def test_get_dataset_lists_return_correct_ids(self): node1 = Node.objects.get(catalog_id='id1') datajson = DataJson(self.get_sample('full_data.json')) valid, _, _ = sort_datasets_by_condition(node1, datajson) self.assertSetEqual( { '99db6631-d1c9-470b-a73e-c62daa32c777', '99db6631-d1c9-470b-a73e-c62daa32c420' }, valid) dataset = Dataset.objects.get( catalog__identifier='id1', identifier='99db6631-d1c9-470b-a73e-c62daa32c777') dataset.identifier = 'new_identifier' dataset.save() dataset = datajson.get_dataset( identifier='99db6631-d1c9-470b-a73e-c62daa32c777') dataset['identifier'] = 'new_identifier' valid, _, _ = sort_datasets_by_condition(node1, datajson) self.assertSetEqual( {'new_identifier', '99db6631-d1c9-470b-a73e-c62daa32c420'}, valid) dataset = Dataset.objects.get(catalog__identifier='id1', identifier='new_identifier') dataset.indexable = False dataset.save() valid, _, _ = sort_datasets_by_condition(node1, datajson) self.assertSetEqual({'99db6631-d1c9-470b-a73e-c62daa32c420'}, valid)
def test_get_dataset_does_not_return_invalid_datasets(self): node = Node.objects.get(catalog_id='id3') datajson = DataJson(self.get_sample('missing_dataset_title.json')) valid, invalid, _ = sort_datasets_by_condition(node, datajson) self.assertSetEqual(set(), valid) self.assertSetEqual({'99db6631-d1c9-470b-a73e-c62daa32c777'}, invalid) dataset = datajson.get_dataset( identifier='99db6631-d1c9-470b-a73e-c62daa32c777') dataset['title'] = 'aTitle' valid, invalid, _ = sort_datasets_by_condition(node, datajson) self.assertSetEqual({'99db6631-d1c9-470b-a73e-c62daa32c777'}, valid) self.assertSetEqual(set(), invalid)