Commit 4ac41898 authored by Guilhem Saurel's avatar Guilhem Saurel

test middleware & view

parent e5cbd849
Pipeline #9098 passed with stage
in 24 seconds
import doctest
from django.test import TestCase
from django.urls import reverse
from . import models, utils
......@@ -33,3 +34,21 @@ class RainboardTests(TestCase):
badges = project.badges()
for chunk in ['<img src="https://gitlab.laas', 'travis-ci', 'href="https://gepettoweb.laas']:
self.assertIn(chunk, badges)
# Test Middleware
response = self.client.get(reverse('rainboard:project', kwargs={'slug': project.slug}),
HTTP_X_FORWARDED_FOR='9.9.9.9')
self.assertEqual(response.status_code, 302)
response = self.client.get(reverse('rainboard:project', kwargs={'slug': project.slug}),
HTTP_X_FORWARDED_FOR='140.93.5.4')
self.assertEqual(response.status_code, 200)
# Test Views
content = response.content.decode()
for chunk in [
'<title>Gepetto Packages</title>',
'<h1>rainboard tests</h1>',
'Main forge</dt> <dd class="col-9"><a href="https://github.com">Github</a></dd>',
'<label class="label label-primary">BSD-2-Clause</label>',
]:
self.assertIn(chunk, content)
Markdown is supported
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