Skip to content

Commit

Permalink
[#2939] Fix tests in tests/functional/test_tag_vocab.p
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Oct 12, 2012
1 parent 3ab3559 commit 0a1ec62
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions ckan/tests/functional/test_tag_vocab.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def setup_class(cls):
# create a test vocab
params = json.dumps({'name': TEST_VOCAB_NAME})
extra_environ = {'Authorization' : str(cls.sysadmin_user.apikey)}
cls.extra_environ = {'Authorization' : str(cls.sysadmin_user.apikey)}
response = cls.app.post('/api/action/vocabulary_create', params=params,
extra_environ=extra_environ)
assert json.loads(response.body)['success']
Expand Down Expand Up @@ -146,11 +147,11 @@ def test_01_dataset_view(self):
def test_02_dataset_edit_add_vocab_tag(self):
vocab_id = self._get_vocab_id(TEST_VOCAB_NAME)
url = h.url_for(controller='package', action='edit', id=self.dset.id)
response = self.app.get(url)
response = self.app.get(url, extra_environ=self.extra_environ)
fv = response.forms['dataset-edit']
fv = Form(fv.response, fv.text)
fv['vocab_tags'] = [self.tag2_name]
response = fv.submit('save')
response = fv.submit('save', extra_environ=self.extra_environ)
response = response.follow()
assert not self.tag1_name in response.body
assert self.tag2_name in response.body
Expand All @@ -160,7 +161,7 @@ def test_02_dataset_edit_add_vocab_tag(self):
def test_02_dataset_edit_add_free_and_vocab_tags_then_edit_again(self):
vocab_id = self._get_vocab_id(TEST_VOCAB_NAME)
url = h.url_for(controller='package', action='edit', id=self.dset.id)
response = self.app.get(url)
response = self.app.get(url, extra_environ=self.extra_environ)
fv = response.forms['dataset-edit']
fv = Form(fv.response, fv.text)

Expand All @@ -171,12 +172,12 @@ def test_02_dataset_edit_add_free_and_vocab_tags_then_edit_again(self):
fv['vocab_tags'] = [self.tag2_name]

# Save the dataset and visit the page again
response = fv.submit('save')
response = fv.submit('save', extra_environ=self.extra_environ)
response = response.follow()
assert not self.tag1_name in response.body
assert self.tag2_name in response.body
url = h.url_for(controller='package', action='edit', id=self.dset.id)
response = self.app.get(url)
response = self.app.get(url, extra_environ=self.extra_environ)
fv = response.forms['dataset-edit']
fv = Form(fv.response, fv.text)
assert fv['vocab_tags'].value == [self.tag2_name], fv['vocab_tags'].value
Expand All @@ -186,11 +187,11 @@ def test_03_dataset_edit_remove_vocab_tag(self):
vocab_id = self._get_vocab_id(TEST_VOCAB_NAME)
self._add_vocab_tag_to_dataset(self.dset.id, vocab_id, self.tag1_name)
url = h.url_for(controller='package', action='edit', id=self.dset.id)
response = self.app.get(url)
response = self.app.get(url, extra_environ=self.extra_environ)
fv = response.forms['dataset-edit']
fv = Form(fv.response, fv.text)
fv['vocab_tags'] = []
response = fv.submit('save')
response = fv.submit('save', extra_environ=self.extra_environ)
response = response.follow()
assert not self.tag1_name in response.body
self._remove_vocab_tags(self.dset.id, vocab_id, self.tag1_name)
Expand All @@ -199,11 +200,11 @@ def test_04_dataset_edit_change_vocab_tag(self):
vocab_id = self._get_vocab_id(TEST_VOCAB_NAME)
self._add_vocab_tag_to_dataset(self.dset.id, vocab_id, self.tag1_name)
url = h.url_for(controller='package', action='edit', id=self.dset.id)
response = self.app.get(url)
response = self.app.get(url, extra_environ=self.extra_environ)
fv = response.forms['dataset-edit']
fv = Form(fv.response, fv.text)
fv['vocab_tags'] = [self.tag2_name]
response = fv.submit('save')
response = fv.submit('save', extra_environ=self.extra_environ)
response = response.follow()
assert not self.tag1_name in response.body
assert self.tag2_name in response.body
Expand All @@ -212,11 +213,11 @@ def test_04_dataset_edit_change_vocab_tag(self):
def test_05_dataset_edit_add_multiple_vocab_tags(self):
vocab_id = self._get_vocab_id(TEST_VOCAB_NAME)
url = h.url_for(controller='package', action='edit', id=self.dset.id)
response = self.app.get(url)
response = self.app.get(url, extra_environ=self.extra_environ)
fv = response.forms['dataset-edit']
fv = Form(fv.response, fv.text)
fv['vocab_tags'] = [self.tag1_name, self.tag2_name]
response = fv.submit('save')
response = fv.submit('save', extra_environ=self.extra_environ)
response = response.follow()
assert self.tag1_name in response.body
assert self.tag2_name in response.body
Expand Down

0 comments on commit 0a1ec62

Please sign in to comment.