4
4
from django .urls import reverse
5
5
from pytest_lazyfixture import lazy_fixture
6
6
from rest_framework import status
7
+ from rest_framework .test import APIClient
7
8
8
9
from features .models import Feature
9
10
from organisations .models import Organisation
10
11
from projects .models import Project
12
+ from users .models import FFAdminUser
11
13
12
14
13
15
@pytest .mark .parametrize (
@@ -68,12 +70,9 @@ def test_cannot_create_mv_option_when_feature_id_invalid(client, feature_id, pro
68
70
assert response .status_code == status .HTTP_404_NOT_FOUND
69
71
70
72
71
- @pytest .mark .parametrize (
72
- "client" ,
73
- [lazy_fixture ("admin_client" )],
74
- )
75
- def test_cannot_create_mv_option_when_user_is_not_owner_of_the_feature (client , project ):
73
+ def test_cannot_create_mv_option_when_user_is_not_owner_of_the_feature (project ):
76
74
# Given
75
+ new_user = FFAdminUser .
objects .
create (
email = "[email protected] " )
77
76
organisation = Organisation .objects .create (name = "Test Org" )
78
77
new_project = Project .objects .create (name = "Test project" , organisation = organisation )
79
78
feature = Feature .objects .create (
@@ -91,6 +90,8 @@ def test_cannot_create_mv_option_when_user_is_not_owner_of_the_feature(client, p
91
90
"string_value" : "bigger" ,
92
91
"default_percentage_allocation" : 50 ,
93
92
}
93
+ client = APIClient ()
94
+ client .force_authenticate (user = new_user )
94
95
# When
95
96
response = client .post (
96
97
url ,
0 commit comments