Skip to content

Commit

Permalink
Improve test for package.purge
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed May 24, 2019
1 parent 687afaf commit 00819a3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ckan/tests/model/test_package.py
Expand Up @@ -77,11 +77,15 @@ def test_delete(self):
assert_equal([p.name for p in tag.packages], [dataset['name']])

def test_purge(self):
org = factories.Organization()
group = factories.Group()
dataset = factories.Dataset(
groups=[{u'id': group['id']}],
resources=[{u'url': u'http://example.com/image.png',
u'format': u'png', u'name': u'Image 1'}],
tags=[{u'name': u'science'}],
extras=[{u'key': u'subject', u'value': u'science'}],
groups=[{u'id': group['id']}],
owner_org=org['id'],
)
pkg = model.Package.by_name(dataset['name'])

Expand All @@ -94,6 +98,10 @@ def test_purge(self):
# the purge cascades to some objects
assert not model.Session.query(model.PackageExtra).all()
assert not model.Session.query(model.PackageTag).all()
assert not model.Session.query(model.Resource).all()
# org remains, just not attached to the package
org = model.Group.get(org['id'])
assert_equal(org.packages(), [])
# tag object remains, just not attached to the package
tag = model.Session.query(model.Tag).all()[0]
assert_equal(tag.packages, [])
Expand Down

0 comments on commit 00819a3

Please sign in to comment.