Example #1
0
 def test_put_with_bad_sha(self):
     user = User()
     resource = AddressableUserResource(user)
     resource.get = lambda *args: {"age": 20, "name": "Bob"}
     request = self.make_request('{"age": 20, "name": "Bob"}', 'OmManePadmeHumOmManePadmeHumOmManePadmeHum')
     response = views._process_put(mock_context(), resource, request)
     self.assertEqual(response.status_code, 412)
Example #2
0
 def test_put_with_good_sha(self):
     user = User()
     resource = AddressableUserResource(user)
     resource.get = lambda *args: {"age": 20, "name": "Bob"}
     request = self.make_request('{"age": 20, "name": "Bob"}', 'fd92376f24d6a75974c8da6edf84a834b92ee13c')
     response = views._process_put(mock_context(), resource, request)
     self.assertEqual(response.status_code, 204)
Example #3
0
 def test_put_with_missing_required_field(self):
     user = User()
     request = self.make_request('{"name": "Bob"}')   # no age
     response = views._process_put(mock_context(),
                                   AddressableUserResource(user),
                                   request)
     errors = json.loads(response.content)
     self.assertTrue('validation_errors' in errors)
     self.assertEqual(errors['validation_errors'], {'missingField': 'age', 'target': 'User'})