test(devops): Adjust functional model test to use fixture kwargs
ref: #883 #882
This commit is contained in:
@ -8,8 +8,6 @@ from core.tests.functional.centurion_abstract.test_functional_centurion_abstract
|
||||
CenturionAbstractModelInheritedCases
|
||||
)
|
||||
|
||||
from devops.models.git_group import GitGroup
|
||||
|
||||
|
||||
|
||||
@pytest.mark.model_gitgroup
|
||||
@ -18,16 +16,6 @@ class GitGroupModelTestCases(
|
||||
):
|
||||
|
||||
|
||||
kwargs_create_item = {
|
||||
'parent_group': None,
|
||||
'provider': GitGroup.GitProvider.GITHUB,
|
||||
'provider_pk': 1,
|
||||
'name': 'a name',
|
||||
'path': 'a_path',
|
||||
'description': 'a random bit of text.'
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.skip( reason = 'test must be as part of serializer and viewset tests, not model' )
|
||||
def test_model_create_has_history_entry(self, model_contenttype, created_model, model):
|
||||
"""Model Created
|
||||
@ -39,22 +27,22 @@ class GitGroupModelTestCases(
|
||||
pass
|
||||
|
||||
|
||||
def test_model_create_with_parent_sets_tenancy(self, created_model, model):
|
||||
def test_model_create_with_parent_sets_tenancy(self, created_model, model, model_kwargs):
|
||||
"""Model Created
|
||||
|
||||
Ensure that the model when created with a parent git group, that its
|
||||
tenancy is set to that of the parent group
|
||||
"""
|
||||
|
||||
kwargs_create_item = self.kwargs_create_item.copy()
|
||||
kwargs = model_kwargs.copy()
|
||||
|
||||
kwargs_create_item['provider'] = model.GitProvider.GITLAB
|
||||
kwargs['provider'] = model.GitProvider.GITLAB
|
||||
|
||||
del kwargs_create_item['organization']
|
||||
kwargs_create_item['parent_group'] = created_model
|
||||
del kwargs['organization']
|
||||
kwargs['parent_group'] = created_model
|
||||
|
||||
child_group = model.objects.create(
|
||||
**kwargs_create_item
|
||||
**kwargs
|
||||
)
|
||||
|
||||
organization = child_group.organization
|
||||
@ -65,7 +53,7 @@ class GitGroupModelTestCases(
|
||||
|
||||
|
||||
|
||||
def test_model_create_with_parent_exception_github(self, created_model, model):
|
||||
def test_model_create_with_parent_exception_github(self, created_model, model, model_kwargs):
|
||||
"""Model Created
|
||||
|
||||
Ensure that the model when created with a parent git group, with the
|
||||
@ -73,17 +61,17 @@ class GitGroupModelTestCases(
|
||||
can't have parents/nesting.
|
||||
"""
|
||||
|
||||
kwargs_create_item = self.kwargs_create_item.copy()
|
||||
kwargs = model_kwargs.copy()
|
||||
|
||||
kwargs_create_item['provider'] = model.GitProvider.GITHUB
|
||||
kwargs['provider'] = model.GitProvider.GITHUB
|
||||
|
||||
del kwargs_create_item['organization']
|
||||
kwargs_create_item['parent_group'] = created_model
|
||||
del kwargs['organization']
|
||||
kwargs['parent_group'] = created_model
|
||||
|
||||
with pytest.raises( ValidationError ) as e:
|
||||
|
||||
child_group = model.objects.create(
|
||||
**kwargs_create_item
|
||||
**kwargs
|
||||
)
|
||||
|
||||
child_group.delete()
|
||||
@ -91,7 +79,6 @@ class GitGroupModelTestCases(
|
||||
assert e.value.error_dict['__all__'][0].code == 'no_parent_for_github_group'
|
||||
|
||||
|
||||
|
||||
class GitGroupModelInheritedCases(
|
||||
GitGroupModelTestCases,
|
||||
):
|
||||
@ -99,6 +86,7 @@ class GitGroupModelInheritedCases(
|
||||
|
||||
|
||||
|
||||
@pytest.mark.module_access
|
||||
class GitGroupModelPyTest(
|
||||
GitGroupModelTestCases,
|
||||
):
|
||||
|
Reference in New Issue
Block a user