Skip to content

Commit

Permalink
[#5031] [#5031] More tests fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Jan 10, 2020
1 parent eca8887 commit f22f01d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
3 changes: 1 addition & 2 deletions ckan/tests/controllers/test_package.py
Expand Up @@ -140,8 +140,7 @@ def test_complete_package_with_two_resources(self, app):

# resource upload is tested in TestExampleIUploaderPlugin

def test_previous_button_works(self):
app = self._get_test_app()
def test_previous_button_works(self, app):
env, response = _get_package_new_page(app)
form = response.forms["dataset-edit"]
form["name"] = u"previous-button-works"
Expand Down
12 changes: 8 additions & 4 deletions ckan/tests/logic/action/test_create.py
Expand Up @@ -8,6 +8,8 @@
import mock
import pytest

from werkzeug.datastructures import FileStorage as FlaskFileStorage

import ckan
import ckan.logic as logic
import ckan.model as model
Expand All @@ -26,9 +28,11 @@
fake_open = fake_filesystem.FakeFileOpen(fs)


class FakeFileStorage(cgi.FieldStorage):
def __init__(self, fp, filename):
self.file = fp
class FakeFileStorage(FlaskFileStorage):
content_type = None

def __init__(self, stream, filename):
self.stream = stream
self.filename = filename
self.name = "upload"

Expand Down Expand Up @@ -535,7 +539,7 @@ def test_mimetype_by_upload_by_file(self, mock_open):
NAZKO,1C08,1070,2016/01/05,20,31,,76,16,JAN-01,41
"""
)
test_resource = FakeFileStorage(test_file, "")
test_resource = FakeFileStorage(test_file, "test.csv")

context = {}
params = {
Expand Down
19 changes: 10 additions & 9 deletions ckan/tests/logic/action/test_update.py
Expand Up @@ -26,6 +26,15 @@
fake_open = fake_filesystem.FakeFileOpen(fs)


class FakeFileStorage(FlaskFileStorage):
content_type = None

def __init__(self, stream, filename):
self.stream = stream
self.filename = filename
self.name = "upload"


def mock_open_if_open_fails(*args, **kwargs):
try:
return real_open(*args, **kwargs)
Expand Down Expand Up @@ -813,14 +822,6 @@ def test_calling_with_only_id_doesnt_update_anything(self):
@pytest.mark.usefixtures("clean_db", "with_plugins")
class TestResourceUpdate(object):

class FakeFileStorage(FlaskFileStorage):
content_type = None

def __init__(self, stream, filename):
self.stream = stream
self.filename = filename
self.name = "upload"

def test_url_only(self):
dataset = factories.Dataset()
resource = factories.Resource(package=dataset, url="http://first")
Expand Down Expand Up @@ -1072,7 +1073,7 @@ def test_mimetype_by_upload_by_file(self, mock_open):
NAZKO,1C08,1070,2016/01/05,20,31,,76,16,JAN-01,41
"""
)
update_resource = TestResourceUpdate.FakeFileStorage(
update_resource = FakeFileStorage(
update_file, "update_test"
)

Expand Down

0 comments on commit f22f01d

Please sign in to comment.