Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add back pkg.extras_list, which was just removed in #4691
- Loading branch information
David Read
committed
May 10, 2019
1 parent
bcf1271
commit 1fc1442
Showing
2 changed files
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# encoding: utf-8 | ||
|
||
from nose.tools import assert_equal | ||
|
||
from ckan import model | ||
from ckan.tests import helpers, factories | ||
|
||
|
||
class TestPackage(object): | ||
|
||
def setup(self): | ||
helpers.reset_db() | ||
|
||
def test_extras_list(self): | ||
extras = [ | ||
{u'key': u'subject', u'value': u'science'}, | ||
{u'key': u'accuracy', u'value': u'metre'}, | ||
{u'key': u'sample_years', u'value': u'2012-2013'}, | ||
] | ||
dataset = factories.Dataset(extras=extras) | ||
# delete the 'subject' extra | ||
extras = extras[1:] | ||
helpers.call_action(u'package_patch', id=dataset['id'], extras=extras) | ||
# unrelated extra, to check it doesn't affect things | ||
factories.Dataset(extras=[{u'key': u'foo', u'value': u'bar'}]) | ||
|
||
pkg = model.Package.by_name(dataset['name']) | ||
assert isinstance(pkg.extras_list[0], model.PackageExtra) | ||
assert_equal( | ||
set([(pe.package_id, pe.key, pe.value, pe.state) | ||
for pe in pkg.extras_list]), | ||
set([(dataset['id'], u'subject', u'science', u'deleted'), | ||
(dataset['id'], u'accuracy', u'metre', u'active'), | ||
(dataset['id'], u'sample_years', u'2012-2013', u'active'), | ||
]) | ||
) |