Beispiel #1
0
 def test_query_parameter_in_path_generates_warning(self):
     with warnings.catch_warnings(record=True) as warning_records:
         warnings.simplefilter('always')
         foo = endpoint.Endpoint(path='/?foo=bar')
         self.assertEqual(1, len(warning_records))
         self.assertTrue(
             issubclass(warning_records[-1].category, UserWarning))
Beispiel #2
0
 def test_path_when_doesnt_end_with_slash_and_check_is_on(self):
     with warnings.catch_warnings(record=True) as warning_records:
         warnings.simplefilter('always')
         foo = endpoint.Endpoint(path='/foo')
         self.assertEqual(1, len(warning_records))
         self.assertTrue(issubclass(warning_records[-1].category, UserWarning))
         self.assertEqual('/foo', foo.path)
Beispiel #3
0
 def test_format_path_with_extra_kwargs(self):
     foo = endpoint.Endpoint(path='/{one}/{two}/')
     path_kwargs = {'one': 'foo', 'two': 'bar', 'three': 'not used'}
     self.assertEqual('/foo/bar/', foo.get_formatted_path(**path_kwargs))
Beispiel #4
0
 def test_format_path_with_correct_kwargs(self):
     foo = endpoint.Endpoint(path='/{one}/{two}/')
     path_kwargs = {'one': 'foo', 'two': 'bar'}
     assert '/foo/bar/' == foo.get_formatted_path(**path_kwargs)
Beispiel #5
0
 def test_str_method(self):
     foo = endpoint.Endpoint(path='/foo/bar/')
     self.assertEqual('/foo/bar/', str(foo))
Beispiel #6
0
 def test_format_path_with_incorrect_kwargs(self):
     foo = endpoint.Endpoint(path='/{one}/{two}/')
     path_kwargs = {'foo': 'bar'}
     with self.assertRaises(KeyError):
         foo.get_formatted_path(**path_kwargs)
Beispiel #7
0
 def test_format_response(self):
     foo = endpoint.Endpoint()
     mock_response = mock.Mock()
     mock_response.text = 'foobar'
     self.assertEqual('foobar', foo.format_response(mock_response))
Beispiel #8
0
 def test_required_headers(self):
     foo = endpoint.Endpoint()
     self.assertDictEqual({}, foo.required_headers)
Beispiel #9
0
 def test_default_attributes_from_constructor(self):
     foo = endpoint.Endpoint()
     self.assertEqual('/', foo.path)
     self.assertEqual('GET', foo.default_method)
Beispiel #10
0
 def test_constructor_stores_passed_attributes(self):
     foo = endpoint.Endpoint(path='/foo/', default_method='POST')
     self.assertEqual('/foo/', foo.path)
     self.assertEqual('POST', foo.default_method)
Beispiel #11
0
 def test_str_method(self):
     foo = endpoint.Endpoint(path='/foo/bar/')
     assert '/foo/bar/' == str(foo)
Beispiel #12
0
 def test_call(self, service):
     service.foo = endpoint.Endpoint()
     service.foo()
Beispiel #13
0
 def test_required_headers(self):
     foo = endpoint.Endpoint()
     assert {} == foo.required_headers
Beispiel #14
0
 def test_format_response(self):
     foo = endpoint.Endpoint()
     mock_response = mock.Mock()
     mock_response.text = 'foobar'
     assert 'foobar' == foo.format_response(mock_response)
Beispiel #15
0
 def test_constructor_stores_passed_attributes(self):
     foo = endpoint.Endpoint(path='/foo/', default_method='POST')
     assert '/foo/' == foo.path
     assert 'POST' == foo.default_method
Beispiel #16
0
 def test_default_attributes_from_constructor(self):
     foo = endpoint.Endpoint()
     assert '/' == foo.path
     assert 'GET' == foo.default_method
Beispiel #17
0
 def test_call_without_service_raises_exception(self):
     foo = endpoint.Endpoint()
     with pytest.raises(TypeError):
         foo()