Skip to content

Commit

Permalink
Remove six from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelboca committed Feb 28, 2023
1 parent 6090ad8 commit ee661f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 31 deletions.
16 changes: 4 additions & 12 deletions ckanext/harvest/tests/harvesters/mock_ckan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
import json
import re
import copy
import six
from six.moves.urllib.parse import unquote_plus
from urllib.parse import unquote_plus

from threading import Thread

if six.PY2:
from SimpleHTTPServer import SimpleHTTPRequestHandler
from SocketServer import TCPServer
else:
from http.server import SimpleHTTPRequestHandler
from socketserver import TCPServer
from http.server import SimpleHTTPRequestHandler
from socketserver import TCPServer


PORT = 8998
Expand Down Expand Up @@ -171,10 +166,7 @@ def get_org(self, org_ref):

def get_url_params(self):
params_str = self.path.split('?')[-1]
if six.PY2:
params_unicode = unquote_plus(params_str).decode('utf8')
else:
params_unicode = unquote_plus(params_str)
params_unicode = unquote_plus(params_str)
params = params_unicode.split('&')
return dict([param.split('=') for param in params])

Expand Down
30 changes: 11 additions & 19 deletions ckanext/harvest/tests/test_blueprint.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import six
import pytest

from ckantoolkit import url_for
from ckantoolkit.tests import factories
from ckanext.harvest.tests import factories as harvest_factories


def _assert_in_body(string, response):
if six.PY2:
assert string in response.body.decode('utf8')
else:
assert string in response.body


@pytest.mark.usefixtures('clean_db', 'clean_index', 'harvest_setup')
class TestBlueprint():

Expand All @@ -23,8 +15,8 @@ def test_index_page_is_rendered(self, app):

response = app.get(u'/harvest')

_assert_in_body(source1['title'], response)
_assert_in_body(source2['title'], response)
assert source1['title'] in response.body
assert source2['title'] in response.body

def test_new_form_is_rendered(self, app):

Expand All @@ -34,7 +26,7 @@ def test_new_form_is_rendered(self, app):

response = app.get(url, extra_environ=env)

_assert_in_body('<form id="source-new"', response)
assert '<form id="source-new"' in response.body

def test_edit_form_is_rendered(self, app):

Expand All @@ -46,7 +38,7 @@ def test_edit_form_is_rendered(self, app):

response = app.get(url, extra_environ=env)

_assert_in_body('<form id="source-new"', response)
assert '<form id="source-new"' in response.body

def test_source_page_rendered(self, app):

Expand All @@ -58,7 +50,7 @@ def test_source_page_rendered(self, app):

response = app.get(url, extra_environ=env)

_assert_in_body(source['name'], response)
assert source['name'] in response.body

def test_admin_page_rendered(self, app):

Expand All @@ -72,9 +64,9 @@ def test_admin_page_rendered(self, app):

response = app.get(url, extra_environ=env)

_assert_in_body(source_obj.title, response)
assert source_obj.title in response.body

_assert_in_body(job['id'], response)
assert job['id'] in response.body

def test_about_page_rendered(self, app):

Expand All @@ -86,7 +78,7 @@ def test_about_page_rendered(self, app):

response = app.get(url, extra_environ=env)

_assert_in_body(source['name'], response)
assert source['name'] in response.body

def test_job_page_rendered(self, app):

Expand All @@ -99,7 +91,7 @@ def test_job_page_rendered(self, app):

response = app.get(url, extra_environ=env)

_assert_in_body(job['id'], response)
assert job['id'] in response.body

def test_job_show_last_page_rendered(self, app):

Expand All @@ -112,7 +104,7 @@ def test_job_show_last_page_rendered(self, app):

response = app.get(url, extra_environ=env)

_assert_in_body(job['id'], response)
assert job['id'] in response.body

def test_job_show_page_rendered(self, app):

Expand All @@ -125,4 +117,4 @@ def test_job_show_page_rendered(self, app):

response = app.get(url, extra_environ=env)

_assert_in_body(job['id'], response)
assert job['id'] in response.body

0 comments on commit ee661f1

Please sign in to comment.