-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Reindex datasets when an organization is purged
- Loading branch information
Showing
4 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .. import TestCase, SearchTestMixin | ||
|
||
from udata.models import Dataset, Organization | ||
from udata.core.dataset.factories import DatasetFactory, ResourceFactory | ||
from udata.core.dataset.search import DatasetSearch | ||
from udata.core.organization import tasks | ||
from udata.search import es | ||
|
||
|
||
class OrganizationTasksTest(SearchTestMixin, TestCase): | ||
def test_purge_organizations(self): | ||
with self.autoindex(): | ||
org = Organization.objects.create( | ||
name='delete me', deleted='2016-01-01', description='XXX') | ||
resources = [ResourceFactory() for _ in range(2)] | ||
dataset = DatasetFactory(resources=resources, organization=org) | ||
|
||
tasks.purge_organizations() | ||
|
||
dataset = Dataset.objects(id=dataset.id).first() | ||
self.assertEqual(dataset.organization, None) | ||
|
||
organization = Organization.objects(name='delete me').first() | ||
self.assertEqual(organization, None) | ||
|
||
indexed_dataset = DatasetSearch.get(id=dataset.id, | ||
using=es.client, | ||
index=es.index_name) | ||
self.assertEqual(indexed_dataset.organization, '') |