# -*- coding:utf-8 -* # # Copyright 2023 © AE UTBM # ae@utbm.fr / ae.info@utbm.fr # # This file is part of the website of the UTBM Student Association (AE UTBM), # https://ae.utbm.fr. # # You can find the source code of the website at https://github.com/ae-utbm/sith3 # # LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3) # SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE # OR WITHIN THE LOCAL FILE "LICENSE" # # from django.test import TestCase from django.urls import reverse from django.core.management import call_command from datetime import date, timedelta from core.models import User from accounting.models import ( GeneralJournal, Operation, Label, AccountingType, SimplifiedAccountingType, ) class RefoundAccountTest(TestCase): def setUp(self): call_command("populate") self.skia = User.objects.filter(username="skia").first() # reffil skia's account self.skia.customer.amount = 800 self.skia.customer.save() def test_permission_denied(self): self.client.login(username="guy", password="plop") response_post = self.client.post( reverse("accounting:refound_account"), {"user": self.skia.id} ) response_get = self.client.get(reverse("accounting:refound_account")) self.assertTrue(response_get.status_code == 403) self.assertTrue(response_post.status_code == 403) def test_root_granteed(self): self.client.login(username="root", password="plop") response_post = self.client.post( reverse("accounting:refound_account"), {"user": self.skia.id} ) self.skia = User.objects.filter(username="skia").first() response_get = self.client.get(reverse("accounting:refound_account")) self.assertFalse(response_get.status_code == 403) self.assertTrue('