def test_config(self): config = appconfig('config:test.ini', relative_to=conf_dir) config.local_conf['ckan.plugins'] = 'googleanalytics' config.local_conf['googleanalytics.id'] = '' command = LoadAnalytics("loadanalytics") command.CONFIG = config.local_conf self.assertRaises(Exception, command.run, [])
def test_config(self): config = appconfig("config:test.ini", relative_to=conf_dir) config.local_conf["ckan.plugins"] = "googleanalytics" config.local_conf["googleanalytics.id"] = "" command = LoadAnalytics("loadanalytics") command.CONFIG = config.local_conf self.assertRaises(Exception, command.run, [])
def test_download_count_inserted(self): command = LoadAnalytics("loadanalytics") command.TEST_HOST = MockClient('localhost', 6969) command.CONFIG = self.config command.run([]) response = self.app.get(url_for( controller='package', action='read', id='annakarenina' )) assert "[downloaded 4 times]" in response.body
def test_top_packages(self): command = LoadAnalytics("loadanalytics") command.TEST_HOST = MockClient('localhost', 6969) command.CONFIG = self.config command.run([]) packages = dbutil.get_top_packages() resources = dbutil.get_top_resources() self.assertEquals(packages[0][1], 2) self.assertEquals(resources[0][1], 4)
def test_js_inserted_resource_view(self): from nose import SkipTest raise SkipTest("Test won't work until CKAN 1.5.2") from ckan.logic.action import get from ckan import model context = {'model': model, 'ignore_auth': True} data = {'id': 'annakarenina'} pkg = get.package_show(context, data) resource_id = pkg['resources'][0]['id'] command = LoadAnalytics("loadanalytics") command.TEST_HOST = MockClient('localhost', 6969) command.CONFIG = self.config command.run([]) response = self.app.get(url_for( controller='package', action='resource_read', id='annakarenina', resource_id=resource_id )) assert 'onclick="javascript: _gaq.push(' in response.body
def test_js_inserted_resource_view(self): from nose import SkipTest raise SkipTest("Test won't work until CKAN 1.5.2") from ckan.logic.action import get from ckan import model context = {"model": model, "ignore_auth": True} data = {"id": "annakarenina"} pkg = get.package_show(context, data) resource_id = pkg["resources"][0]["id"] command = LoadAnalytics("loadanalytics") command.TEST_HOST = MockClient("localhost", 6969) command.CONFIG = self.config command.run([]) response = self.app.get( url_for( controller="package", action="resource_read", id="annakarenina", resource_id=resource_id, )) assert 'onclick="javascript: _gaq.push(' in response.body
def test_download_count_inserted(self): command = LoadAnalytics("loadanalytics") command.TEST_HOST = MockClient('localhost', 6969) command.CONFIG = self.config command.run([]) response = self.app.get( url_for(controller='package', action='read', id='annakarenina')) assert "[downloaded 4 times]" in response.body