15
.vscode/launch.json
vendored
15
.vscode/launch.json
vendored
@ -88,6 +88,21 @@
|
|||||||
],
|
],
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"justMyCode": false
|
"justMyCode": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Python Debugger: Local Attach",
|
||||||
|
"type": "debugpy",
|
||||||
|
"request": "attach",
|
||||||
|
"connect": {
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 5678
|
||||||
|
},
|
||||||
|
"pathMappings": [
|
||||||
|
{
|
||||||
|
"localRoot": "${workspaceFolder}",
|
||||||
|
"remoteRoot": "."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
}
|
}
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -4,6 +4,10 @@
|
|||||||
"cSpell.enableFiletypes": [
|
"cSpell.enableFiletypes": [
|
||||||
"!python"
|
"!python"
|
||||||
],
|
],
|
||||||
|
"python.testing.pytestArgs": [
|
||||||
|
"--override-ini", "addopts=",
|
||||||
|
"app",
|
||||||
|
],
|
||||||
"python.testing.unittestEnabled": false,
|
"python.testing.unittestEnabled": false,
|
||||||
"python.testing.pytestEnabled": true,
|
"python.testing.pytestEnabled": true,
|
||||||
"testing.coverageToolbarEnabled": true,
|
"testing.coverageToolbarEnabled": true,
|
||||||
|
@ -2,6 +2,7 @@ import pytest
|
|||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from django.apps import apps
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.urls.exceptions import NoReverseMatch
|
from django.urls.exceptions import NoReverseMatch
|
||||||
@ -633,7 +634,7 @@ class TenancyObjectTest(
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(self):
|
def setUpTestData(self):
|
||||||
|
|
||||||
class TestModel(TenancyObject):
|
class MockTenancyObjectModel(TenancyObject):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
@ -641,9 +642,23 @@ class TenancyObjectTest(
|
|||||||
|
|
||||||
verbose_name = 'Test Model'
|
verbose_name = 'Test Model'
|
||||||
|
|
||||||
|
self.model = MockTenancyObjectModel
|
||||||
|
|
||||||
self.model = TestModel
|
|
||||||
self.item = TestModel()
|
self.item = MockTenancyObjectModel()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(self):
|
||||||
|
|
||||||
|
self.item = None
|
||||||
|
|
||||||
|
del apps.all_models['access']['mocktenancyobjectmodel']
|
||||||
|
|
||||||
|
self.model = None
|
||||||
|
|
||||||
|
super().tearDownClass()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,6 +9,14 @@ from access.models.organization import Organization
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_configure(config):
|
||||||
|
|
||||||
|
print("\n--- Pytest Launch Arguments ---")
|
||||||
|
print(f"Command-line arguments: {config.invocation_params.args}")
|
||||||
|
print(f"Config file options: {config.getini('addopts')}")
|
||||||
|
print("\n-------------------------------")
|
||||||
|
|
||||||
|
|
||||||
def pytest_pycollect_makeitem(collector, name, obj):
|
def pytest_pycollect_makeitem(collector, name, obj):
|
||||||
"""PyTest Test Creation
|
"""PyTest Test Creation
|
||||||
|
|
||||||
@ -87,7 +95,7 @@ def create_model(request, django_db_blocker):
|
|||||||
|
|
||||||
with django_db_blocker.unblock():
|
with django_db_blocker.unblock():
|
||||||
|
|
||||||
request.cls.item.delete()
|
item.delete()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from django.apps import apps
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
@ -134,7 +135,7 @@ class SaveHistoryMixinTest(
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(self):
|
def setUpTestData(self):
|
||||||
|
|
||||||
class MockModel(self.model):
|
class MockSaveHistoryModel(SaveHistory):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
@ -142,7 +143,15 @@ class SaveHistoryMixinTest(
|
|||||||
|
|
||||||
verbose_name = 'unit test'
|
verbose_name = 'unit test'
|
||||||
|
|
||||||
self.item = MockModel()
|
self.item = MockSaveHistoryModel()
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(self):
|
||||||
|
|
||||||
|
self.item = None
|
||||||
|
|
||||||
|
del apps.all_models['core']['mocksavehistorymodel']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,37 +23,36 @@ class APITestCases(
|
|||||||
@pytest.fixture( scope = 'class')
|
@pytest.fixture( scope = 'class')
|
||||||
def setup_model(self, request, django_db_blocker,
|
def setup_model(self, request, django_db_blocker,
|
||||||
model,
|
model,
|
||||||
organization_one,
|
|
||||||
):
|
):
|
||||||
|
|
||||||
with django_db_blocker.unblock():
|
with django_db_blocker.unblock():
|
||||||
|
|
||||||
request.cls.entity_user = Entity.objects.create(
|
request.cls.entity_user = Entity.objects.create(
|
||||||
organization = organization_one,
|
organization = request.cls.organization,
|
||||||
model_notes = 'asdas'
|
model_notes = 'asdas'
|
||||||
)
|
)
|
||||||
|
|
||||||
project = Project.objects.create(
|
project = Project.objects.create(
|
||||||
organization = organization_one,
|
organization = request.cls.organization,
|
||||||
name = 'project'
|
name = 'project'
|
||||||
)
|
)
|
||||||
|
|
||||||
parent_ticket = request.cls.model.objects.create(
|
parent_ticket = request.cls.model.objects.create(
|
||||||
organization = organization_one,
|
organization = request.cls.organization,
|
||||||
title = 'parent ticket',
|
title = 'parent ticket',
|
||||||
description = 'bla bla',
|
description = 'bla bla',
|
||||||
opened_by = request.cls.view_user,
|
opened_by = request.cls.view_user,
|
||||||
)
|
)
|
||||||
|
|
||||||
project_milestone = ProjectMilestone.objects.create(
|
project_milestone = ProjectMilestone.objects.create(
|
||||||
organization = organization_one,
|
organization = request.cls.organization,
|
||||||
name = 'project milestone one',
|
name = 'project milestone one',
|
||||||
project = project
|
project = project
|
||||||
)
|
)
|
||||||
|
|
||||||
request.cls.kwargs_create_item.update({
|
request.cls.kwargs_create_item.update({
|
||||||
'category': TicketCategory.objects.create(
|
'category': TicketCategory.objects.create(
|
||||||
organization = organization_one,
|
organization = request.cls.organization,
|
||||||
name = 'a category'
|
name = 'a category'
|
||||||
),
|
),
|
||||||
'opened_by': request.cls.view_user,
|
'opened_by': request.cls.view_user,
|
||||||
@ -78,12 +77,12 @@ class APITestCases(
|
|||||||
|
|
||||||
request.cls.entity_user.delete()
|
request.cls.entity_user.delete()
|
||||||
|
|
||||||
|
parent_ticket.delete()
|
||||||
|
|
||||||
project_milestone.delete()
|
project_milestone.delete()
|
||||||
|
|
||||||
project.delete()
|
project.delete()
|
||||||
|
|
||||||
parent_ticket.delete()
|
|
||||||
|
|
||||||
request.cls.kwargs_create_item['category'].delete()
|
request.cls.kwargs_create_item['category'].delete()
|
||||||
|
|
||||||
if 'ticket_model' in request.cls.url_view_kwargs:
|
if 'ticket_model' in request.cls.url_view_kwargs:
|
||||||
|
@ -32,8 +32,6 @@ class ProjectMilestonePermissions(TestCase, ModelPermissions):
|
|||||||
|
|
||||||
url_name_delete = '_project_milestone_delete'
|
url_name_delete = '_project_milestone_delete'
|
||||||
|
|
||||||
url_delete_response = reverse('Project Management:_project_view', kwargs={'pk': 1}) + '?tab=milestones'
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(self):
|
def setUpTestData(self):
|
||||||
"""Setup Test
|
"""Setup Test
|
||||||
@ -57,6 +55,8 @@ class ProjectMilestonePermissions(TestCase, ModelPermissions):
|
|||||||
organization = self.organization
|
organization = self.organization
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.url_delete_response = reverse('Project Management:_project_view', kwargs={'pk': self.project.id}) + '?tab=milestones'
|
||||||
|
|
||||||
self.item = self.model.objects.create(
|
self.item = self.model.objects.create(
|
||||||
name = 'test_item_' + self.model._meta.model_name,
|
name = 'test_item_' + self.model._meta.model_name,
|
||||||
organization = self.organization,
|
organization = self.organization,
|
||||||
|
6
makefile
6
makefile
@ -39,14 +39,14 @@ docs: docs-lint
|
|||||||
lint: markdown-mkdocs-lint
|
lint: markdown-mkdocs-lint
|
||||||
|
|
||||||
test:
|
test:
|
||||||
pytest -s --cov --cov-branch --cov-report term --cov-report xml:artifacts/coverage_unit_functional.xml --cov-report html:artifacts/coverage/unit_functional/ --junit-xml=artifacts/unit_functional.JUnit.xml app/**/tests/unit app/**/tests/functional
|
pytest --cov-report xml:artifacts/coverage_unit_functional.xml --cov-report html:artifacts/coverage/unit_functional/ --junit-xml=artifacts/unit_functional.JUnit.xml app/**/tests/unit app/**/tests/functional
|
||||||
|
|
||||||
test-functional:
|
test-functional:
|
||||||
pytest -s --cov --cov-branch --cov-report term --cov-report xml:artifacts/coverage_functional.xml --cov-report html:artifacts/coverage/functional/ --junit-xml=artifacts/functional.JUnit.xml app/**/tests/functional
|
pytest --cov-report xml:artifacts/coverage_functional.xml --cov-report html:artifacts/coverage/functional/ --junit-xml=artifacts/functional.JUnit.xml app/**/tests/functional
|
||||||
|
|
||||||
|
|
||||||
test-unit:
|
test-unit:
|
||||||
pytest -s --cov --cov-branch --cov-report term --cov-report xml:artifacts/coverage_unit.xml --cov-report html:artifacts/coverage/unit/ --junit-xml=artifacts/unit.JUnit.xml app/**/tests/unit
|
pytest --cov-report xml:artifacts/coverage_unit.xml --cov-report html:artifacts/coverage/unit/ --junit-xml=artifacts/unit.JUnit.xml app/**/tests/unit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ disable = [
|
|||||||
enable = [
|
enable = [
|
||||||
"variables"
|
"variables"
|
||||||
]
|
]
|
||||||
|
|
||||||
source-roots = [
|
source-roots = [
|
||||||
"app/"
|
"app/"
|
||||||
]
|
]
|
||||||
@ -16,11 +15,15 @@ allow-global-unused-variables = true
|
|||||||
init-import = true
|
init-import = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
|
|
||||||
addopts = '-s app'
|
addopts = '--cov --cov-branch --cov-report term --tb=long --verbosity=2 --full-trace --showlocals app'
|
||||||
|
|
||||||
|
|
||||||
DJANGO_SETTINGS_MODULE = 'app.settings'
|
DJANGO_SETTINGS_MODULE = 'app.settings'
|
||||||
|
|
||||||
|
junit_family = 'xunit2'
|
||||||
# -- recommended but optional:
|
# -- recommended but optional:
|
||||||
# python_files = 'tests.py test_*.py *_tests.py'
|
# python_files = 'tests.py test_*.py *_tests.py'
|
||||||
log_cli = true
|
log_cli = true
|
||||||
|
Reference in New Issue
Block a user