Skip to content

Commit

Permalink
Merge pull request #4641 from kmbn/remove-unused-test-imports
Browse files Browse the repository at this point in the history
Remove unused imports from tests
  • Loading branch information
amercader committed Jan 31, 2019
2 parents e358acf + 0e1b600 commit 469713b
Show file tree
Hide file tree
Showing 38 changed files with 20 additions and 130 deletions.
8 changes: 1 addition & 7 deletions ckan/tests/controllers/test_api.py
Expand Up @@ -8,20 +8,14 @@
import re
import mock
import __builtin__ as builtins
from StringIO import StringIO

from nose.tools import assert_equal, assert_in, eq_
from pyfakefs import fake_filesystem

from six import text_type
from six.moves import xrange

from ckan.lib.helpers import url_for
import ckan.tests.helpers as helpers
from ckan.tests import factories
from ckan.lib import helpers as template_helpers, uploader as ckan_uploader
import ckan.plugins as p
from ckan import model
from ckan.lib import uploader as ckan_uploader

fs = fake_filesystem.FakeFilesystem()
fake_os = fake_filesystem.FakeOsModule(fs)
Expand Down
1 change: 0 additions & 1 deletion ckan/tests/controllers/test_organization.py
@@ -1,6 +1,5 @@
# encoding: utf-8

from ckan.common import config
from bs4 import BeautifulSoup
from nose.tools import assert_equal, assert_true, assert_in
from ckan.lib.helpers import url_for
Expand Down
1 change: 0 additions & 1 deletion ckan/tests/controllers/test_package.py
Expand Up @@ -13,7 +13,6 @@

import ckan.model as model
import ckan.plugins as p
from ckan.logic import get_action

import ckan.tests.helpers as helpers
import ckan.tests.factories as factories
Expand Down
2 changes: 0 additions & 2 deletions ckan/tests/controllers/test_util.py
@@ -1,8 +1,6 @@
# encoding: utf-8

from nose.tools import assert_equal
from pylons.test import pylonsapp
import paste.fixture

from ckan.lib.helpers import url_for as url_for

Expand Down
3 changes: 0 additions & 3 deletions ckan/tests/helpers.py
Expand Up @@ -22,15 +22,12 @@

import collections
import contextlib
import errno
import functools
import logging
import os
import re

import webtest
import nose.tools
from nose.tools import assert_in, assert_not_in
import mock
import rq

