test(devops): Update feature flag test case setup to enable feature flag for testing software
ref: #662 #659
This commit is contained in:
@ -6,6 +6,7 @@ from rest_framework.exceptions import ValidationError
|
||||
|
||||
from access.models.organization import Organization
|
||||
|
||||
from devops.models.software_enable_feature_flag import SoftwareEnableFeatureFlag
|
||||
from devops.serializers.feature_flag import FeatureFlag, ModelSerializer
|
||||
|
||||
from itam.models.software import Software
|
||||
@ -35,6 +36,12 @@ class ValidationAPI(
|
||||
name = 'soft',
|
||||
)
|
||||
|
||||
SoftwareEnableFeatureFlag.objects.create(
|
||||
organization = self.organization,
|
||||
software = software,
|
||||
enabled = True
|
||||
)
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one',
|
||||
@ -91,7 +98,7 @@ class ValidationAPI(
|
||||
assert err.value.get_codes()['name'][0] == 'required'
|
||||
|
||||
|
||||
def test_serializer_validation_no_software_ok(self):
|
||||
def test_serializer_validation_no_software_exception(self):
|
||||
"""Serializer Validation Check
|
||||
|
||||
Ensure that when creating and field software is not provided, no
|
||||
@ -102,11 +109,16 @@ class ValidationAPI(
|
||||
|
||||
del valid_data['software']
|
||||
|
||||
serializer = ModelSerializer(
|
||||
data = valid_data
|
||||
)
|
||||
with pytest.raises(ValidationError) as err:
|
||||
|
||||
serializer = ModelSerializer(
|
||||
data = valid_data
|
||||
)
|
||||
|
||||
serializer.is_valid(raise_exception = True)
|
||||
|
||||
assert err.value.get_codes()['software'][0] == 'required'
|
||||
|
||||
assert serializer.is_valid(raise_exception = True)
|
||||
|
||||
|
||||
def test_serializer_validation_no_description_ok(self):
|
||||
|
@ -14,6 +14,7 @@ from api.tests.abstract.api_serializer_viewset import SerializersTestCases
|
||||
from api.tests.abstract.test_metadata_functional import MetadataAttributesFunctional
|
||||
|
||||
from devops.models.feature_flag import FeatureFlag
|
||||
from devops.models.software_enable_feature_flag import SoftwareEnableFeatureFlag
|
||||
|
||||
from itam.models.software import Software
|
||||
|
||||
@ -61,11 +62,6 @@ class ViewSetBase:
|
||||
name = 'test_global_organization'
|
||||
)
|
||||
|
||||
self.global_org_item = self.model.objects.create(
|
||||
organization = self.global_organization,
|
||||
name = 'global_item'
|
||||
)
|
||||
|
||||
app_settings = AppSettings.objects.get(
|
||||
owner_organization = None
|
||||
)
|
||||
@ -155,14 +151,27 @@ class ViewSetBase:
|
||||
user = self.view_user
|
||||
)
|
||||
|
||||
software = Software.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'soft',
|
||||
)
|
||||
|
||||
SoftwareEnableFeatureFlag.objects.create(
|
||||
organization = self.organization,
|
||||
software = software,
|
||||
enabled = True
|
||||
)
|
||||
|
||||
self.global_org_item = self.model.objects.create(
|
||||
organization = self.global_organization,
|
||||
name = 'global_item',
|
||||
software = software,
|
||||
)
|
||||
|
||||
self.item = self.model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one',
|
||||
software = Software.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'soft',
|
||||
),
|
||||
software = software,
|
||||
description = 'desc',
|
||||
model_notes = 'text',
|
||||
enabled = True
|
||||
@ -170,7 +179,8 @@ class ViewSetBase:
|
||||
|
||||
self.other_org_item = self.model.objects.create(
|
||||
organization = self.different_organization,
|
||||
name = 'two'
|
||||
name = 'two',
|
||||
software = software,
|
||||
)
|
||||
|
||||
|
||||
@ -179,6 +189,7 @@ class ViewSetBase:
|
||||
self.add_data = {
|
||||
'name': 'team_post',
|
||||
'organization': self.organization.id,
|
||||
'software': software.id,
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user