Compare commits

...

3 Commits

Author SHA1 Message Date
Roberto Rosario
9340afd196 Initial commit to support QUnit tests
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
2019-09-26 00:28:44 -04:00
Roberto Rosario
f97ccb693b Add test GitLab issue #653
Tests opening zip files containing a non English named member.

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
2019-09-25 23:00:51 -04:00
Roberto Rosario
c3b539ba19 Add MAYAN_GUNICORN_TIMEOUT documentatoin
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
2019-09-25 22:17:50 -04:00
11 changed files with 90 additions and 2 deletions

View File

@@ -233,6 +233,12 @@ and will exhaust the available Postgres connections available if a number
other than 0 is used. Reference: https://serverfault.com/questions/635100/django-conn-max-age-persists-connections-but-doesnt-reuse-them-with-postgresq
and https://github.com/benoitc/gunicorn/issues/996
``MAYAN_GUNICORN_TIMEOUT``
Optional. Changes the amount of time the frontend worker will wait for a
request to finish before raising a timeout error. The default is 120
seconds.
``MAYAN_GUNICORN_WORKERS``
Optional. This environment variable controls the number of frontend workers

View File

@@ -0,0 +1,31 @@
'use strict';
QUnit.test('partialNavigation.filterLocation', function (assert) {
var testPartialNavigation = new PartialNavigation({
initialURL: '/testInitialURL',
});
/*
* For an empty newLocation we expect the fragment of the URL minus the
* query
*/
var expected = new URI(new URI(location).fragment()).path().toString();
assert.strictEqual(
testPartialNavigation.filterLocation(''), expected, 'newLocation === ""');
/*
* For an empty root value we expect initialURL passed to the
* partialNavigation instance when initialized.
*/
assert.strictEqual(
testPartialNavigation.filterLocation('/'), testPartialNavigation.initialURL, 'newLocation === "/"'
);
/*
* For an empty root value we expect initialURL passed to the
* partialNavigation instance when initialized.
*/
assert.strictEqual(
testPartialNavigation.filterLocation('random'), 'random', 'newLocation === "random"'
);
});

View File

@@ -38,6 +38,7 @@
<script src="{% static 'appearance/node_modules/jquery/dist/jquery.min.js' %}" type="text/javascript"></script>
<script src="{% static 'appearance/node_modules/bootstrap/dist/js/bootstrap.min.js' %}" type="text/javascript"></script>
<script src="{% static 'appearance/node_modules/@fortawesome/fontawesome-free/js/all.min.js' %}" data-auto-replace-svg="nest" type="text/javascript"></script>
{% block javascript %}{% endblock %}
</body>
</html>
{% endspaceless %}

View File

