def test_purge_datasets_community(): dataset = Dataset.objects.create(title='delete me', deleted='2016-01-01') community_resource1 = CommunityResourceFactory() community_resource1.dataset = dataset community_resource1.save() tasks.purge_datasets() assert CommunityResource.objects.count() == 0
def test_purge_orphan_community(): dataset = Dataset.objects.create(title='test_dataset') community_resource1 = CommunityResourceFactory(title='test_community_1') community_resource2 = CommunityResourceFactory(title='test_community_2') community_resource1.dataset = dataset community_resource1.save() tasks.purge_orphan_community_resources() assert CommunityResource.objects.count() == 1
def test_community_resource(self): user = UserFactory() dataset = DatasetFactory(owner=user) community_resource1 = CommunityResourceFactory() community_resource1.dataset = dataset community_resource1.save() assert len(dataset.community_resources) == 1 community_resource2 = CommunityResourceFactory() community_resource2.dataset = dataset community_resource2.save() assert len(dataset.community_resources) == 2 assert dataset.community_resources[1].id == community_resource1.id assert dataset.community_resources[0].id == community_resource2.id
def test_community_resource(self): user = UserFactory() dataset = DatasetFactory(owner=user) community_resource1 = CommunityResourceFactory() community_resource1.dataset = dataset community_resource1.save() self.assertEqual(len(dataset.community_resources), 1) community_resource2 = CommunityResourceFactory() community_resource2.dataset = dataset community_resource2.save() self.assertEqual(len(dataset.community_resources), 2) self.assertEqual(dataset.community_resources[1].id, community_resource1.id) self.assertEqual(dataset.community_resources[0].id, community_resource2.id)