Commit 0d34343a authored by Flavio TARSETTI's avatar Flavio TARSETTI
Browse files

[accounts][tests] Pre-commit cleanup for TemporaryUrl

parent a9185c80
Pipeline #39919 passed with stage
in 14 minutes and 56 seconds
......@@ -26,8 +26,6 @@
###############################################################################
from django.core.urlresolvers import reverse
from django.test import TestCase
from rest_framework import status
from rest_framework.test import APITestCase
......@@ -39,7 +37,7 @@ from .models import SupervisionTrack
from .models import Profile
from .models import TemporaryUrl
from datetime import datetime, timedelta
from datetime import timedelta
import datetime
import simplejson as json
......@@ -164,7 +162,6 @@ class AccountTestCase(APITestCase):
self.blockeduser.save()
def tearDown(self):
user = None
pass
def test_check_access_and_setup(self):
......@@ -174,44 +171,44 @@ class AccountTestCase(APITestCase):
logged_in = self.client.login(username=user.username, password=self.password)
self.assertTrue(logged_in)
self.assertEqual(user.username, "firstsupervisor")
logged_out = self.client.logout()
self.client.logout()
user = self.secondsupervisor
logged_in = self.client.login(username=user.username, password=self.password)
self.assertTrue(logged_in)
self.assertEqual(user.username, "secondsupervisor")
logged_out = self.client.logout()
self.client.logout()
user = self.invalidsupervisor
logged_in = self.client.login(username=user.username, password=self.password)
self.assertFalse(logged_in)
self.assertEqual(user.username, "invalidsupervisor")
logged_out = self.client.logout()
self.client.logout()
# Users
user = self.accepteduser
logged_in = self.client.login(username=user.username, password=self.password)
self.assertTrue(logged_in)
self.assertEqual(user.username, "accepteduser")
logged_out = self.client.logout()
self.client.logout()
user = self.rejecteduser
logged_in = self.client.login(username=user.username, password=self.password)
self.assertTrue(logged_in)
self.assertEqual(user.username, "rejecteduser")
logged_out = self.client.logout()
self.client.logout()
user = self.yearrevalidationuser
logged_in = self.client.login(username=user.username, password=self.password)
self.assertTrue(logged_in)
self.assertEqual(user.username, "yearrevalidationuser")
logged_out = self.client.logout()
self.client.logout()
user = self.blockeduser
logged_in = self.client.login(username=user.username, password=self.password)
self.assertFalse(logged_in)
self.assertEqual(user.username, "blockeduser")
logged_out = self.client.logout()
self.client.logout()
# ----------------------------------------------------------
......@@ -246,7 +243,7 @@ class AccountListTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Not a supervisor account")
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_user_supervisor(self):
......@@ -263,7 +260,7 @@ class AccountListTestCase(AccountTestCase):
self.assertEqual(content[0]["supervisee"]["username"], "accepteduser")
self.assertEqual(content[1]["supervisee"]["username"], "yearrevalidationuser")
logged_out = self.client.logout()
self.client.logout()
# ----------------------------------------------------------
......@@ -300,7 +297,7 @@ class AccountRevalidationTestCase(AccountTestCase):
"You don't need to revalidate at the moment, your supervision is still valid",
)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_rejected_user(self):
client = self.rejecteduser
......@@ -319,7 +316,7 @@ class AccountRevalidationTestCase(AccountTestCase):
"You are not allowed to perform this action, you first need to get a valid supervision",
)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_yearrevalidation_user(self):
......@@ -332,7 +329,7 @@ class AccountRevalidationTestCase(AccountTestCase):
response = self.client.put(self.url, format="json")
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_yearrevalidation_user_twice_validation(self):
......@@ -355,7 +352,7 @@ class AccountRevalidationTestCase(AccountTestCase):
"You don't need to revalidate at the moment, your supervision is still valid",
)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_blocked_user(self):
......@@ -372,7 +369,7 @@ class AccountRevalidationTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Authentication credentials were not provided.")
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_user_supervisor(self):
......@@ -392,7 +389,7 @@ class AccountRevalidationTestCase(AccountTestCase):
"You are not allowed to perform this action, you first need to get a valid supervision",
)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_invalid_supervisor(self):
......@@ -409,7 +406,7 @@ class AccountRevalidationTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Authentication credentials were not provided.")
logged_out = self.client.logout()
self.client.logout()
# ----------------------------------------------------------
......@@ -472,7 +469,7 @@ class AccountAddSupervisorTestCase(AccountTestCase):
self.assertEqual(previous_supervision_track.is_valid, True)
self.assertEqual(previous_supervision_key, new_supervision_key)
self.assertEqual(client.profile.status, Profile.ACCEPTED)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_accepted_user(self):
......@@ -509,7 +506,7 @@ class AccountAddSupervisorTestCase(AccountTestCase):
previous_supervision_track.supervisor, new_supervision_track.supervisor
)
self.assertEqual(client.profile.status, Profile.REJECTED)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_rejected_user(self):
......@@ -536,7 +533,7 @@ class AccountAddSupervisorTestCase(AccountTestCase):
self.assertNotEqual(previous_supervision_key, new_supervision_key)
self.assertEqual(new_supervision_track.supervisor.username, "secondsupervisor")
self.assertEqual(client.profile.status, Profile.REJECTED)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_rejected_user_twice(self):
......@@ -584,7 +581,7 @@ class AccountAddSupervisorTestCase(AccountTestCase):
self.assertNotEqual(previous_supervision_key, new_supervision_key)
self.assertEqual(new_supervision_track.supervisor.username, "secondsupervisor")
self.assertEqual(client.profile.status, Profile.REJECTED)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_yearrevalidation_user(self):
......@@ -622,7 +619,7 @@ class AccountAddSupervisorTestCase(AccountTestCase):
)
self.assertEqual(client.profile.status, Profile.REJECTED)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_blocked_user(self):
......@@ -641,7 +638,7 @@ class AccountAddSupervisorTestCase(AccountTestCase):
# This reactivation can be done through online request ONLY
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_user_supervisor(self):
......@@ -658,7 +655,7 @@ class AccountAddSupervisorTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Not a supervisee account")
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_invalid_supervisor(self):
......@@ -675,7 +672,7 @@ class AccountAddSupervisorTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Authentication credentials were not provided.")
logged_out = self.client.logout()
self.client.logout()
# ----------------------------------------------------------
......@@ -720,7 +717,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Not a supervisor account")
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_rejected_user(self):
client = self.rejecteduser
......@@ -737,7 +734,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Not a supervisor account")
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_yearrevalidation_user(self):
......@@ -755,7 +752,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Not a supervisor account")
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_blocked_user(self):
......@@ -772,7 +769,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Authentication credentials were not provided.")
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_user_supervisor_validate_already_accepted_user(self):
......@@ -792,7 +789,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
"You can't validate this supervisee as his supervision is still valid",
)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_user_secondsupervisor_validates_previously_accepted_user(self):
......@@ -835,7 +832,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
previous_supervision_track.supervisor, new_supervision_track.supervisor
)
self.assertEqual(client.profile.status, Profile.REJECTED)
logged_out = self.client.logout()
self.client.logout()
self.url = reverse(
"api_accounts:validate_supervisee",
......@@ -851,7 +848,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
logged_out = self.client.logout()
self.client.logout()
client = User.objects.get(username=self.accepteduser.username)
new_supervision_key = client.profile.supervision_key
......@@ -898,7 +895,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
self.assertNotEqual(previous_supervision_key, new_supervision_key)
self.assertEqual(new_supervision_track.supervisor.username, "secondsupervisor")
self.assertEqual(client.profile.status, Profile.REJECTED)
logged_out = self.client.logout()
self.client.logout()
self.url = reverse(
"api_accounts:validate_supervisee",
......@@ -914,7 +911,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
logged_out = self.client.logout()
self.client.logout()
client = User.objects.get(username=self.rejecteduser.username)
new_supervision_key = client.profile.supervision_key
......@@ -968,7 +965,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
)
self.assertEqual(client.profile.status, Profile.REJECTED)
logged_out = self.client.logout()
self.client.logout()
self.url = reverse(
"api_accounts:validate_supervisee",
......@@ -984,7 +981,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
logged_out = self.client.logout()
self.client.logout()
client = User.objects.get(username=self.yearrevalidationuser.username)
new_supervision_key = client.profile.supervision_key
......@@ -1019,7 +1016,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
"You can't validate this supervisee as his supervision is still valid",
)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_invalid_supervisor(self):
......@@ -1036,7 +1033,7 @@ class AccountValidateSuperviseeTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Authentication credentials were not provided.")
logged_out = self.client.logout()
self.client.logout()
# ----------------------------------------------------------
......@@ -1081,7 +1078,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Not a supervisor account")
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_rejected_user(self):
client = self.rejecteduser
......@@ -1098,7 +1095,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Not a supervisor account")
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_yearrevalidation_user(self):
......@@ -1116,7 +1113,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Not a supervisor account")
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_blocked_user(self):
......@@ -1133,7 +1130,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Authentication credentials were not provided.")
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_supervisor_remove_accepted_user(self):
# accepted user before
......@@ -1150,7 +1147,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase):
self.assertEqual(previous_supervision_track.is_valid, True)
self.assertEqual(client.profile.status, Profile.ACCEPTED)
logged_out = self.client.logout()
self.client.logout()
# accepted user removed
client = self.firstsupervisor
......@@ -1162,7 +1159,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase):
response = self.client.put(self.url, format="json")
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
logged_out = self.client.logout()
self.client.logout()
# accepted user after
client = User.objects.get(username=self.accepteduser.username)
......@@ -1178,7 +1175,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase):
)
self.assertEqual(previous_supervision_track.is_valid, False)
self.assertEqual(client.profile.status, Profile.REJECTED)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_supervisor_remove_yearrevalidation_user(self):
self.url = reverse(
......@@ -1200,7 +1197,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase):
self.assertEqual(previous_supervision_track.is_valid, True)
self.assertEqual(client.profile.status, Profile.YEARREVALIDATION)
logged_out = self.client.logout()
self.client.logout()
# yearrevalidationuser user removed
client = self.firstsupervisor
......@@ -1212,7 +1209,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase):
response = self.client.put(self.url, format="json")
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
logged_out = self.client.logout()
self.client.logout()
# yearrevalidationuser user after
client = User.objects.get(username=self.yearrevalidationuser.username)
......@@ -1228,7 +1225,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase):
)
self.assertEqual(previous_supervision_track.is_valid, False)
self.assertEqual(client.profile.status, Profile.REJECTED)
logged_out = self.client.logout()
self.client.logout()
def test_logged_in_invalid_supervisor(self):
......@@ -1245,7 +1242,7 @@ class AccountRemoveSuperviseeTestCase(AccountTestCase):
errormsg = content["detail"]
self.assertEqual(errormsg, "Authentication credentials were not provided.")
logged_out = self.client.logout()
self.client.logout()
# ----------------------------------------------------------
......@@ -1287,7 +1284,7 @@ class TemporaryUrlTestCase(AccountTestCase):
self.new_supervision_track = SupervisionTrack.objects.get(
supervision_key=client.profile.supervision_key
)
logged_out = self.client.logout()
self.client.logout()
self.valid_supervision_track = SupervisionTrack.objects.get(
supervision_key=self.accepteduser.profile.supervision_key
)
......
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