Beispiel #1
0
 def test_post_bad_resource(self):
     with self.assertRaises(api.RecordSetException) as cm:
         obj = api.post_resource(self.collection, self.agent, 'Agent',
                                 {'agenttype': 0,
                                  'lastname': 'MonkeyWrench',
                                  'division': api.uri_for_model('division', self.division.id)},
                                 recordsetid=self.recordset.id)
     self.assertEqual(models.Agent.objects.filter(lastname='MonkeyWrench').count(), 0)
Beispiel #2
0
 def test_post_resource_to_bad_recordset(self):
     max_id = models.Recordset.objects.aggregate(Max('id'))['id__max']
     with self.assertRaises(api.RecordSetException) as cm:
         obj = api.post_resource(self.collection, self.agent, 'Agent',
                                 {'agenttype': 0,
                                  'lastname': 'Pitts',
                                  'division': api.uri_for_model('division', self.division.id)},
                                 recordsetid=max_id + 100)
     self.assertEqual(models.Agent.objects.filter(lastname='Pitts').count(), 0)
Beispiel #3
0
 def test_post_resource(self):
     obj = api.post_resource(
         self.collection,
         self.agent,
         'collectionobject', {
             'collection': api.uri_for_model('collection',
                                             self.collection.id),
             'catalognumber': 'foobar'
         },
         recordsetid=self.recordset.id)
     self.assertEqual(
         self.recordset.recordsetitems.filter(recordid=obj.id).count(), 1)
Beispiel #4
0
 def test_post_bad_resource(self):
     with self.assertRaises(api.RecordSetException) as cm:
         obj = api.post_resource(
             self.collection,
             self.agent,
             'Agent', {
                 'agenttype': 0,
                 'lastname': 'MonkeyWrench',
                 'division': api.uri_for_model('division', self.division.id)
             },
             recordsetid=self.recordset.id)
     self.assertEqual(
         models.Agent.objects.filter(lastname='MonkeyWrench').count(), 0)
Beispiel #5
0
 def test_post_resource_to_bad_recordset(self):
     max_id = models.Recordset.objects.aggregate(Max('id'))['id__max']
     with self.assertRaises(api.RecordSetException) as cm:
         obj = api.post_resource(
             self.collection,
             self.agent,
             'Agent', {
                 'agenttype': 0,
                 'lastname': 'Pitts',
                 'division': api.uri_for_model('division', self.division.id)
             },
             recordsetid=max_id + 100)
     self.assertEqual(
         models.Agent.objects.filter(lastname='Pitts').count(), 0)
Beispiel #6
0
 def test_post_resource(self):
     obj = api.post_resource(self.collection, self.agent, 'collectionobject', {
             'collection': api.uri_for_model('collection', self.collection.id),
             'catalognumber': 'foobar'}, recordsetid=self.recordset.id)
     self.assertEqual(self.recordset.recordsetitems.filter(recordid=obj.id).count(), 1)