Commit 122d89c39311f42c80e40bf28554ad7bd374f512
Committed by
Matheus de Sousa Faria
1 parent
405e0aa0
Exists in
master
and in
4 other branches
Testing UserManageSubscription
Signed-off-by: Matheus Faria <matheus.sousa.faria@gmail.com> Signed-off-by: TomazMartins <tomaz.r.martins@gmail.com>
Showing
1 changed file
with
50 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,50 @@ | @@ -0,0 +1,50 @@ | ||
1 | +""" | ||
2 | +Test User Mailing list Subscriptions class. | ||
3 | +Objective: Test parameters, and behavior. | ||
4 | +""" | ||
5 | + | ||
6 | +from colab.accounts.models import User | ||
7 | +from django.test import TestCase, Client | ||
8 | + | ||
9 | + | ||
10 | +class UserSubscriptionTest(TestCase): | ||
11 | + OK = 200 | ||
12 | + FORBIDDEN_ACCESS = 403 | ||
13 | + | ||
14 | + def setUp(self): | ||
15 | + self.user = self.create_user() | ||
16 | + self.client = Client() | ||
17 | + | ||
18 | + def tearDown(self): | ||
19 | + pass | ||
20 | + | ||
21 | + def create_user(self): | ||
22 | + user = User() | ||
23 | + user.username = "USERtestCoLaB" | ||
24 | + user.set_password("123colab4") | ||
25 | + user.email = "usertest@colab.com.br" | ||
26 | + user.id = 1 | ||
27 | + user.twitter = "usertestcolab" | ||
28 | + user.facebook = "usertestcolab" | ||
29 | + user.first_name = "USERtestCoLaB" | ||
30 | + user.last_name = "COLAB" | ||
31 | + user.save() | ||
32 | + | ||
33 | + return user | ||
34 | + | ||
35 | + def authenticate_user(self): | ||
36 | + self.user.needs_update = False | ||
37 | + self.user.save() | ||
38 | + self.client.login(username=self.user.username, | ||
39 | + password='123colab4') | ||
40 | + | ||
41 | + def test_manage_subscription_logged_in(self): | ||
42 | + self.authenticate_user() | ||
43 | + response = self.client.get("/account/" + self.user.username + | ||
44 | + "/subscriptions") | ||
45 | + self.assertEqual(response.status_code, self.OK) | ||
46 | + | ||
47 | + def test_manage_subscription_without_login(self): | ||
48 | + response = self.client.get("/account/" + self.user.username + | ||
49 | + "/subscriptions") | ||
50 | + self.assertEqual(response.status_code, self.FORBIDDEN_ACCESS) |