48
app/access/tests/team_user/test_team_user_functions.py
Normal file
48
app/access/tests/team_user/test_team_user_functions.py
Normal file
@ -0,0 +1,48 @@
|
||||
from django.test import TestCase
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
import unittest
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import ValidationError
|
||||
from access.models import Organization, Team
|
||||
|
||||
|
||||
# @pytest.fixture
|
||||
# def organization() -> Organization:
|
||||
# return Organization.objects.create(
|
||||
# name='Test org',
|
||||
# )
|
||||
|
||||
|
||||
# @pytest.fixture
|
||||
# def team() -> Team:
|
||||
# return Team.objects.create(
|
||||
# name='Team one',
|
||||
# organization = Organization.objects.create(
|
||||
# name='Test org',
|
||||
# ),
|
||||
# )
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_user_permission_add_team_manager(user):
|
||||
"""Ensure user can be added when user is team manager
|
||||
|
||||
user requires permissions team view and user add
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_user_permission_delete_team_manager(user):
|
||||
"""Ensure user can be deleted when user is team manager
|
||||
|
||||
user requires permissions team view and user delete
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
# is_superuser to be able to view, add, change, delete for all objects
|
||||
|
@ -1,99 +0,0 @@
|
||||
from django.conf import settings
|
||||
from django.shortcuts import reverse
|
||||
from django.test import TestCase, Client
|
||||
|
||||
import pytest
|
||||
import unittest
|
||||
import requests
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import ValidationError
|
||||
from access.models import Organization
|
||||
|
||||
# class Test_app_structure_auth(unittest.TestCase):
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user() -> User:
|
||||
return User.objects.create_user(username="testuser", password="testpassword")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def organization() -> Organization:
|
||||
return Organization.objects.create(
|
||||
name='Test org',
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_require_login_organizations():
|
||||
"""Some docstring defining what the test is checking."""
|
||||
client = Client()
|
||||
url = reverse('Access:Organizations')
|
||||
|
||||
response = client.get(url)
|
||||
|
||||
assert response.status_code == 302 and response.url.startswith('/account/login')
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_organizations_permission_change(user):
|
||||
"""ensure user with permission can change organization
|
||||
|
||||
Args:
|
||||
user (_type_): _description_
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_organizations_permission_delete_denied(user):
|
||||
"""ensure non-admin user cant delete organization
|
||||
|
||||
Args:
|
||||
user (_type_): _description_
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_team_permission_add_in_org(user):
|
||||
"""ensure user with add permission to an organization can add team
|
||||
|
||||
Args:
|
||||
user (_type_): _description_
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_team_permission_add_not_in_org(user):
|
||||
"""ensure user with add permission to an organization can add team
|
||||
|
||||
Args:
|
||||
user (_type_): _description_
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_team_permission_change(user):
|
||||
"""ensure user can change a team
|
||||
|
||||
Args:
|
||||
user (_type_): _description_
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_team_permission_delete(user):
|
||||
"""ensure user can delete a team
|
||||
|
||||
Args:
|
||||
user (_type_): _description_
|
||||
"""
|
||||
pass
|
||||
|
||||
|
@ -1,205 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
import unittest
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import ValidationError
|
||||
from access.models import Organization, Team
|
||||
|
||||
|
||||
# @pytest.fixture
|
||||
# def organization() -> Organization:
|
||||
# return Organization.objects.create(
|
||||
# name='Test org',
|
||||
# )
|
||||
|
||||
|
||||
# @pytest.fixture
|
||||
# def team() -> Team:
|
||||
# return Team.objects.create(
|
||||
# name='Team one',
|
||||
# organization = Organization.objects.create(
|
||||
# name='Test org',
|
||||
# ),
|
||||
# )
|
||||
|
||||
|
||||
######################################################################
|
||||
# SoF for loop for tests
|
||||
# for test in ['organization','team', 'users']
|
||||
#
|
||||
# permissions for each item as per the action plus view of the parent item
|
||||
######################################################################
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_organization_view(user):
|
||||
"""User of organization can view
|
||||
|
||||
user requires permissions organization view
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_organization_no_view(user):
|
||||
"""User not part of organization cant view
|
||||
|
||||
user requires permissions organization view
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
###################################################################
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_team_permission_view(user):
|
||||
""" Ensure team can be viewed when user has correct permissions
|
||||
|
||||
user requires permissions organization view and team view
|
||||
"""
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_team_permission_no_view(user):
|
||||
""" Ensure team can't be viewed when user is missing permissions
|
||||
|
||||
user requires permissions organization view and team view
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_team_permission_add(user):
|
||||
"""Ensure team can be added when user has correct permissions
|
||||
|
||||
user requires permissions organization view and team add
|
||||
"""
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_team_permission_no_view(user):
|
||||
"""Ensure team can't be added when user is missing permissions
|
||||
|
||||
user requires permissions organization view and team add
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_team_permission_change(user):
|
||||
"""Ensure team can be changed when user has correct permissions
|
||||
|
||||
user requires permissions organization view and team change
|
||||
"""
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_team_permission_no_change(user):
|
||||
"""Ensure team can't be change when user is missing permissions
|
||||
|
||||
user requires permissions organization view and team change
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_team_permission_delete(user):
|
||||
"""Ensure team can be deleted when user has correct permissions
|
||||
|
||||
user requires permissions organization view and team delete
|
||||
"""
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_team_permission_no_delete(user):
|
||||
"""Ensure team can't be deleted when user is missing permissions
|
||||
|
||||
user requires permissions organization view and team delete
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
###################################################################
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_user_permission_add(user):
|
||||
"""Ensure user can be added when user has correct permissions
|
||||
|
||||
user requires permissions team view and user add
|
||||
"""
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_user_permission_no_add(user):
|
||||
"""Ensure user can't be added when user is missing permissions
|
||||
|
||||
user requires permissions team view and user add
|
||||
"""
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_user_permission_add_team_manager(user):
|
||||
"""Ensure user can be added when user is team manager
|
||||
|
||||
user requires permissions team view and user add
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_user_permission_change(user):
|
||||
"""Ensure user can be changed when user has correct permissions
|
||||
|
||||
user requires permissions team view and user change
|
||||
"""
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_user_permission_no_change(user):
|
||||
"""Ensure user can't be change when user is missing permissions
|
||||
|
||||
user requires permissions team view and user change
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_user_permission_delete(user):
|
||||
"""Ensure user can be deleted when user has correct permissions
|
||||
|
||||
user requires permissions team view and user delete
|
||||
"""
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_user_permission_no_delete(user):
|
||||
"""Ensure user can't be deleted when user is missing permissions
|
||||
|
||||
user requires permissions team view and user delete
|
||||
"""
|
||||
pass
|
||||
|
||||
@pytest.mark.skip(reason="to be written")
|
||||
def test_authorization_user_permission_delete_team_manager(user):
|
||||
"""Ensure user can be deleted when user is team manager
|
||||
|
||||
user requires permissions team view and user delete
|
||||
"""
|
||||
pass
|
||||
|
||||
######################################################################
|
||||
# EoF for loop for tests
|
||||
# for test in ['organization','team']
|
||||
######################################################################
|
||||
|
||||
# is_superuser to be able to view, add, change, delete for all objects
|
||||
|
@ -1,41 +0,0 @@
|
||||
from app import settings
|
||||
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
class Test_aa_settings_default(unittest.TestCase):
|
||||
|
||||
# @pytest.mark.django_db
|
||||
# def test_setting_api_disabled_default(self):
|
||||
# """ As the API is only partially developed, it must be disabled.
|
||||
|
||||
# This test can be removed when the API has been fully developed and functioning as it should.
|
||||
# """
|
||||
|
||||
# assert not settings.API_ENABLED
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_setting_login_required_default(self):
|
||||
""" By default login should be required
|
||||
"""
|
||||
|
||||
assert settings.LOGIN_REQUIRED
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_setting_use_tz_default(self):
|
||||
""" Ensure that 'USE_TZ = True' is within settings
|
||||
"""
|
||||
|
||||
assert settings.USE_TZ
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_setting_debug_off(self):
|
||||
""" Ensure that debug is off within settings by default
|
||||
|
||||
Debug is only required during development with this setting must always remain off within the committed code.
|
||||
"""
|
||||
|
||||
assert not settings.DEBUG
|
@ -1,38 +0,0 @@
|
||||
from django.conf import settings
|
||||
from django.shortcuts import reverse
|
||||
from django.test import TestCase, Client
|
||||
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
from access.models import Organization
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_setting_login_required():
|
||||
"""Some docstring defining what the test is checking."""
|
||||
client = Client()
|
||||
url = reverse('home')
|
||||
# client.force_login(user)
|
||||
# default_settings = settings
|
||||
settings.LOGIN_REQUIRED = True
|
||||
|
||||
response = client.get(url)
|
||||
|
||||
assert response.status_code == 302
|
||||
|
||||
# settings = default_settings
|
||||
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_setting_login_required_not():
|
||||
"""Some docstring defining what the test is checking."""
|
||||
client = Client()
|
||||
url = reverse('home')
|
||||
|
||||
settings.LOGIN_REQUIRED = False
|
||||
|
||||
response = client.get(url)
|
||||
|
||||
assert response.status_code == 200
|
66
app/app/tests/test_settings.py
Normal file
66
app/app/tests/test_settings.py
Normal file
@ -0,0 +1,66 @@
|
||||
from django.conf import settings as django_settings
|
||||
from django.shortcuts import reverse
|
||||
from django.test import TestCase, Client
|
||||
|
||||
from app import settings
|
||||
|
||||
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
|
||||
class SettingsDefault(TestCase):
|
||||
""" Test Settings file default values """
|
||||
|
||||
|
||||
def test_setting_default_login_required(self):
|
||||
""" By default login should be required
|
||||
"""
|
||||
|
||||
assert settings.LOGIN_REQUIRED
|
||||
|
||||
|
||||
def test_setting_default_use_tz(self):
|
||||
""" Ensure that 'USE_TZ = True' is within settings
|
||||
"""
|
||||
|
||||
assert settings.USE_TZ
|
||||
|
||||
|
||||
def test_setting_default_debug_off(self):
|
||||
""" Ensure that debug is off within settings by default
|
||||
|
||||
Debug is only required during development with this setting must always remain off within the committed code.
|
||||
"""
|
||||
|
||||
assert not settings.DEBUG
|
||||
|
||||
|
||||
|
||||
class SettingsValues(TestCase):
|
||||
""" Test Each setting that offers different functionality """
|
||||
|
||||
|
||||
def test_setting_value_login_required(self):
|
||||
"""Some docstring defining what the test is checking."""
|
||||
client = Client()
|
||||
url = reverse('home')
|
||||
|
||||
django_settings.LOGIN_REQUIRED = True
|
||||
|
||||
response = client.get(url)
|
||||
|
||||
assert response.status_code == 302 and response.url.startswith('/account/login')
|
||||
|
||||
|
||||
|
||||
def test_setting_value_login_required_not(self):
|
||||
"""Some docstring defining what the test is checking."""
|
||||
client = Client()
|
||||
url = reverse('home')
|
||||
|
||||
django_settings.LOGIN_REQUIRED = False
|
||||
|
||||
response = client.get(url)
|
||||
|
||||
assert response.status_code == 200
|
Reference in New Issue
Block a user