def setUp(self): # Create demo test_utils.mock_with_file( httpretty.POST, "http://0.0.0.0:3000/api/v1/Demos", "server/tests/mocks/POST_api_v1_Demos_200.json", 200) test_utils.mock_with_file( httpretty.GET, "http://0.0.0.0:3000/api/v1/Demos/DemoGUID/retailers", "server/tests/mocks/GET_api_v1_Demos_DemoGUID_retailers_200.json", 200) self.demo = test_utils.create_demo() self.retailers = demo_service.get_demo_retailers( loads(self.demo).get('guid'))
def test_demo_retrieve_retailers_success(self): """With correct values, are valid demo retailers returned?""" # Retrieve demo retailers demo_guid = loads(self.demo).get('guid') retailers = demo_service.get_demo_retailers(demo_guid) retailers_json = loads(retailers) # TODO: Update to use assertIsInstance(a,b) # Check that the retailers are valid for retailer_json in retailers_json: self.assertTrue(retailer_json.get('id')) self.assertTrue(retailer_json.get('address')) address_json = retailer_json.get('address') self.assertTrue(address_json.get('city')) self.assertTrue(address_json.get('state')) self.assertTrue(address_json.get('country')) self.assertTrue(address_json.get('latitude')) self.assertTrue(address_json.get('longitude'))
def get_demo_retailers(guid): """ Retrieve a single demo's list of retailers. :param guid: The demo's guid :return: [{ "id": "123", "address": { "city": "Raleigh", "state": "North Carolina", "country": "US", "latitude": 35.71, "longitude": -78.63 }, "managerId": "123" }, {...}] """ web_utils.check_null_input((guid, 'demo for which to retrieve retailers')) retailers = demo_service.get_demo_retailers(guid) return Response(retailers, status=200, mimetype='application/json')
def setUp(self): # Create demo self.demo = test_utils.create_demo() self.retailers = demo_service.get_demo_retailers(loads(self.demo).get('guid'))
def setUp(self): # Create demo self.demo = test_utils.create_demo() self.retailers = demo_service.get_demo_retailers( loads(self.demo).get('guid'))