Skip to content

Commit

Permalink
[#430] Add test for packages in vocab list.
Browse files Browse the repository at this point in the history
From seanh commit 4c917f5
  • Loading branch information
johnglover committed Mar 19, 2013
1 parent abf2729 commit f527dfc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ckan/tests/functional/api/model/test_vocabulary.py
Expand Up @@ -826,6 +826,28 @@ def test_add_vocab_tag_to_dataset(self):
tag_in_pkg['vocabulary_id'] == tag['vocabulary_id']]
assert len(tags_in_pkg) == 1

# Test that the package appears vocabulary_list.
vocabs = self._post('/api/action/vocabulary_list')['result']
genre_vocab = [vocab for vocab in vocabs if vocab['name'] == 'Genre']
assert len(genre_vocab) == 1
genre_vocab = genre_vocab[0]
noise_tag = [tag_ for tag_ in genre_vocab['tags']
if tag_['name'] == 'noise']
assert len(noise_tag) == 1
noise_tag = noise_tag[0]
assert len([p for p in noise_tag['packages'] if
p['id'] == updated_package['id']]) == 1

# Test that the tagged package appears in vocabulary_show.
genre_vocab = self._post('/api/action/vocabulary_show',
params={'id': genre_vocab['id']})['result']
noise_tag = [tag_ for tag_ in genre_vocab['tags']
if tag_['name'] == 'noise']
assert len(noise_tag) == 1
noise_tag = noise_tag[0]
assert len([p for p in noise_tag['packages'] if
p['id'] == updated_package['id']]) == 1

# Remove the new vocab tag from the package.
package['tags'].remove(tag)
updated_package = (self._post('/api/action/package_update',
Expand Down

0 comments on commit f527dfc

Please sign in to comment.