Commit f3e26eb1 authored by Jelle van der Waa's avatar Jelle van der Waa 🚧 Committed by Angel Velásquez
Browse files

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.
parent 875d50d8
......@@ -4,5 +4,8 @@
omit =
**/migrations/*.py
**/tests.py
**/tests/*.py
env*
settings.py
local_settings.py
/home/travis/virtualenv*
def secure(request):
return {'secure': request.is_secure()}
# vim: set ts=4 sw=4 et:
import json
import unittest
from django.core import mail
from django.test import TestCase
from .alpm import AlpmAPI
......@@ -235,4 +236,43 @@ def test_groups_detail(self):
# 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:
......@@ -180,7 +180,6 @@
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.contrib.messages.context_processors.messages',
'main.context_processors.secure',
],
}
}
......
......@@ -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>
......
......@@ -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 @@ <h3>Recent Updates <span class="more">(<a href="/packages/?sort=-last_update"
</div>
{% endcache %}
{% cache 115 main-page-right secure %}
{% cache 115 main-page-right %}
<div id="nav-sidebar" class="widget">
<h4>Documentation</h4>
<ul>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment