Skip to content

Admin

Admin page for regulatory permit models.

Factories

DataUsePermissionFactory

Bases: DjangoModelFactory

data use permission factory

Models

DataUsePermission

Bases: Model

data use permission model

Test Case

DataUsePermissionTestCase

Bases: TestCase

test data use permission model

setUpTestData classmethod

setUpTestData()

setup test data

Source code in django_project/regulatory_permit/test_regulatory_permit_models.py
@classmethod
def setUpTestData(cls):
    """setup test data"""
    cls.data_use_permission = (
        regulatoryPermitFactories.DataUsePermissionFactory()
    )

test_create_data_use_permission

test_create_data_use_permission()

test creating use permission

Source code in django_project/regulatory_permit/test_regulatory_permit_models.py
def test_create_data_use_permission(self):
    """test creating use permission"""
    self.assertTrue(
        isinstance(
            self.data_use_permission,
            regulatoryPermitModels.DataUsePermission,
        )
    )
    self.assertEqual(
        regulatoryPermitModels.DataUsePermission.objects.count(), 1
    )

test_delete_data_use_permission

test_delete_data_use_permission()

test deleting use permission

Source code in django_project/regulatory_permit/test_regulatory_permit_models.py
def test_delete_data_use_permission(self):
    """test deleting use permission"""
    self.data_use_permission.delete()
    self.assertEqual(
        regulatoryPermitModels.DataUsePermission.objects.count(), 0
    )

test_unqiue_data_use_permission_name

test_unqiue_data_use_permission_name()

test unique name of use permission

Source code in django_project/regulatory_permit/test_regulatory_permit_models.py
def test_unqiue_data_use_permission_name(self):
    """test unique name of use permission"""
    try:
        (
            regulatoryPermitModels.DataUsePermission.objects.create(
                name='data use permission 0',
                description='data use permission description 0',
            )
        )

    except Exception as e:
        self.assertTrue(isinstance(e, IntegrityError))
        return

test_update_data_use_permission

test_update_data_use_permission()

test updating use permission

Source code in django_project/regulatory_permit/test_regulatory_permit_models.py
def test_update_data_use_permission(self):
    """test updating use permission"""
    self.data_use_permission.name = 'Data Use Permission #1'
    self.data_use_permission.description = (
        'Data Use Permission Description #1'
    )
    self.data_use_permission.save()
    self.assertIn(
        'Data Use Permission',
        regulatoryPermitModels.DataUsePermission.objects.get(
        id=self.data_use_permission.id).name,
    )
    self.assertIn(
        'Data Use Permission Description',
        regulatoryPermitModels.DataUsePermission.objects.get(
            id=self.data_use_permission.id
        ).description,
    )