Viewing file: client_test.py (1.17 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
import unittest import requests import jsonschema import json
class ClientTest(unittest.TestCase):
def setUp(self): import config_loader self.__url = config_loader.client_url with open('./schemas/client_list.json') as json_file: self.__list_schema = json.load(json_file) def test_get_collection(self): r = requests.get(self.__url) jsonschema.validate(r.json(), self.__list_schema) self.assertEqual(r.status_code, 200)
def test_insert_client(self): import uuid # get a substr of the uuid generated client_name = str(uuid.uuid4())[0:25] # there is a difference between get and post # we use telephone as key name in get and phone in post client = { 'province': '', 'city': 'RESISTENCIA', 'expresso': '', 'name': client_name, 'cuit': '20108828987', 'mail': '', 'phone': '(03722)424151 / 15218080', 'address': 'ARTURO FRONDIZI 223', 'business_name': client_name, 'id': 1 } response = requests.post(self.__url, data=json.dumps(client)) self.assertEqual(response.status_code, 200)
|