@ -1,74 +0,0 @@
|
||||
|
||||
# import pytest
|
||||
# import unittest
|
||||
# import requests
|
||||
|
||||
# from django.test import TestCase, Client
|
||||
|
||||
# from access.models import Organization
|
||||
|
||||
# from core.models.history import History
|
||||
# from core.tests.abstract.history_entry import HistoryEntry
|
||||
# from core.tests.abstract.history_entry_parent_model import HistoryEntryParentItem
|
||||
|
||||
# from itam.models.software import Software
|
||||
|
||||
|
||||
|
||||
# class SoftwareHistory(TestCase, HistoryEntry, HistoryEntryParentItem):
|
||||
|
||||
|
||||
# model = Software
|
||||
|
||||
|
||||
# @classmethod
|
||||
# def setUpTestData(self):
|
||||
# """ Setup Test """
|
||||
|
||||
# organization = Organization.objects.create(name='test_org')
|
||||
|
||||
# self.organization = organization
|
||||
|
||||
# self.item_create = self.model.objects.create(
|
||||
# name = 'test_item_' + self.model._meta.model_name,
|
||||
# organization = self.organization
|
||||
# )
|
||||
|
||||
|
||||
# self.history_create = History.objects.get(
|
||||
# action = int(History.Actions.ADD),
|
||||
# item_pk = self.item_create.pk,
|
||||
# item_class = self.model._meta.model_name,
|
||||
# )
|
||||
|
||||
# self.item_change = self.item_create
|
||||
# self.item_change.name = 'test_item_' + self.model._meta.model_name + '_changed'
|
||||
# self.item_change.save()
|
||||
|
||||
# self.field_after_expected_value = '{"name": "test_item_' + self.model._meta.model_name + '_changed"}'
|
||||
|
||||
# self.history_change = History.objects.get(
|
||||
# action = int(History.Actions.UPDATE),
|
||||
# item_pk = self.item_change.pk,
|
||||
# item_class = self.model._meta.model_name,
|
||||
# )
|
||||
|
||||
# self.item_delete = self.model.objects.create(
|
||||
# name = 'test_item_delete_' + self.model._meta.model_name,
|
||||
# organization = self.organization
|
||||
# )
|
||||
|
||||
|
||||
# self.deleted_pk = self.item_delete.pk
|
||||
|
||||
# self.item_delete.delete()
|
||||
|
||||
# self.history_delete = History.objects.filter(
|
||||
# item_pk = self.deleted_pk,
|
||||
# item_class = self.model._meta.model_name,
|
||||
# )
|
||||
|
||||
# self.history_delete_children = History.objects.filter(
|
||||
# item_parent_pk = self.deleted_pk,
|
||||
# item_parent_class = self.model._meta.model_name,
|
||||
# )
|
@ -1,94 +0,0 @@
|
||||
# import pytest
|
||||
# import unittest
|
||||
# import requests
|
||||
|
||||
# from django.contrib.auth.models import AnonymousUser, User
|
||||
# from django.contrib.contenttypes.models import ContentType
|
||||
# from django.test import TestCase, Client
|
||||
|
||||
# from access.models import Organization, Team, TeamUsers, Permission
|
||||
|
||||
# from core.tests.abstract.history_permissions import HistoryPermissions
|
||||
|
||||
# from itam.models.software import Software
|
||||
|
||||
|
||||
|
||||
# class SoftwareHistoryPermissions(TestCase, HistoryPermissions):
|
||||
|
||||
|
||||
# item_model = Software
|
||||
|
||||
|
||||
# @classmethod
|
||||
# def setUpTestData(self):
|
||||
# """Setup Test
|
||||
|
||||
# 1. Create an organization for user and item
|
||||
# 2. create an organization that is different to item
|
||||
# 3. Create a device
|
||||
# 4. Add history device history entry as item
|
||||
# 5. create a user
|
||||
# 6. create user in different organization (with the required permission)
|
||||
# """
|
||||
|
||||
# organization = Organization.objects.create(name='test_org')
|
||||
|
||||
# self.organization = organization
|
||||
|
||||
# different_organization = Organization.objects.create(name='test_different_organization')
|
||||
|
||||
# self.item = self.item_model.objects.create(
|
||||
# organization=organization,
|
||||
# name = 'deviceone'
|
||||
# )
|
||||
|
||||
# self.history_model_name = self.item._meta.model_name
|
||||
|
||||
# self.history = self.model.objects.get(
|
||||
# item_pk = self.item.id,
|
||||
# item_class = self.item._meta.model_name,
|
||||
# action = self.model.Actions.ADD,
|
||||
# )
|
||||
|
||||
# view_permissions = Permission.objects.get(
|
||||
# codename = 'view_' + self.model._meta.model_name,
|
||||
# content_type = ContentType.objects.get(
|
||||
# app_label = self.model._meta.app_label,
|
||||
# model = self.model._meta.model_name,
|
||||
# )
|
||||
# )
|
||||
|
||||
# view_team = Team.objects.create(
|
||||
# team_name = 'view_team',
|
||||
# organization = organization,
|
||||
# )
|
||||
|
||||
# view_team.permissions.set([view_permissions])
|
||||
|
||||
|
||||
# self.no_permissions_user = User.objects.create_user(username="test_no_permissions", password="password")
|
||||
|
||||
|
||||
# self.view_user = User.objects.create_user(username="test_user_view", password="password")
|
||||
# teamuser = TeamUsers.objects.create(
|
||||
# team = view_team,
|
||||
# user = self.view_user
|
||||
# )
|
||||
|
||||
# self.different_organization_user = User.objects.create_user(username="test_different_organization_user", password="password")
|
||||
|
||||
|
||||
# different_organization_team = Team.objects.create(
|
||||
# team_name = 'different_organization_team',
|
||||
# organization = different_organization,
|
||||
# )
|
||||
|
||||
# different_organization_team.permissions.set([
|
||||
# view_permissions,
|
||||
# ])
|
||||
|
||||
# TeamUsers.objects.create(
|
||||
# team = different_organization_team,
|
||||
# user = self.different_organization_user
|
||||
# )
|
@ -0,0 +1,43 @@
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.test import TestCase
|
||||
|
||||
from core.tests.abstract.test_unit_model_history_api_v2 import PrimaryModelHistoryAPI
|
||||
|
||||
from itam.models.software_history import Software, SoftwareHistory
|
||||
|
||||
|
||||
|
||||
class ModelHistoryAPI(
|
||||
PrimaryModelHistoryAPI,
|
||||
TestCase,
|
||||
):
|
||||
|
||||
audit_model = Software
|
||||
|
||||
model = SoftwareHistory
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(self):
|
||||
|
||||
super().setUpTestData()
|
||||
|
||||
self.audit_object = self.audit_model.objects.create(
|
||||
organization = self.organization,
|
||||
name = 'one',
|
||||
)
|
||||
|
||||
self.history_entry = self.model.objects.create(
|
||||
organization = self.audit_object.organization,
|
||||
action = self.model.Actions.ADD,
|
||||
user = self.view_user,
|
||||
before = {},
|
||||
after = {},
|
||||
content_type = ContentType.objects.get(
|
||||
app_label = self.audit_object._meta.app_label,
|
||||
model = self.audit_object._meta.model_name,
|
||||
),
|
||||
model = self.audit_object,
|
||||
)
|
||||
|
||||
|
||||
self.make_request()
|
Reference in New Issue
Block a user