mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-10-31 00:53:08 +00:00 
			
		
		
		
	fix some tests
This commit is contained in:
		| @@ -66,6 +66,40 @@ class TestImageAccess: | ||||
|         assert not picture.is_owned_by(user) | ||||
|  | ||||
|  | ||||
| @pytest.mark.django_db | ||||
| class TestUserPicture: | ||||
|     def test_anonymous_user_unauthorized(self, client): | ||||
|         """An anonymous user shouldn't have access to an user's photo page.""" | ||||
|         response = client.get( | ||||
|             reverse( | ||||
|                 "core:user_pictures", | ||||
|                 kwargs={"user_id": User.objects.get(username="sli").pk}, | ||||
|             ) | ||||
|         ) | ||||
|         assert response.status_code == 403 | ||||
|  | ||||
|     @pytest.mark.parametrize( | ||||
|         ("username", "status"), | ||||
|         [ | ||||
|             ("guy", 403), | ||||
|             ("root", 200), | ||||
|             ("skia", 200), | ||||
|             ("sli", 200), | ||||
|         ], | ||||
|     ) | ||||
|     def test_page_is_working(self, client, username, status): | ||||
|         """Only user that subscribed (or admins) should be able to see the page.""" | ||||
|         # Test for simple user | ||||
|         client.force_login(User.objects.get(username=username)) | ||||
|         response = client.get( | ||||
|             reverse( | ||||
|                 "core:user_pictures", | ||||
|                 kwargs={"user_id": User.objects.get(username="sli").pk}, | ||||
|             ) | ||||
|         ) | ||||
|         assert response.status_code == status | ||||
|  | ||||
|  | ||||
| # TODO: many tests on the pages: | ||||
| #   - renaming a page | ||||
| #   - changing a page's parent --> check that page's children's full_name | ||||
|   | ||||
| @@ -22,6 +22,7 @@ from core.models import Group, User | ||||
| from core.views import UserTabsMixin | ||||
| from counter.models import Counter, Refilling, Selling | ||||
| from eboutic.models import Invoice, InvoiceItem | ||||
| from sas.models import Picture | ||||
|  | ||||
|  | ||||
| class TestSearchUsers(TestCase): | ||||
| @@ -29,6 +30,7 @@ class TestSearchUsers(TestCase): | ||||
|     def setUpTestData(cls): | ||||
|         # News.author has on_delete=PROTECT, so news must be deleted beforehand | ||||
|         News.objects.all().delete() | ||||
|         Picture.objects.all().delete()  # same for pictures | ||||
|         User.objects.all().delete() | ||||
|         user_recipe = Recipe( | ||||
|             User, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user