Expand Down
7 changes: 0 additions & 7 deletions ckan/tests/legacy/__init__.py
Expand Up @@ -11,28 +11,21 @@
setup-app) with the project's test.ini configuration file.
"""
import os
import sys
import re
from unittest import TestCase
from nose.tools import assert_equal, assert_not_equal, make_decorator
from nose.plugins.skip import SkipTest
import time

from ckan.common import config
from pylons.test import pylonsapp
from paste.script.appinstall import SetupCommand
from six import text_type

import pkg_resources
import paste.fixture
import paste.script.appinstall
from paste.deploy import loadapp

from ckan.lib.create_test_data import CreateTestData
from ckan.lib import search
import ckan.lib.helpers as h
from ckan.logic import get_action
from ckan.logic.action import get_domain_object
import ckan.model as model
from ckan import ckan_nose_plugin
from ckan.common import json
Expand Down
10 changes: 3 additions & 7 deletions ckan/tests/legacy/functional/api/base.py
@@ -1,22 +1,18 @@
# encoding: utf-8

import re
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO

import urllib

from ckan.common import config
import webhelpers.util
from nose.tools import assert_equal
from paste.fixture import TestRequest
from webhelpers.html import url_escape

from ckan.tests.legacy import *
import ckan.model as model
from ckan.lib.create_test_data import CreateTestData
from ckan.tests.legacy import CreateTestData
from ckan.tests.legacy import TestController as ControllerTestCase
from ckan.common import json

Expand Down Expand Up @@ -160,14 +156,14 @@ def data_from_res(self, res):
return self.loads(res.body)

def package_ref_from_name(self, package_name):
package = self.get_package_by_name(unicode(package_name))
package = self.get_package_by_name(package_name)
if package is None:
return package_name
else:
return self.ref_package(package)

def package_id_from_ref(self, package_name):
package = self.get_package_by_name(unicode(package_name))
package = self.get_package_by_name(package_name)
if package is None:
return package_name
else:
Expand Down
3 changes: 0 additions & 3 deletions ckan/tests/legacy/functional/api/model/test_ratings.py
@@ -1,8 +1,5 @@
# encoding: utf-8

from nose.tools import assert_equal
from nose.plugins.skip import SkipTest

from ckan import model
from ckan.lib.create_test_data import CreateTestData

Expand Down
4 changes: 0 additions & 4 deletions ckan/tests/legacy/functional/api/model/test_tag.py
@@ -1,9 +1,5 @@
# encoding: utf-8

import copy

from nose.tools import assert_equal

from ckan import model
from ckan.lib.create_test_data import CreateTestData
import ckan.lib.search as search
Expand Down
1 change: 0 additions & 1 deletion ckan/tests/legacy/functional/api/model/test_vocabulary.py
@@ -1,7 +1,6 @@
# encoding: utf-8

import ckan
import pylons.test
import ckan.lib.helpers as helpers
import ckan.tests.helpers as h
import ckan.lib.dictization.model_dictize as model_dictize
Expand Down
3 changes: 0 additions & 3 deletions ckan/tests/legacy/functional/api/test_activity.py
Expand Up @@ -14,10 +14,8 @@
import logging
logger = logging.getLogger(__name__)

import pylons.test
from ckan.common import config
from paste.deploy.converters import asbool
import paste.fixture
from nose import SkipTest
from ckan.common import json
import ckan.tests.legacy as tests
Expand Down Expand Up @@ -174,7 +172,6 @@ class TestActivity:
def setup_class(self):
if not asbool(config.get('ckan.activity_streams_enabled', 'true')):
raise SkipTest('Activity streams not enabled')
import ckan
import ckan.model as model
tests.CreateTestData.create()
sysadmin_user = model.User.get('testsysadmin')
Expand Down
2 changes: 0 additions & 2 deletions ckan/tests/legacy/functional/api/test_api.py
@@ -1,7 +1,5 @@
# encoding: utf-8

import json

from nose.tools import assert_in

from ckan.tests.legacy.functional.api.base import *
Expand Down
2 changes: 0 additions & 2 deletions ckan/tests/legacy/functional/api/test_dashboard.py
Expand Up @@ -9,8 +9,6 @@
'''
import ckan
from ckan.common import json
import paste
import pylons.test
from ckan.tests.legacy import CreateTestData
import ckan.tests.helpers as helpers

Expand Down
10 changes: 0 additions & 10 deletions ckan/tests/legacy/functional/api/test_email_notifications.py
Expand Up @@ -3,22 +3,12 @@
import time

import ckan.model as model
import ckan.lib.base
import ckan.lib.mailer
import ckan.tests.legacy as tests
import ckan.tests.helpers as helpers
import ckan.tests.legacy.mock_mail_server as mock_mail_server
import ckan.config.middleware
from ckan.tests.legacy import TestController as ControllerTestCase


import paste
import paste.deploy
import pylons.test

from ckan.common import config


class TestEmailNotifications(mock_mail_server.SmtpServerHarness, ControllerTestCase):

@classmethod
Expand Down
2 changes: 0 additions & 2 deletions ckan/tests/legacy/functional/api/test_follow.py
Expand Up @@ -13,8 +13,6 @@
'''
import datetime
import paste
import pylons.test
import ckan
from ckan.tests.legacy import are_foreign_keys_supported, SkipTest, CreateTestData, call_action_api
import ckan.tests.helpers as helpers
Expand Down
2 changes: 2 additions & 0 deletions ckan/tests/legacy/functional/api/test_package_search.py
Expand Up @@ -2,6 +2,8 @@

from urllib import quote

import webhelpers

import ckan.lib.search as search
from ckan.tests.legacy import setup_test_search_index
from ckan.tests.legacy.functional.api.base import *
Expand Down
4 changes: 0 additions & 4 deletions ckan/tests/legacy/functional/api/test_user.py
@@ -1,18 +1,14 @@
# encoding: utf-8

import paste
from ckan.common import config
from nose.tools import assert_equal

import ckan.logic as logic
import ckan.authz as authz
from ckan import model
from ckan.lib.create_test_data import CreateTestData
from ckan.tests.legacy import TestController as ControllerTestCase
from ckan.tests.legacy import url_for
from ckan.tests import helpers

import ckan.config.middleware
from ckan.common import json


Expand Down
3 changes: 1 addition & 2 deletions ckan/tests/legacy/functional/api/test_util.py
Expand Up @@ -2,11 +2,10 @@

from nose.tools import assert_equal

from ckan import model, __version__
from ckan import model
from ckan.lib.create_test_data import CreateTestData
from ckan.tests.legacy import TestController as ControllerTestCase
from ckan.tests.legacy import url_for
from ckan.common import json

class TestUtil(ControllerTestCase):
@classmethod
Expand Down
2 changes: 0 additions & 2 deletions ckan/tests/legacy/functional/test_activity.py
@@ -1,9 +1,7 @@
# encoding: utf-8

from ckan.common import config
from pylons.test import pylonsapp
from paste.deploy.converters import asbool
import paste.fixture
from ckan.lib.helpers import url_for
from nose import SkipTest
import ckan.tests.helpers as helpers
Expand Down
4 changes: 1 addition & 3 deletions ckan/tests/legacy/functional/test_package.py
Expand Up @@ -2,9 +2,7 @@

from __future__ import print_function

import datetime

from ckan.common import config, c
from ckan.common import config
from difflib import unified_diff
from nose.tools import assert_equal

Expand Down
4 changes: 1 addition & 3 deletions ckan/tests/legacy/functional/test_user.py
@@ -1,18 +1,16 @@
# encoding: utf-8

from ckan.lib.helpers import url_for
from nose.tools import assert_equal
from ckan.common import config
import hashlib

from ckan.tests.legacy import CreateTestData
from ckan.tests.legacy.html_check import HtmlCheckMethods
from ckan.tests.legacy.mock_mail_server import SmtpServerHarness
from ckan.tests.legacy import TestController as ControllerTestCase

import ckan.model as model
from base import FunctionalTestCase
from ckan.lib.mailer import get_reset_link, create_reset_key
from ckan.lib.mailer import create_reset_key

class TestUserController(FunctionalTestCase, HtmlCheckMethods, SmtpServerHarness):
@classmethod
Expand Down
10 changes: 2 additions & 8 deletions ckan/tests/legacy/lib/test_cli.py
@@ -1,16 +1,10 @@
# encoding: utf-8

import os
import csv

from nose.tools import assert_equal

from ckan import model
from ckan.lib.cli import ManageDb,SearchIndexCommand
from ckan.lib.cli import SearchIndexCommand
from ckan.lib.create_test_data import CreateTestData
from ckan.common import json

from ckan.lib.search import index_for,query_for, clear_all
from ckan.lib.search import index_for,query_for


class FakeOptions():
Expand Down
2 changes: 0 additions & 2 deletions ckan/tests/legacy/lib/test_dictization.py
Expand Up @@ -14,14 +14,12 @@

from ckan.lib.dictization.model_dictize import (package_dictize,
resource_dictize,
activity_dictize,
package_to_api1,
package_to_api2,
user_dictize,
)
from ckan.lib.dictization.model_save import (package_dict_save,
resource_dict_save,
group_dict_save,
activity_dict_save,
package_api_to_dict,
group_api_to_dict,
Expand Down
4 changes: 2 additions & 2 deletions ckan/tests/legacy/lib/test_hash.py
Expand Up @@ -2,7 +2,7 @@

from nose.tools import assert_equals

from ckan.lib.hash import get_message_hash, get_redirect
from ckan.lib.hash import get_message_hash

class TestHash:
@classmethod
Expand All @@ -15,4 +15,4 @@ def test_get_message_hash(self):

def test_get_message_hash_unicode(self):
assert_equals(len(get_message_hash(u'/tag/biocombust\xedveis')), len('d748fa890eb6a964cd317e6ff62905fad645b43d'))

3 changes: 1 addition & 2 deletions ckan/tests/legacy/lib/test_tag_search.py
@@ -1,6 +1,5 @@
# encoding: utf-8

from nose.tools import assert_raises
from ckan.tests.legacy import *
from ckan.tests.legacy import is_search_supported
import ckan.lib.search as search
Expand Down Expand Up @@ -61,7 +60,7 @@ def test_search_with_unicode_in_search_query(self):
def test_search_is_case_insensitive(self):
result = search.query_for(model.Tag).run(query=u'flexible')
assert u'Flexible \u30a1' in result['results']


def test_good_search_fields(self):
result = search.query_for(model.Tag).run(fields={'tags': u'ru'})
Expand Down

0 comments on commit 469713b

Please sign in to comment.