def setUp(self): self.config = {'host': 'localhost:8888', 'service': 'foo'} self.adapter = RestfulHttpAdapter(self.config) self.records = [{'id': 1}, {'id': 2}, {'id': 3}] http_server.set_response(body=json.dumps(self.records))
def test_missing_host(self): """should raise if host is not configured""" del self.config['host'] adapter = RestfulHttpAdapter(self.config) self.assertRaises(errors.ConfigurationError, adapter.http_request, 'GET', 'foo', {})
def test_with_wrapper(self): """should wrap the model's attributes with the given string""" self.config['params_wrapper'] = 'widget' adapter = RestfulHttpAdapter(self.config) params = adapter.params_for(self.model) self.assertEqual(params, {'widget': self.model.fields})