@@ -4,7 +4,12 @@ from django.utils.translation import ugettext_lazy as _
from mayan.apps.dependencies.classes import (
environment_build, environment_development, environment_testing,
PythonDependency
JavaScriptDependency, PythonDependency
)
JavaScriptDependency(
environment=environment_testing, label=_('QUnit'), module=__name__,
name='qunit', version_string='=2.9.2'
)
PythonDependency(

View File

@@ -0,0 +1,22 @@
{% extends 'appearance/base.html' %}
{% load i18n %}
{% load static %}
{% block base_title %}{% trans 'Qunit' %}{% endblock %}
{% block project_name %}{% endblock %}
{% block stylesheets %}
<link href="{% static 'common/node_modules/qunit/qunit/qunit.css' %}" media="screen" rel="stylesheet" type="text/css" />
{% endblock %}
{% block content %}
<div id="qunit"></div>
<div id="qunit-fixture"></div>
{% endblock %}
{% block javascript %}
<script src="{% static 'common/node_modules/qunit/qunit/qunit.js' %}" type="text/javascript"></script>
<script src="{% static 'appearance/js/test/unit/partial_navigation.js' %}" type="text/javascript"></script>
{% endblock %}

View File

@@ -0,0 +1 @@
TEST FILE SPECIAL CHARACTERS FILENAME

View File

@@ -11,6 +11,7 @@ TEST_VIEW_NAME = 'test view name'
TEST_VIEW_URL = 'test-view-url'
# Filenames
TEST_ARCHIVE_ZIP_SPECIAL_CHARACTERS_FILENAME_MEMBER = 'test_archvive_with_special_characters_filename_member.zip'
TEST_FILENAME1 = 'test_file1.txt'
TEST_FILENAME2 = 'test_file2.txt'
TEST_FILENAME3 = 'test_file3.txt'
@@ -23,6 +24,10 @@ TEST_ZIP_FILE = 'test_file.zip'
TEST_COMPRESSED_FILE_CONTENTS = [TEST_FILENAME1, TEST_FILENAME2]
# File paths
TEST_ARCHIVE_ZIP_SPECIAL_CHARACTERS_FILENAME_MEMBER_PATH = os.path.join(
settings.BASE_DIR, 'apps', 'common', 'tests', 'contrib',
TEST_ARCHIVE_ZIP_SPECIAL_CHARACTERS_FILENAME_MEMBER
)
TEST_FILE3_PATH = os.path.join(
settings.BASE_DIR, 'apps', 'common', 'tests', 'contrib', TEST_FILENAME3
)

View File

@@ -5,6 +5,7 @@ from mayan.apps.common.tests import BaseTestCase
from ..compressed_files import Archive, TarArchive, ZipArchive
from .literals import (
TEST_ARCHIVE_ZIP_SPECIAL_CHARACTERS_FILENAME_MEMBER_PATH,
TEST_COMPRESSED_FILE_CONTENTS, TEST_FILE_CONTENTS_1, TEST_FILE3_PATH,
TEST_FILENAME1, TEST_FILENAME3, TEST_TAR_BZ2_FILE_PATH,
TEST_TAR_FILE_PATH, TEST_TAR_GZ_FILE_PATH, TEST_ZIP_FILE_PATH
@@ -58,6 +59,11 @@ class ZipArchiveClassTestCase(TarArchiveClassTestCase):
archive_path = TEST_ZIP_FILE_PATH
cls = ZipArchive
def test_open_member_with_special_characters_filename(self):
with open(TEST_ARCHIVE_ZIP_SPECIAL_CHARACTERS_FILENAME_MEMBER_PATH, mode='rb') as file_object:
archive = Archive.open(file_object=file_object)
list(archive.get_members())
class TarGzArchiveClassTestCase(TarArchiveClassTestCase):
archive_path = TEST_TAR_GZ_FILE_PATH
@@ -67,3 +73,5 @@ class TarGzArchiveClassTestCase(TarArchiveClassTestCase):
class TarBz2ArchiveClassTestCase(TarArchiveClassTestCase):
archive_path = TEST_TAR_BZ2_FILE_PATH
cls = TarArchive

View File

@@ -10,7 +10,8 @@ from .views import (
AboutView, CurrentUserLocaleProfileDetailsView,
CurrentUserLocaleProfileEditView, FaviconRedirectView, HomeView,
LicenseView, ObjectErrorLogEntryListClearView, ObjectErrorLogEntryListView,
RootView, SetupListView, ToolsListView, multi_object_action_view
RootView, SetupListView, ToolsListView, QUnitView,
multi_object_action_view
)
urlpatterns = [
@@ -43,6 +44,9 @@ urlpatterns = [
view=ObjectErrorLogEntryListClearView.as_view(),
name='object_error_list_clear'
),
url(
regex=r'^qunit/', view=QUnitView.as_view(), name='qunit'
)
]
urlpatterns += [

View File

@@ -276,3 +276,8 @@ def multi_object_action_view(request):
action, urlencode({'id_list': id_list, 'next': next})
)
)
class QUnitView(SimpleView):
extra_context = {'title': _('QUnit tests')}
template_name = 'common/qunit.html'