refactor(); project refactor
This commit is contained in:
@@ -4,7 +4,11 @@ from uuid import UUID
|
||||
|
||||
from ninja import Field, ModelSchema, Schema
|
||||
|
||||
from apps.conflicts.models import ConflictDomain, ConflictPolicy, ExperimentConflictDomain
|
||||
from apps.conflicts.models import (
|
||||
ConflictDomain,
|
||||
ConflictPolicy,
|
||||
ExperimentConflictDomain,
|
||||
)
|
||||
|
||||
|
||||
class ConflictDomainOut(ModelSchema):
|
||||
@@ -54,7 +58,8 @@ class MembershipOut(Schema):
|
||||
|
||||
@classmethod
|
||||
def from_membership(
|
||||
cls, m: ExperimentConflictDomain,
|
||||
cls,
|
||||
m: ExperimentConflictDomain,
|
||||
) -> "MembershipOut":
|
||||
return cls(
|
||||
id=m.pk,
|
||||
@@ -76,7 +81,8 @@ class ExperimentDomainOut(Schema):
|
||||
|
||||
@classmethod
|
||||
def from_membership(
|
||||
cls, m: ExperimentConflictDomain,
|
||||
cls,
|
||||
m: ExperimentConflictDomain,
|
||||
) -> "ExperimentDomainOut":
|
||||
return cls(
|
||||
id=m.pk,
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import json
|
||||
import uuid
|
||||
from typing import override
|
||||
|
||||
from django.test import Client, TestCase
|
||||
from django.urls import reverse
|
||||
|
||||
from apps.conflicts.tests.helpers import make_domain
|
||||
from apps.experiments.tests.helpers import add_two_variants, make_flag
|
||||
from apps.experiments.services import experiment_create
|
||||
from apps.reviews.tests.helpers import make_admin, make_experimenter, make_viewer
|
||||
from apps.experiments.tests.helpers import add_two_variants, make_flag
|
||||
from apps.reviews.tests.helpers import (
|
||||
make_admin,
|
||||
make_experimenter,
|
||||
make_viewer,
|
||||
)
|
||||
from apps.users.tests.helpers import auth_header
|
||||
|
||||
|
||||
@@ -23,12 +28,14 @@ class ConflictDomainAPITest(TestCase):
|
||||
def test_create_domain(self) -> None:
|
||||
resp = self.client.post(
|
||||
reverse("api-1:create_domain"),
|
||||
data=json.dumps({
|
||||
"name": "checkout",
|
||||
"description": "Checkout zone",
|
||||
"policy": "mutual_exclusion",
|
||||
"max_concurrent": 1,
|
||||
}),
|
||||
data=json.dumps(
|
||||
{
|
||||
"name": "checkout",
|
||||
"description": "Checkout zone",
|
||||
"policy": "mutual_exclusion",
|
||||
"max_concurrent": 1,
|
||||
}
|
||||
),
|
||||
content_type="application/json",
|
||||
HTTP_AUTHORIZATION=self.admin_auth,
|
||||
)
|
||||
@@ -86,8 +93,6 @@ class ConflictDomainAPITest(TestCase):
|
||||
self.assertEqual(resp.status_code, 204)
|
||||
|
||||
def test_get_nonexistent_domain(self) -> None:
|
||||
import uuid
|
||||
|
||||
resp = self.client.get(
|
||||
reverse("api-1:get_domain", args=[uuid.uuid4()]),
|
||||
HTTP_AUTHORIZATION=self.admin_auth,
|
||||
@@ -114,10 +119,12 @@ class DomainExperimentAPITest(TestCase):
|
||||
def test_add_experiment_to_domain(self) -> None:
|
||||
resp = self.client.post(
|
||||
reverse("api-1:add_experiment_to_domain", args=[self.domain.pk]),
|
||||
data=json.dumps({
|
||||
"experiment_id": str(self.exp.pk),
|
||||
"priority": 5,
|
||||
}),
|
||||
data=json.dumps(
|
||||
{
|
||||
"experiment_id": str(self.exp.pk),
|
||||
"priority": 5,
|
||||
}
|
||||
),
|
||||
content_type="application/json",
|
||||
HTTP_AUTHORIZATION=self.admin_auth,
|
||||
)
|
||||
@@ -134,9 +141,7 @@ class DomainExperimentAPITest(TestCase):
|
||||
HTTP_AUTHORIZATION=self.admin_auth,
|
||||
)
|
||||
resp = self.client.get(
|
||||
reverse(
|
||||
"api-1:list_experiment_domains", args=[self.exp.pk]
|
||||
),
|
||||
reverse("api-1:list_experiment_domains", args=[self.exp.pk]),
|
||||
HTTP_AUTHORIZATION=self.admin_auth,
|
||||
)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
Reference in New Issue
Block a user