diff --git a/ckan/tests/functional/api/model/test_vocabulary.py b/ckan/tests/functional/api/model/test_vocabulary.py index 6143bef1781..14475f962a5 100644 --- a/ckan/tests/functional/api/model/test_vocabulary.py +++ b/ckan/tests/functional/api/model/test_vocabulary.py @@ -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',