Skip to content

Commit

Permalink
fix tests for api changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Feb 24, 2012
1 parent 6f743b6 commit 3fab4a1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
23 changes: 19 additions & 4 deletions ckan/tests/functional/api/test_activity.py
Expand Up @@ -4,8 +4,8 @@

import ckan
import ckan.model as model
from ckan.logic.action.create import package_create, user_create, group_create
from ckan.logic.action.update import package_update, resource_update
from ckan.logic.action.create import package_create as _package_create, user_create, group_create
from ckan.logic.action.update import package_update as _package_update, resource_update
from ckan.logic.action.update import user_update, group_update
from ckan.logic.action.delete import package_delete
from ckan.logic.action.get import package_list, package_show
Expand All @@ -14,6 +14,21 @@
import paste.fixture
from ckan.lib.helpers import json


def package_update(context, data_dict):
# These tests call package_update directly which is really bad
# setting api_version in context make things seem like the api key
# is ok etc
context['api_version'] = 3
return _package_update(context, data_dict)

def package_create(context, data_dict):
# These tests call package_update directly which is really bad
# setting api_version in context make things seem like the api key
# is ok etc
context['api_version'] = 3
return _package_create(context, data_dict)

def datetime_from_string(s):
'''Return a standard datetime.datetime object initialised from a string in
the same format used for timestamps in dictized activities (the format
Expand Down Expand Up @@ -949,7 +964,7 @@ def test_add_tag(self):
'id': pkg_dict['id'],
'tags': new_tag_list
}
ckan.logic.action.update.package_update(context, data_dict)
package_update(context, data_dict)
after = self.record_details(user.id, pkg_dict['id'])

# Find the new activity in the user's activity stream.
Expand Down Expand Up @@ -1020,7 +1035,7 @@ def test_remove_tag(self):
'id': pkg_dict['id'],
'tags': pkg_dict['tags'][0:-1],
}
ckan.logic.action.update.package_update(context, data_dict)
package_update(context, data_dict)
after = self.record_details(user.id, pkg_dict['id'])

# Find the new activity in the user's activity stream.
Expand Down
5 changes: 5 additions & 0 deletions ckan/tests/functional/test_activity.py
Expand Up @@ -53,6 +53,11 @@ def test_activity(self):
'title' : "Billy's Stats about Baseball Players",
}
context['user'] = user['name']
# FIXME This test use an old way to get at the schema to
# recreate this we need to pretend to be using the api. We
# should not be calling package_create like this we should be
# going via the api or package controllers
context['api_version'] = 3
package = package_create(context, package)
result = self.app.get(offset, status=200)
stripped = self.strip_tags(result)
Expand Down
2 changes: 2 additions & 0 deletions ckan/tests/functional/test_package.py
Expand Up @@ -381,6 +381,8 @@ def test_resource_list(self):
data = {'id': 'annakarenina'}
pkg = get.package_show(context, data)
pkg['resources'][0]['cache_url'] = cache_url
# FIXME need to pretend to be called by the api
context['api_version'] = 3
update.package_update(context, pkg)
# check that the cache url is included on the dataset view page
offset = url_for(controller='package', action='read', id=name)
Expand Down

0 comments on commit 3fab4a1

Please sign in to comment.