refactor(human_resources): Update Model Employee to use PyTest API Fields Render
ref: #761 #730
This commit is contained in:
14
app/human_resources/tests/unit/employee/conftest.py
Normal file
14
app/human_resources/tests/unit/employee/conftest.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from human_resources.models.employee import Employee
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture( scope = 'class')
|
||||||
|
def model(request):
|
||||||
|
|
||||||
|
request.cls.model = Employee
|
||||||
|
|
||||||
|
yield request.cls.model
|
||||||
|
|
||||||
|
del request.cls.model
|
@ -0,0 +1,37 @@
|
|||||||
|
from access.tests.unit.contact.test_unit_contact_api_fields import (
|
||||||
|
ContactAPIInheritedCases
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class EmployeeAPITestCases(
|
||||||
|
ContactAPIInheritedCases,
|
||||||
|
):
|
||||||
|
|
||||||
|
parameterized_test_data = {
|
||||||
|
'employee_number': {
|
||||||
|
'expected': int
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kwargs_create_item: dict = {
|
||||||
|
'employee_number': 12345,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class EmployeeAPIInheritedCases(
|
||||||
|
EmployeeAPITestCases,
|
||||||
|
):
|
||||||
|
|
||||||
|
kwargs_create_item: dict = None
|
||||||
|
|
||||||
|
model = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class EmployeeAPIPyTest(
|
||||||
|
EmployeeAPITestCases,
|
||||||
|
):
|
||||||
|
|
||||||
|
pass
|
@ -1,73 +0,0 @@
|
|||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
from access.tests.unit.contact.test_unit_contact_api_v2 import (
|
|
||||||
ContactAPIInheritedCases,
|
|
||||||
)
|
|
||||||
|
|
||||||
from human_resources.models.employee import Employee
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class APITestCases(
|
|
||||||
ContactAPIInheritedCases,
|
|
||||||
):
|
|
||||||
|
|
||||||
model = Employee
|
|
||||||
|
|
||||||
kwargs_item_create: dict = {
|
|
||||||
'email': 'ipfunny@unit.test',
|
|
||||||
'employee_number': 123456,
|
|
||||||
}
|
|
||||||
|
|
||||||
url_ns_name = '_api_v2_entity_sub'
|
|
||||||
|
|
||||||
|
|
||||||
def test_api_field_exists_employee_number(self):
|
|
||||||
""" Test for existance of API Field
|
|
||||||
|
|
||||||
employee_number field must exist
|
|
||||||
"""
|
|
||||||
|
|
||||||
assert 'employee_number' in self.api_data
|
|
||||||
|
|
||||||
|
|
||||||
def test_api_field_type_employee_number(self):
|
|
||||||
""" Test for type for API Field
|
|
||||||
|
|
||||||
employee_number field must be str
|
|
||||||
"""
|
|
||||||
|
|
||||||
assert type(self.api_data['employee_number']) is int
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class EmployeeAPIInheritedCases(
|
|
||||||
APITestCases,
|
|
||||||
):
|
|
||||||
"""Sub-Entity Test Cases
|
|
||||||
|
|
||||||
Test Cases for Entity models that inherit from model Employee
|
|
||||||
"""
|
|
||||||
|
|
||||||
kwargs_item_create: dict = None
|
|
||||||
|
|
||||||
model = None
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpTestData(self):
|
|
||||||
|
|
||||||
self.kwargs_item_create.update(
|
|
||||||
super().kwargs_item_create
|
|
||||||
)
|
|
||||||
|
|
||||||
super().setUpTestData()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class EmployeeAPITest(
|
|
||||||
APITestCases,
|
|
||||||
TestCase,
|
|
||||||
):
|
|
||||||
|
|
||||||
pass
|
|
Reference in New Issue
Block a user