From: Radek Czajka Date: Wed, 27 Feb 2019 15:05:38 +0000 (+0100) Subject: Fix tests. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/e81283e08cca4c47d57dd0aef34a5c598931a9d2 Fix tests. --- diff --git a/.gitignore b/.gitignore index e5d43c77..26e48d32 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ var coverage.xml nosetests.xml pip-log.txt +/htmlcov # Mac OS X garbage .DS_Store @@ -37,4 +38,4 @@ nbproject/* node_modules /static_test -chromedriver.log \ No newline at end of file +chromedriver.log diff --git a/apps/apiclient/tests.py b/apps/apiclient/tests.py deleted file mode 100644 index 2247054b..00000000 --- a/apps/apiclient/tests.py +++ /dev/null @@ -1,23 +0,0 @@ -""" -This file demonstrates two different styles of tests (one doctest and one -unittest). These will both pass when you run "manage.py test". - -Replace these with more appropriate tests for your application. -""" - -from django.test import TestCase - -class SimpleTest(TestCase): - def test_basic_addition(self): - """ - Tests that 1 + 1 always equals 2. - """ - self.failUnlessEqual(1 + 1, 2) - -__test__ = {"doctest": """ -Another way to test that 1 + 1 is equal to 2. - ->>> 1 + 1 == 2 -True -"""} - diff --git a/apps/catalogue/tests/publish.py b/apps/catalogue/tests/publish.py index 9f0b8ca4..93e02daa 100644 --- a/apps/catalogue/tests/publish.py +++ b/apps/catalogue/tests/publish.py @@ -28,7 +28,7 @@ class PublishTests(TestCase): def test_publish(self, api_call): self.book[0].head.set_publishable(True) self.book.publish(self.user) - api_call.assert_called_with(self.user, 'books/', {"book_xml": self.text1}) + api_call.assert_called_with(self.user, 'books/', {"book_xml": self.text1, "days": 0}, beta=False) @patch('apiclient.api_call') def test_publish_multiple(self, api_call): @@ -37,4 +37,4 @@ class PublishTests(TestCase): self.book[1].commit(get_fixture('chunk2.xml')) self.book[1].head.set_publishable(True) self.book.publish(self.user) - api_call.assert_called_with(self.user, 'books/', {"book_xml": get_fixture('expected.xml')}) + api_call.assert_called_with(self.user, 'books/', {"book_xml": get_fixture('expected.xml'), "days": 0}, beta=False) diff --git a/apps/cover/tests.py b/apps/cover/tests.py index 5b4b8858..be8d0033 100644 --- a/apps/cover/tests.py +++ b/apps/cover/tests.py @@ -13,8 +13,8 @@ class FlickrTests(TestCase): form = FlickrForm({"source_url": "https://www.flickr.com/photos/rczajka/6941928577/in/photostream"}) self.assertTrue(form.is_valid()) self.assertEqual(form.cleaned_data['source_url'], "https://www.flickr.com/photos/rczajka/6941928577/") - self.assertEqual(form.cleaned_data['author'], "rczajka@Flickr") + self.assertEqual(form.cleaned_data['author'], "Radek Czajka@Flickr") self.assertEqual(form.cleaned_data['title'], u"Pirate Stańczyk") self.assertEqual(form.cleaned_data['license_name'], "CC BY 2.0") - self.assertEqual(form.cleaned_data['license_url'], "https://creativecommons.org/licenses/by/2.0/deed.en") - self.assertEqual(form.cleaned_data['download_url'], "https://farm8.staticflickr.com/7069/6941928577_415844c58e_o.jpg") + self.assertEqual(form.cleaned_data['license_url'], "https://creativecommons.org/licenses/by/2.0/") + self.assertTrue('.staticflickr.com' in form.cleaned_data['download_url']) diff --git a/apps/wiki/tests/xslt/auto/auto_test.js b/apps/wiki/tests/xslt/auto/auto_test.js index 6a02716e..ab485f51 100644 --- a/apps/wiki/tests/xslt/auto/auto_test.js +++ b/apps/wiki/tests/xslt/auto/auto_test.js @@ -1,4 +1,5 @@ -var $ = require('jquery'); +var jsdom = require("jsdom"); +var $ = require('jquery')(new jsdom.JSDOM().window); var fs = require('fs'); var exec = require('child_process').exec; var pd = require('pretty-data').pd; diff --git a/deployment.py b/deployment.py deleted file mode 100644 index b989fc7a..00000000 --- a/deployment.py +++ /dev/null @@ -1,155 +0,0 @@ -from __future__ import with_statement - -import shutil -import os -import sys -import logging - -logging.basicConfig(stream=sys.stderr, format="%(levelname)s:: %(message)s", level=logging.INFO) - -from string import Template - -class DeploySite(object): - - def __init__(self, **env): - self.env = env - - for arg in ('ROOT', 'PROJECT_NAME', 'PYTHON_VERSION'): - if arg not in self.env: - raise ValueError("Argument '%s' is required." % arg) - - if 'PYTHON_BASE' not in self.env: - self.env['PYTHON_BASE'] = os.path.join(self.env['ROOT'], 'pythonenv') - - if 'PYTHON_BIN' not in self.env: - self.env['PYTHON_BIN'] = os.path.join( - self.env['PYTHON_BASE'], 'bin', 'python') + self.env['PYTHON_VERSION'] - - if 'PIP_BIN' not in self.env: - self.env['PIP_BIN'] = os.path.join(self.env['PYTHON_BASE'], 'bin', 'pip') - - if 'PYTHON_SITE' not in self.env: - self.env['PYTHON_SITE'] = os.path.join( - self.env['PYTHON_BASE'], 'lib', - 'python' + self.env['PYTHON_VERSION'], 'site-packages') - - if 'APP_DIR' not in self.env: - self.env['APP_DIR'] = os.path.join(self.env['ROOT'], 'application') - - if 'CONFIG_DIR' not in self.env: - self.env['CONFIG_DIR'] = os.path.join(self.env['ROOT'], 'etc') - - if 'MEDIA_DIR' not in self.env: - self.env['MEDIA_DIR'] = os.path.join(self.env['ROOT'], 'www', 'media') - - self._logger = logging.getLogger("deployment") - - def info(self, *args, **kwargs): - self._logger.info(*args, **kwargs) - - def render_template(self, source, dest, extra_context={}): - self.info("Rendering template: %s", source) - - with open(source, 'rb') as source_file: - t = Template(source_file.read()) - - context = dict(self.env) - context.update(extra_context) - - with open(dest, 'wb') as dest_file: - dest_file.write(t.safe_substitute(context)) - - self.info("Done.") - - def restart_app(self): - pass - - def update_app(self): - pass - - def update_config(self): - pass - - def install_dependencies(self): - pass - - def deploy(self): - self.update_app() - self.install_dependencies() - self.update_config() - self.restart_app() - - def find_resource(self, path): - for dir in (self.env['CONFIG_DIR'], self.env['APP_DIR']): - full_path = os.path.join(dir, path) - if os.path.isfile(full_path): - return full_path - - raise ValueError("Resource '%s' not found" % path) - - @classmethod - def run_deploy(cls, *args, **kwargs): - site = cls(*args, **kwargs) - return site.deploy() - -class WSGISite(DeploySite): - - def __init__(self, **env): - super(WSGISite, self).__init__(**env) - - if 'WSGI_FILE' not in self.env: - self.env['WSGI_FILE'] = os.path.join(self.env['ROOT'], 'www', - 'wsgi', self.env['PROJECT_NAME']) + '.wsgi' - - self.env['WSGI_DIR'] = os.path.dirname(self.env['WSGI_FILE']) - - if 'WSGI_SOURCE_FILE' not in self.env: - self.env['WSGI_SOURCE_FILE'] = 'wsgi_app.template' - - if 'WSGI_USER' not in self.env: - self.env['WSGI_USER'] = 'www-data' - - def restart_app(self): - self.info("Restarting wsgi application: %s", self.env['WSGI_FILE']) - os.system("touch %s" % self.env['WSGI_FILE']) - - def update_config(self): - super(WSGISite, self).update_config() - - source = self.find_resource(self.env['WSGI_SOURCE_FILE']) - self.render_template(source, self.env['WSGI_FILE']) - -class PIPSite(DeploySite): - - def install_dependencies(self): - self.info("Installing requirements") - os.system("%s install -r %s" % (self.env['PIP_BIN'], self.find_resource('requirements.txt'))) - - try: - self.info("Installing local requirements") - os.system("%s install -r %s" % (self.env['PIP_BIN'], self.find_resource('requirements_local.txt'))) - except ValueError: - pass - -class GitSite(DeploySite): - - def update_app(self): - self.info("Updating repository.") - os.system("cd %s; git pull" % self.env['APP_DIR']) - -class ApacheSite(DeploySite): - - def __init__(self, **env): - super(ApacheSite, self).__init__(**env) - - if 'VHOST_SOURCE_FILE' not in self.env: - self.env['VHOST_SOURCE_FILE'] = 'apache_vhost.template' - - if 'VHOST_FILE' not in self.env: - self.env['VHOST_FILE'] = os.path.join(self.env['CONFIG_DIR'], self.env['PROJECT_NAME'] + '.vhost') - - def update_config(self): - super(ApacheSite, self).update_config() - - source = self.find_resource(self.env['VHOST_SOURCE_FILE']) - self.render_template(source, self.env['VHOST_FILE']) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json deleted file mode 100644 index 22424714..00000000 --- a/npm-shrinkwrap.json +++ /dev/null @@ -1,369 +0,0 @@ -{ - "dependencies": { - "mocha": { - "version": "1.8.2", - "from": "mocha@", - "dependencies": { - "commander": { - "version": "0.6.1", - "from": "commander@0.6.1" - }, - "growl": { - "version": "1.7.0", - "from": "growl@1.7.x" - }, - "jade": { - "version": "0.26.3", - "from": "jade@0.26.3", - "dependencies": { - "mkdirp": { - "version": "0.3.0", - "from": "mkdirp@0.3.0" - } - } - }, - "diff": { - "version": "1.0.2", - "from": "diff@1.0.2" - }, - "debug": { - "version": "0.7.2", - "from": "debug@*" - }, - "mkdirp": { - "version": "0.3.3", - "from": "mkdirp@0.3.3" - }, - "ms": { - "version": "0.3.0", - "from": "ms@0.3.0" - } - } - }, - "jsdom": { - "version": "0.5.4", - "from": "jsdom@", - "dependencies": { - "htmlparser": { - "version": "1.7.6", - "from": "htmlparser@1.x", - "resolved": "https://registry.npmjs.org/htmlparser/-/htmlparser-1.7.6.tgz" - }, - "nwmatcher": { - "version": "1.3.1", - "from": "nwmatcher@>=1.3.1", - "resolved": "https://registry.npmjs.org/nwmatcher/-/nwmatcher-1.3.1.tgz" - }, - "request": { - "version": "2.16.6", - "from": "request@2.x", - "resolved": "https://registry.npmjs.org/request/-/request-2.16.6.tgz", - "dependencies": { - "form-data": { - "version": "0.0.7", - "from": "form-data@~0.0.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-0.0.7.tgz", - "dependencies": { - "combined-stream": { - "version": "0.0.4", - "from": "combined-stream@~0.0.4", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.4.tgz", - "dependencies": { - "delayed-stream": { - "version": "0.0.5", - "from": "delayed-stream@0.0.5", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz" - } - } - }, - "async": { - "version": "0.1.22", - "from": "async@~0.1.9" - } - } - }, - "mime": { - "version": "1.2.9", - "from": "mime@~1.2.7" - }, - "hawk": { - "version": "0.10.2", - "from": "hawk@~0.10.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-0.10.2.tgz", - "dependencies": { - "hoek": { - "version": "0.7.1", - "from": "hoek@0.7.x", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-0.7.1.tgz" - }, - "boom": { - "version": "0.3.7", - "from": "boom@0.3.x", - "resolved": "https://registry.npmjs.org/boom/-/boom-0.3.7.tgz" - }, - "cryptiles": { - "version": "0.1.3", - "from": "cryptiles@0.1.x", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-0.1.3.tgz" - }, - "sntp": { - "version": "0.1.4", - "from": "sntp@0.1.x", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-0.1.4.tgz" - } - } - }, - "node-uuid": { - "version": "1.4.0", - "from": "node-uuid@~1.4.0" - }, - "cookie-jar": { - "version": "0.2.0", - "from": "cookie-jar@~0.2.0", - "resolved": "https://registry.npmjs.org/cookie-jar/-/cookie-jar-0.2.0.tgz" - }, - "aws-sign": { - "version": "0.2.0", - "from": "aws-sign@~0.2.0", - "resolved": "https://registry.npmjs.org/aws-sign/-/aws-sign-0.2.0.tgz" - }, - "oauth-sign": { - "version": "0.2.0", - "from": "oauth-sign@~0.2.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.2.0.tgz" - }, - "forever-agent": { - "version": "0.2.0", - "from": "forever-agent@~0.2.0", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.2.0.tgz" - }, - "tunnel-agent": { - "version": "0.2.0", - "from": "tunnel-agent@~0.2.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.2.0.tgz" - }, - "json-stringify-safe": { - "version": "3.0.0", - "from": "json-stringify-safe@~3.0.0", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-3.0.0.tgz" - }, - "qs": { - "version": "0.5.5", - "from": "qs@~0.5.4", - "resolved": "https://registry.npmjs.org/qs/-/qs-0.5.5.tgz" - } - } - }, - "cssom": { - "version": "0.2.5", - "from": "cssom@0.2.x" - }, - "cssstyle": { - "version": "0.2.3", - "from": "cssstyle@>=0.2.3" - }, - "contextify": { - "version": "0.1.5", - "from": "contextify@~0.1.3", - "resolved": "https://registry.npmjs.org/contextify/-/contextify-0.1.5.tgz", - "dependencies": { - "bindings": { - "version": "1.1.0", - "from": "bindings@*", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.1.0.tgz" - } - } - } - } - }, - "jquery": { - "version": "1.8.3", - "from": "jquery@", - "dependencies": { - "jsdom": { - "version": "0.5.4", - "from": "jsdom@", - "dependencies": { - "htmlparser": { - "version": "1.7.6", - "from": "htmlparser@1.x", - "resolved": "https://registry.npmjs.org/htmlparser/-/htmlparser-1.7.6.tgz" - }, - "nwmatcher": { - "version": "1.3.1", - "from": "nwmatcher@>=1.3.1", - "resolved": "https://registry.npmjs.org/nwmatcher/-/nwmatcher-1.3.1.tgz" - }, - "request": { - "version": "2.16.6", - "from": "request@2.x", - "resolved": "https://registry.npmjs.org/request/-/request-2.16.6.tgz", - "dependencies": { - "form-data": { - "version": "0.0.7", - "from": "form-data@~0.0.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-0.0.7.tgz", - "dependencies": { - "combined-stream": { - "version": "0.0.4", - "from": "combined-stream@~0.0.4", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.4.tgz", - "dependencies": { - "delayed-stream": { - "version": "0.0.5", - "from": "delayed-stream@0.0.5", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz" - } - } - }, - "async": { - "version": "0.1.22", - "from": "async@~0.1.9" - } - } - }, - "mime": { - "version": "1.2.9", - "from": "mime@~1.2.7" - }, - "hawk": { - "version": "0.10.2", - "from": "hawk@~0.10.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-0.10.2.tgz", - "dependencies": { - "hoek": { - "version": "0.7.1", - "from": "hoek@0.7.x", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-0.7.1.tgz" - }, - "boom": { - "version": "0.3.7", - "from": "boom@0.3.x", - "resolved": "https://registry.npmjs.org/boom/-/boom-0.3.7.tgz" - }, - "cryptiles": { - "version": "0.1.3", - "from": "cryptiles@0.1.x", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-0.1.3.tgz" - }, - "sntp": { - "version": "0.1.4", - "from": "sntp@0.1.x", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-0.1.4.tgz" - } - } - }, - "node-uuid": { - "version": "1.4.0", - "from": "node-uuid@~1.4.0" - }, - "cookie-jar": { - "version": "0.2.0", - "from": "cookie-jar@~0.2.0", - "resolved": "https://registry.npmjs.org/cookie-jar/-/cookie-jar-0.2.0.tgz" - }, - "aws-sign": { - "version": "0.2.0", - "from": "aws-sign@~0.2.0", - "resolved": "https://registry.npmjs.org/aws-sign/-/aws-sign-0.2.0.tgz" - }, - "oauth-sign": { - "version": "0.2.0", - "from": "oauth-sign@~0.2.0", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.2.0.tgz" - }, - "forever-agent": { - "version": "0.2.0", - "from": "forever-agent@~0.2.0", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.2.0.tgz" - }, - "tunnel-agent": { - "version": "0.2.0", - "from": "tunnel-agent@~0.2.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.2.0.tgz" - }, - "json-stringify-safe": { - "version": "3.0.0", - "from": "json-stringify-safe@~3.0.0", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-3.0.0.tgz" - }, - "qs": { - "version": "0.5.5", - "from": "qs@~0.5.4", - "resolved": "https://registry.npmjs.org/qs/-/qs-0.5.5.tgz" - } - } - }, - "cssom": { - "version": "0.2.5", - "from": "cssom@0.2.x" - }, - "cssstyle": { - "version": "0.2.3", - "from": "cssstyle@>=0.2.3" - }, - "contextify": { - "version": "0.1.5", - "from": "contextify@~0.1.3", - "resolved": "https://registry.npmjs.org/contextify/-/contextify-0.1.5.tgz", - "dependencies": { - "bindings": { - "version": "1.1.0", - "from": "bindings@*", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.1.0.tgz" - } - } - } - } - }, - "htmlparser": { - "version": "1.7.6", - "from": "htmlparser@1.x", - "resolved": "https://registry.npmjs.org/htmlparser/-/htmlparser-1.7.6.tgz" - }, - "xmlhttprequest": { - "version": "1.4.2", - "from": "xmlhttprequest@~1.4.2" - }, - "location": { - "version": "0.0.1", - "from": "location@0.0.1", - "resolved": "https://registry.npmjs.org/location/-/location-0.0.1.tgz" - }, - "navigator": { - "version": "1.0.1", - "from": "navigator@~1.0.1", - "resolved": "https://registry.npmjs.org/navigator/-/navigator-1.0.1.tgz" - }, - "contextify": { - "version": "0.1.5", - "from": "contextify@~0.1.3", - "resolved": "https://registry.npmjs.org/contextify/-/contextify-0.1.5.tgz", - "dependencies": { - "bindings": { - "version": "1.1.0", - "from": "bindings@*", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.1.0.tgz" - } - } - } - } - }, - "pretty-data": { - "version": "0.40.0", - "from": "pretty-data@" - }, - "ansidiff": { - "version": "1.0.0", - "from": "ansidiff@", - "resolved": "https://registry.npmjs.org/ansidiff/-/ansidiff-1.0.0.tgz", - "dependencies": { - "diff": { - "version": "1.0.4", - "from": "diff@1.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-1.0.4.tgz" - } - } - } - } -} diff --git a/package.json b/package.json index 2a4dbd31..d7281ba2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,9 @@ { -"engines": { - "node": "0.8.x", - "npm": ">=1.1.2" + "dependencies": { + "ansidiff": "^1.0.0", + "jquery": "^3.3.1", + "jsdom": "^13.2.0", + "mocha": "^6.0.2", + "pretty-data": "^0.40.0" + } } -} \ No newline at end of file diff --git a/redakcja/settings/test.py b/redakcja/settings/test.py index 80b9a3d7..cd131787 100644 --- a/redakcja/settings/test.py +++ b/redakcja/settings/test.py @@ -39,3 +39,6 @@ NOSE_ARGS = ( ) SECRET_KEY = "not-so-secret" + + +LITERARY_DIRECTOR_USERNAME = 'Kaowiec'