♻️(backend) generalize use of SerializerPerActionMixin in viewsets
We improve the serializer and generalize its use for clarity.
This commit is contained in:
committed by
Anthony LC
parent
8c247c8777
commit
5042f4ca47
@@ -76,14 +76,14 @@ def test_api_document_accesses_list_authenticated_related(via, mock_user_teams):
|
||||
user_access = models.DocumentAccess.objects.create(
|
||||
document=document,
|
||||
user=user,
|
||||
role=random.choice(models.RoleChoices.choices)[0],
|
||||
role=random.choice(models.RoleChoices.values),
|
||||
)
|
||||
elif via == TEAM:
|
||||
mock_user_teams.return_value = ["lasuite", "unknown"]
|
||||
user_access = models.DocumentAccess.objects.create(
|
||||
document=document,
|
||||
team="lasuite",
|
||||
role=random.choice(models.RoleChoices.choices)[0],
|
||||
role=random.choice(models.RoleChoices.values),
|
||||
)
|
||||
|
||||
access1 = factories.TeamDocumentAccessFactory(document=document)
|
||||
@@ -227,7 +227,7 @@ def test_api_document_accesses_update_anonymous():
|
||||
new_values = {
|
||||
"id": uuid4(),
|
||||
"user": factories.UserFactory().id,
|
||||
"role": random.choice(models.RoleChoices.choices)[0],
|
||||
"role": random.choice(models.RoleChoices.values),
|
||||
}
|
||||
|
||||
api_client = APIClient()
|
||||
@@ -260,7 +260,7 @@ def test_api_document_accesses_update_authenticated_unrelated():
|
||||
new_values = {
|
||||
"id": uuid4(),
|
||||
"user": factories.UserFactory().id,
|
||||
"role": random.choice(models.RoleChoices.choices)[0],
|
||||
"role": random.choice(models.RoleChoices.values),
|
||||
}
|
||||
|
||||
for field, value in new_values.items():
|
||||
@@ -302,7 +302,7 @@ def test_api_document_accesses_update_authenticated_reader_or_editor(
|
||||
new_values = {
|
||||
"id": uuid4(),
|
||||
"user": factories.UserFactory().id,
|
||||
"role": random.choice(models.RoleChoices.choices)[0],
|
||||
"role": random.choice(models.RoleChoices.values),
|
||||
}
|
||||
|
||||
for field, value in new_values.items():
|
||||
@@ -413,7 +413,7 @@ def test_api_document_accesses_update_administrator_from_owner(via, mock_user_te
|
||||
new_values = {
|
||||
"id": uuid4(),
|
||||
"user_id": factories.UserFactory().id,
|
||||
"role": random.choice(models.RoleChoices.choices)[0],
|
||||
"role": random.choice(models.RoleChoices.values),
|
||||
}
|
||||
|
||||
for field, value in new_values.items():
|
||||
@@ -527,7 +527,7 @@ def test_api_document_accesses_update_owner(
|
||||
new_values = {
|
||||
"id": uuid4(),
|
||||
"user_id": factories.UserFactory().id,
|
||||
"role": random.choice(models.RoleChoices.choices)[0],
|
||||
"role": random.choice(models.RoleChoices.values),
|
||||
}
|
||||
|
||||
for field, value in new_values.items():
|
||||
|
||||
@@ -26,7 +26,7 @@ def test_api_document_accesses_create_anonymous():
|
||||
{
|
||||
"user_id": str(other_user.id),
|
||||
"document": str(document.id),
|
||||
"role": random.choice(models.RoleChoices.choices)[0],
|
||||
"role": random.choice(models.RoleChoices.values),
|
||||
},
|
||||
format="json",
|
||||
)
|
||||
|
||||
@@ -304,7 +304,7 @@ def test_api_document_invitations_create_anonymous():
|
||||
document = factories.DocumentFactory()
|
||||
invitation_values = {
|
||||
"email": "guest@example.com",
|
||||
"role": random.choice(models.RoleChoices.choices)[0],
|
||||
"role": random.choice(models.RoleChoices.values),
|
||||
}
|
||||
|
||||
response = APIClient().post(
|
||||
@@ -325,7 +325,7 @@ def test_api_document_invitations_create_authenticated_outsider():
|
||||
document = factories.DocumentFactory()
|
||||
invitation_values = {
|
||||
"email": "guest@example.com",
|
||||
"role": random.choice(models.RoleChoices.choices)[0],
|
||||
"role": random.choice(models.RoleChoices.values),
|
||||
}
|
||||
|
||||
client = APIClient()
|
||||
@@ -550,7 +550,7 @@ def test_api_document_invitations_create_issuer_and_document_override():
|
||||
"document": str(other_document.id),
|
||||
"issuer": str(factories.UserFactory().id),
|
||||
"email": "guest@example.com",
|
||||
"role": random.choice(models.RoleChoices.choices)[0],
|
||||
"role": random.choice(models.RoleChoices.values),
|
||||
}
|
||||
|
||||
client = APIClient()
|
||||
@@ -611,7 +611,7 @@ def test_api_document_invitations_create_cannot_invite_existing_users():
|
||||
# Build an invitation to the email of an exising identity in the db
|
||||
invitation_values = {
|
||||
"email": existing_user.email,
|
||||
"role": random.choice(models.RoleChoices.choices)[0],
|
||||
"role": random.choice(models.RoleChoices.values),
|
||||
}
|
||||
|
||||
client = APIClient()
|
||||
|
||||
@@ -75,14 +75,14 @@ def test_api_document_versions_list_authenticated_related_success(via, mock_user
|
||||
models.DocumentAccess.objects.create(
|
||||
document=document,
|
||||
user=user,
|
||||
role=random.choice(models.RoleChoices.choices)[0],
|
||||
role=random.choice(models.RoleChoices.values),
|
||||
)
|
||||
elif via == TEAM:
|
||||
mock_user_teams.return_value = ["lasuite", "unknown"]
|
||||
models.DocumentAccess.objects.create(
|
||||
document=document,
|
||||
team="lasuite",
|
||||
role=random.choice(models.RoleChoices.choices)[0],
|
||||
role=random.choice(models.RoleChoices.values),
|
||||
)
|
||||
|
||||
# Other versions of documents to which the user has access should not be listed
|
||||
@@ -134,14 +134,14 @@ def test_api_document_versions_list_authenticated_related_pagination(
|
||||
models.DocumentAccess.objects.create(
|
||||
document=document,
|
||||
user=user,
|
||||
role=random.choice(models.RoleChoices.choices)[0],
|
||||
role=random.choice(models.RoleChoices.values),
|
||||
)
|
||||
elif via == TEAM:
|
||||
mock_user_teams.return_value = ["lasuite", "unknown"]
|
||||
models.DocumentAccess.objects.create(
|
||||
document=document,
|
||||
team="lasuite",
|
||||
role=random.choice(models.RoleChoices.choices)[0],
|
||||
role=random.choice(models.RoleChoices.values),
|
||||
)
|
||||
|
||||
for i in range(4):
|
||||
@@ -210,14 +210,14 @@ def test_api_document_versions_list_authenticated_related_pagination_parent(
|
||||
models.DocumentAccess.objects.create(
|
||||
document=grand_parent,
|
||||
user=user,
|
||||
role=random.choice(models.RoleChoices.choices)[0],
|
||||
role=random.choice(models.RoleChoices.values),
|
||||
)
|
||||
elif via == TEAM:
|
||||
mock_user_teams.return_value = ["lasuite", "unknown"]
|
||||
models.DocumentAccess.objects.create(
|
||||
document=grand_parent,
|
||||
team="lasuite",
|
||||
role=random.choice(models.RoleChoices.choices)[0],
|
||||
role=random.choice(models.RoleChoices.values),
|
||||
)
|
||||
|
||||
for i in range(4):
|
||||
|
||||
Reference in New Issue
Block a user