Skip to content

Commit

Permalink
[QOLDEV-1003] replace Nosetests syntax with pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
ThrawnCA committed Nov 11, 2024
1 parent 066d225 commit 6d90304
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 78 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ apt-get install sudo systemd postgresql-10 git python python-pip
export PGVERSION=10 && export CKAN_BRANCH=qgov-master && export CKAN_GIT_REPO=qld-gov-au/ckan
cd /build
bash bin/travis-build.bash
nosetests --ckan --with-pylons=subdir/test.ini --with-coverage --cover-package=ckanext.s3filestore --cover-inclusive --cover-erase --cover-tests
pytest --ckan-ini=test.ini --cov=ckanext.s3filestore

---------------------------------------
Registering ckanext-s3filestore on PyPI
Expand Down
6 changes: 0 additions & 6 deletions ckanext/s3filestore/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# encoding: utf-8

from ckan.tests import helpers


def _get_status_code(response):
""" Get the status code from a HTTP response.
Expand All @@ -20,7 +18,3 @@ def _get_response_body(response):
return response.text
else:
return response.body


def teardown_function(self=None):
helpers.reset_db()
21 changes: 10 additions & 11 deletions ckanext/s3filestore/tests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests
import six

from nose.tools import (with_setup)
import pytest

from werkzeug.datastructures import FileStorage as FlaskFileStorage

Expand All @@ -18,19 +18,11 @@

from ckanext.s3filestore import uploader

from . import _get_status_code, _get_response_body, teardown_function
from . import _get_status_code, _get_response_body

log = logging.getLogger(__name__)


def setup_function(self):
self.sysadmin = factories.Sysadmin(apikey="my-test-key")

assert config.get('ckanext.s3filestore.signature_version') == 's3v4'
self.bucket_name = config.get(u'ckanext.s3filestore.aws_bucket_name')
uploader.BaseS3Uploader().get_s3_bucket(self.bucket_name)


def _test_org():
try:
return helpers.call_action('organization_show', id='test-org')
Expand All @@ -47,9 +39,16 @@ def _test_org():
image_upload=FlaskFileStorage(six.BytesIO(b"\0\0\0"), u"image.png"))


@with_setup(setup_function, teardown_function)
@pytest.mark.usefixtures("clean_db", "with_plugins")
class TestS3Controller(object):

def setup_method(self, test_method):
self.sysadmin = factories.Sysadmin(apikey="my-test-key")

assert config.get('ckanext.s3filestore.signature_version') == 's3v4'
self.bucket_name = config.get(u'ckanext.s3filestore.aws_bucket_name')
uploader.BaseS3Uploader().get_s3_bucket(self.bucket_name)

def _upload_resource(self):
dataset = factories.Dataset(name="my-dataset")

Expand Down
7 changes: 5 additions & 2 deletions ckanext/s3filestore/tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# encoding: utf-8

import mock
try:
from unittest import mock
except ImportError:
import mock
from parameterized import parameterized

import ckantoolkit as toolkit
Expand All @@ -11,7 +14,7 @@

class TestS3Plugin():

def setup(self):
def setup_method(self, test_method):
self.plugin = S3FileStorePlugin()

def test_update_config(self):
Expand Down
Loading

0 comments on commit 6d90304

Please sign in to comment.