def test_a_default_post(self): t = Three('api.city.gov', api_key='my_api_key') t.post('123', name='Zach Williams', address='85 2nd Street') params = {'first_name': 'Zach', 'last_name': 'Williams', 'service_code': '123', 'address_string': '85 2nd Street', 'api_key': 'my_api_key'} expected = 'https://api.city.gov/requests.json' t.session.post.assert_called_with(expected, data=params, files=None)
def test_a_default_post(self): t = Three("api.city.gov", api_key="my_api_key") t.post("123", name="Zach Williams", address="85 2nd Street") params = { "first_name": "Zach", "last_name": "Williams", "service_code": "123", "address_string": "85 2nd Street", "api_key": "my_api_key", } expected = "https://api.city.gov/requests.json" req.post.assert_called_with(expected, data=params)
def test_a_default_post(self): t = Three('api.city.gov', api_key='my_api_key') t.post('123', name='Zach Williams', address='85 2nd Street') params = { 'first_name': 'Zach', 'last_name': 'Williams', 'service_code': '123', 'address_string': '85 2nd Street', 'api_key': 'my_api_key' } expected = 'https://api.city.gov/requests.json' req.post.assert_called_with(expected, data=params)
def test_post_request_with_api_key_argument(self): t = Three('http://seeclicktest.com/open311/v2') t.post('1627', name='Zach Williams', address='120 Spring St', description='Just a test post.', phone='555-5555', api_key='my_api_key') params = { 'first_name': 'Zach', 'last_name': 'Williams', 'description': 'Just a test post.', 'service_code': '1627', 'address_string': '120 Spring St', 'phone': '555-5555', 'api_key': 'my_api_key' } expected = 'http://seeclicktest.com/open311/v2/requests.json' t.session.post.assert_called_with(expected, data=params, files=None)
def test_post_request_with_api_key_argument(self): t = Three('http://seeclicktest.com/open311/v2') t.post('1627', name='Zach Williams', address='120 Spring St', description='Just a test post.', phone='555-5555', api_key='my_api_key') params = { 'first_name': 'Zach', 'last_name': 'Williams', 'description': 'Just a test post.', 'service_code': '1627', 'address_string': '120 Spring St', 'phone': '555-5555', 'api_key': 'my_api_key' } expected = 'http://seeclicktest.com/open311/v2/requests.json' t.session.post.assert_called_with(expected, data=params, files=None)
def test_post_request_with_api_key_argument(self): t = Three("http://seeclicktest.com/open311/v2") t.post( "1627", name="Zach Williams", address="120 Spring St", description="Just a test post.", phone="555-5555", api_key="my_api_key", ) params = { "first_name": "Zach", "last_name": "Williams", "description": "Just a test post.", "service_code": "1627", "address_string": "120 Spring St", "phone": "555-5555", "api_key": "my_api_key", } expected = "http://seeclicktest.com/open311/v2/requests.json" req.post.assert_called_with(expected, data=params)
def test_a_default_post(self): responses.add(responses.POST, 'https://api.city.gov/requests.json', body="""[ { "service_request_id":293944, "service_notice":"The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code", "account_id":null } ]""", status=201, content_type='application/json') t = Three('api.city.gov', api_key='my_api_key') resp = t.post('123', name='Zach Williams', address='85 2nd Street') params = {'first_name': 'Zach', 'last_name': 'Williams', 'service_code': '123', 'address_string': '85 2nd Street', 'api_key': 'my_api_key'} assert resp.status_code == 201
def test_a_default_post(self): responses.add(responses.POST, 'https://api.city.gov/requests.json', body="""[ { "service_request_id":293944, "service_notice":"The City will inspect and require the responsible party to correct within 24 hours and/or issue a Correction Notice or Notice of Violation of the Public Works Code", "account_id":null } ]""", status=201, content_type='application/json') t = Three('api.city.gov', api_key='my_api_key') resp = t.post('123', name='Zach Williams', address='85 2nd Street') params = { 'first_name': 'Zach', 'last_name': 'Williams', 'service_code': '123', 'address_string': '85 2nd Street', 'api_key': 'my_api_key' } assert resp.status_code == 201