2024-01-11 23:36:15 +02:00
|
|
|
from django.test import TestCase, Client
|
|
|
|
from django.urls import reverse
|
|
|
|
|
2024-01-12 00:05:57 +02:00
|
|
|
from .models import Signup
|
|
|
|
|
|
|
|
class SignupViewTest(TestCase):
|
2024-01-11 23:36:15 +02:00
|
|
|
def setUp(self):
|
|
|
|
self.client = Client()
|
|
|
|
|
|
|
|
def test_index(self):
|
|
|
|
resp = self.client.get(reverse("index"))
|
2024-01-12 00:05:57 +02:00
|
|
|
self.assertEqual(resp.status_code, 200)
|
2024-01-11 23:36:15 +02:00
|
|
|
self.assertContains(resp, "11sync is a privacy-respecting way")
|
|
|
|
|
|
|
|
def test_ok_signup(self):
|
|
|
|
resp = self.client.post(reverse("index"), {"email": "foo@example.com"},
|
|
|
|
follow = True,
|
|
|
|
HTTP_USER_AGENT = "foo-agent",
|
|
|
|
REMOTE_ADDR = "127.0.0.2")
|
2024-01-12 00:05:57 +02:00
|
|
|
self.assertEqual(resp.redirect_chain, [('/?success', 302)])
|
|
|
|
#print(str(resp.content).replace('\\n', '\n'))
|
2024-01-11 23:36:15 +02:00
|
|
|
self.assertContains(resp, "You are now subscribed!")
|