Exemple #1
0
 def test_get_collection(self):
     data = api.get_collection(self.collection, 'collectionobject')
     self.assertEqual(data['meta']['total_count'], len(self.collectionobjects))
     self.assertEqual(len(data['objects']), len(self.collectionobjects))
     ids = [obj['id'] for obj in data['objects']]
     for co in self.collectionobjects:
         self.assertTrue(co.id in ids)
Exemple #2
0
 def test_get_collection(self):
     data = api.get_collection(self.collection, 'collectionobject')
     self.assertEqual(data['meta']['total_count'],
                      len(self.collectionobjects))
     self.assertEqual(len(data['objects']), len(self.collectionobjects))
     ids = [obj['id'] for obj in data['objects']]
     for co in self.collectionobjects:
         self.assertTrue(co.id in ids)
Exemple #3
0
    def test_inlined_inlines(self):
        preptype = models.Preptype.objects.create(collection=self.collection)

        for i in range(3):
            self.collectionobjects[0].preparations.create(
                collectionmemberid=self.collection.id, preptype=preptype)
        data = api.get_collection(self.collection, 'collectionobject')
        co = next(obj for obj in data['objects']
                  if obj['id'] == self.collectionobjects[0].id)
        self.assertTrue(isinstance(co['preparations'], list))
        self.assertEqual(co['preparations'][0]['preparationattachments'], [])
Exemple #4
0
    def test_inlined_inlines(self):
        preptype = models.Preptype.objects.create(
            collection=self.collection)

        for i in range(3):
            self.collectionobjects[0].preparations.create(
                collectionmemberid=self.collection.id,
                preptype=preptype)
        data = api.get_collection(self.collection, 'collectionobject')
        co = next(obj for obj in data['objects'] if obj['id'] == self.collectionobjects[0].id)
        self.assertTrue(isinstance(co['preparations'], list))
        self.assertEqual(co['preparations'][0]['preparationattachments'], [])
Exemple #5
0
    def test_recordsetitem_ordering(self):
        ids = [co.id for co in self.collectionobjects]
        ids.sort()
        ids.reverse()

        for id in ids:
            self.recordset.recordsetitems.create(recordid=id)

        rsis = api.get_collection(self.collection, 'recordsetitem',
                                  {'recordset': self.recordset.id})

        result_ids = [rsi['recordid'] for rsi in rsis['objects']]
        ids.sort()
        self.assertEqual(result_ids, ids)
Exemple #6
0
    def test_recordsetitem_ordering(self):
        ids = [co.id for co in self.collectionobjects]
        ids.sort()
        ids.reverse()

        for id in ids:
            self.recordset.recordsetitems.create(recordid=id)

        rsis = api.get_collection(self.collection, 'recordsetitem', {
                'recordset': self.recordset.id})

        result_ids = [rsi['recordid'] for rsi in rsis['objects']]
        ids.sort()
        self.assertEqual(result_ids, ids)
Exemple #7
0
    def test_inlined_in_collection(self):
        dets = [self.collectionobjects[0].determinations.create(iscurrent=False, number1=i)
                for i in range(3)]

        data = api.get_collection(self.collection, 'collectionobject')
        for obj in data['objects']:
            self.assertTrue(isinstance(obj['determinations'], list))
            if obj['id'] == self.collectionobjects[0].id:
                serialized_dets = obj['determinations']
                self.assertEqual(len(obj['determinations']), 3)
            else:
                self.assertEqual(len(obj['determinations']), 0)

        ids = {d['id'] for d in serialized_dets}
        for det in dets:
            self.assertTrue(det.id in ids)
Exemple #8
0
    def test_inlined_in_collection(self):
        dets = [
            self.collectionobjects[0].determinations.create(iscurrent=False,
                                                            number1=i)
            for i in range(3)
        ]

        data = api.get_collection(self.collection, 'collectionobject')
        for obj in data['objects']:
            self.assertTrue(isinstance(obj['determinations'], list))
            if obj['id'] == self.collectionobjects[0].id:
                serialized_dets = obj['determinations']
                self.assertEqual(len(obj['determinations']), 3)
            else:
                self.assertEqual(len(obj['determinations']), 0)

        ids = {d['id'] for d in serialized_dets}
        for det in dets:
            self.assertTrue(det.id in ids)