diff options
author | jelle van der Waa <jelle@vdwaa.nl> | 2018-02-18 10:33:52 +0100 |
---|---|---|
committer | Angel Velásquez <angvp@archlinux.org> | 2018-02-18 04:33:52 -0500 |
commit | f3e26eb15a54e74a375e395200bfca3d1664adaf (patch) | |
tree | ee946542451e505612a6739ec04073922bf59036 | |
parent | 875d50d8f23069515b865b28044fb572a14049ed (diff) | |
download | archweb-f3e26eb15a54e74a375e395200bfca3d1664adaf.tar.gz archweb-f3e26eb15a54e74a375e395200bfca3d1664adaf.zip |
Misc fixes (#84)
* Update coveragerc to exclude newly located tests
There are now tests under main/tests/* etc, which should be omitted for
coverage.
* omit settings from coverage
settings and local_settings aren't interesting for coverage, omit them.
* remove leftover secure context processor
The secure context processor was used to determine if the cdn served
assets should be loaded over https or http. Since assets are no longer
served with a cdn and the whole site is loaded over https these days,
this code is dead and can be removed.
* packages: Add test for flagging packages out of date
Add simple test cases for flagging packages out of date, should later be
improved to query the Package model for packages and use that data
instead of hardcoding.
-rw-r--r-- | .coveragerc | 3 | ||||
-rw-r--r-- | main/context_processors.py | 4 | ||||
-rw-r--r-- | packages/tests.py | 40 | ||||
-rw-r--r-- | settings.py | 1 | ||||
-rw-r--r-- | templates/public/donate.html | 2 | ||||
-rw-r--r-- | templates/public/index.html | 4 |
6 files changed, 46 insertions, 8 deletions
diff --git a/.coveragerc b/.coveragerc index 249bf089..02b787e9 100644 --- a/.coveragerc +++ b/.coveragerc @@ -4,5 +4,8 @@ omit = **/migrations/*.py **/tests.py + **/tests/*.py env* + settings.py + local_settings.py /home/travis/virtualenv* diff --git a/main/context_processors.py b/main/context_processors.py deleted file mode 100644 index a60d4e63..00000000 --- a/main/context_processors.py +++ /dev/null @@ -1,4 +0,0 @@ -def secure(request): - return {'secure': request.is_secure()} - -# vim: set ts=4 sw=4 et: diff --git a/packages/tests.py b/packages/tests.py index 94d7c20d..7dd1ff5b 100644 --- a/packages/tests.py +++ b/packages/tests.py @@ -1,6 +1,7 @@ import json import unittest +from django.core import mail from django.test import TestCase from .alpm import AlpmAPI @@ -235,4 +236,43 @@ class PackageDisplay(TestCase): # FIXME: add group fixtures. +class FlagPackage(TestCase): + fixtures = ['main/fixtures/arches.json', 'main/fixtures/repos.json', + 'main/fixtures/package.json'] + + def test_flag_package(self): + data = { + 'website': '', + 'email': 'nobody@archlinux.org', + 'message': 'new linux version', + } + response = self.client.post('/packages/core/x86_64/linux/flag/', + data, + follow=True) + self.assertEqual(response.status_code, 200) + self.assertIn('Package Flagged - linux', response.content) + self.assertEqual(len(mail.outbox), 1) + self.assertIn('package [linux] marked out-of-date', mail.outbox[0].subject) + + # Flag again, should fail + response = self.client.post('/packages/core/x86_64/linux/flag/', + data, + follow=True) + self.assertEqual(response.status_code, 200) + self.assertIn('has already been flagged out-of-date.', response.content) + + def test_flag_package_invalid(self): + data = { + 'website': '', + 'email': 'nobody@archlinux.org', + 'message': 'a', + } + response = self.client.post('/packages/core/x86_64/linux/flag/', + data, + follow=True) + self.assertEqual(response.status_code, 200) + self.assertIn('Enter a valid and useful out-of-date message', response.content) + self.assertEqual(len(mail.outbox), 0) + + # vim: set ts=4 sw=4 et: diff --git a/settings.py b/settings.py index 182b8e3b..5919b86b 100644 --- a/settings.py +++ b/settings.py @@ -180,7 +180,6 @@ TEMPLATES = [ 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.debug', 'django.contrib.messages.context_processors.messages', - 'main.context_processors.secure', ], } } diff --git a/templates/public/donate.html b/templates/public/donate.html index d6d105a8..e68100c7 100644 --- a/templates/public/donate.html +++ b/templates/public/donate.html @@ -5,7 +5,7 @@ {% block title %}Arch Linux - Donate{% endblock %} {% block content %} -{% cache 600 donations secure %} +{% cache 600 donations %} <div id="donations" class="box"> <h2>Donate to Arch Linux</h2> diff --git a/templates/public/index.html b/templates/public/index.html index 9242263e..7ee4453b 100644 --- a/templates/public/index.html +++ b/templates/public/index.html @@ -8,7 +8,7 @@ {% endblock %} {% block content_left %} -{% cache 62 main-page-left secure %} +{% cache 62 main-page-left %} <div id="intro" class="box"> <h2>A simple, lightweight distribution</h2> @@ -105,7 +105,7 @@ </div> {% endcache %} -{% cache 115 main-page-right secure %} +{% cache 115 main-page-right %} <div id="nav-sidebar" class="widget"> <h4>Documentation</h4> <ul> |