Example #1
0
 def test_url_absolute_path(self):
     client = RequestsClient('localhost', path_prefix='/api/v1')
     expected = 'http://localhost/api/v2/test'
     self.assertEqual(client.url_for('/api/v2/test', relative=False),
                      expected)
     self.assertEqual(client.url_for('api/v2/test', relative=False),
                      expected)
Example #2
0
 def test_validator_on_multiple_sets(self):
     expected = 'https://localhost:1234/api/v1/'
     client = RequestsClient(expected)
     self.assertEqual(client.url_for(''), expected)
     client.port = 3456
     self.assertEqual(client.url_for(''), 'https://localhost:3456/api/v1/')
     with self.assertRaises(ValueError):
         client.port = 'test'
     self.assertEqual(client.url_for(''), 'https://localhost:3456/api/v1/')
Example #3
0
 def test_update_url_parts(self):
     expected = 'https://localhost:1234/api/v1/'
     client = RequestsClient(expected)
     self.assertEqual(client.url_for(''), expected)
     client.port = 3456
     self.assertEqual(client.url_for(''), 'https://localhost:3456/api/v1/')
Example #4
0
 def test_url_relative_path(self):
     client = RequestsClient('localhost', path_prefix='/api/v1')
     expected = 'http://localhost/api/v1/test'
     self.assertEqual(client.url_for('test'), expected)
     self.assertEqual(client.url_for('/test'), expected)