Skip to content

Instantly share code, notes, and snippets.

@d30jeff
Created May 20, 2015 06:55
Show Gist options
  • Select an option

  • Save d30jeff/f9ff0da118c59990ac24 to your computer and use it in GitHub Desktop.

Select an option

Save d30jeff/f9ff0da118c59990ac24 to your computer and use it in GitHub Desktop.
Nose Test
import requests, json
from func import *
from login import *
from customer import *
from tax import *
# Objects
main = Main('auth')
customer = Customer('customers')
tax = Tax('taxes')
""" Login Block """
def Test_Main_Login_Correct():
r = post(main.url, main.login_credentials_correct())
expect(r, 200)
def Test_Main_Login_Incorrect():
r = post(main.url, main.login_credentials_incorrect())
expect(r, 401)
""" Customer Block """
def Test_Customer_GetList():
r = get(customer.url)
expect(r, 200)
def Test_Customer_Post():
global customer_id
r = post(customer.url, customer.post_data(1))
customer_id = get_id(r)
expect(r, 201)
def Test_Customer_Post_Malformed():
r = post(customer.url, customer.post_data_malformed())
expect(r, 400)
def Test_Customer_GetDetail_Correct():
global customer_edit_seq
r = get(customer.url + customer_id)
customer_edit_seq = getjson(r, 'edit_seq')
expect(r, 200)
def Test_Customer_GetDetail_Incorrect():
r = get(customer.url + str('a'))
expect(r, 500)
def Test_Customer_Update():
global customer_edit_seq
r = put(customer.url + customer_id, customer.put_data(customer_id, customer_edit_seq))
r.status_code
expect(r, 200)
def Test_Customer_Update_Malformed():
r = put(customer.url + customer_id, customer.put_data_malformed())
expect(r, 400)
def Test_Customer_Delete_Correct_ID():
r = delete(customer.url + customer_id)
expect(r, 204)
def Test_Customer_Delete_Incorrect_ID():
r = delete(customer.url + str('a'))
expect(r, 500)
""" Tax Block """
def Test_Tax_GetList():
r = get(tax.url)
expect(r, 200)
def Test_Tax_Post():
global tax_id
r = post(tax.url, tax.post_data())
tax_id = get_id(r)
expect(r, 201)
def Test_Tax_Post_Malformed():
r = post(tax.url, tax.post_data_malformed())
expect(r, 500)
def Test_Tax_GetDetail_Correct():
global tax_id, tax_edit_sequence
r = get(tax.url + tax_id )
tax_edit_sequence = getjson(r, 'edit_seq')
expect(r, 200)
def Test_Tax_GetDetail_Incorrect():
r = get(tax.url + str('a'))
expect(r, 500)
def Test_Tax_Update():
r = put(tax.url + tax_id, tax.put_data(tax_id, tax_edit_sequence))
expect(r, 200)
def Test_Tax_Update_Malformed():
r = put(tax.url + tax_id, tax.put_data_malformed())
expect(r, 409)
def Test_Tax_Delete_Correct_ID():
r = delete(tax.url + tax_id)
expect(r, 204)
def Test_Tax_Delete_Incorrect_ID():
r = delete(tax.url + str('a'))
expect(r, 500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment