-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(core): Unit Test for History Model Viewset
- Loading branch information
Showing
1 changed file
with
47 additions
and
48 deletions.
There are no files selected for viewing
95 changes: 47 additions & 48 deletions
95
app/core/tests/unit/test_history/test_unit_history_viewset.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,78 @@ | ||
# import pytest | ||
from django.contrib.auth.models import User | ||
from django.test import Client, TestCase | ||
|
||
# from django.contrib.auth.models import User | ||
# from django.test import Client, TestCase | ||
from rest_framework.reverse import reverse | ||
|
||
# from rest_framework.reverse import reverse | ||
from access.models import Organization | ||
|
||
# from access.models import Organization | ||
from api.tests.abstract.viewsets import ViewSetModel | ||
|
||
# from api.tests.abstract.viewsets import ViewSetModel | ||
from core.viewsets.history import ViewSet | ||
|
||
# from core.viewsets.history import ViewSet | ||
from itam.models.device import Device | ||
|
||
# from itam.models.device import Device | ||
|
||
|
||
|
||
class ViewsetCommon( | ||
ViewSetModel, | ||
): | ||
|
||
# class ViewsetCommon( | ||
# ViewSetModel, | ||
# ): | ||
viewset = ViewSet | ||
|
||
# viewset = ViewSet | ||
route_name = 'v2:_api_v2_model_history' | ||
|
||
# route_name = 'v2:_api_v2_model_history' | ||
@classmethod | ||
def setUpTestData(self): | ||
"""Setup Test | ||
# @classmethod | ||
# def setUpTestData(self): | ||
# """Setup Test | ||
1. Create an organization | ||
3. create super user | ||
""" | ||
|
||
# 1. Create an organization | ||
# 3. create super user | ||
# """ | ||
organization = Organization.objects.create(name='test_org') | ||
|
||
# organization = Organization.objects.create(name='test_org') | ||
self.organization = organization | ||
|
||
# self.organization = organization | ||
self.view_user = User.objects.create_user(username="test_view_user", password="password", is_superuser=True) | ||
|
||
# self.view_user = User.objects.create_user(username="test_view_user", password="password", is_superuser=True) | ||
device = Device.objects.create( | ||
organization = organization, | ||
name = 'dev' | ||
) | ||
|
||
# device = Device.objects.create( | ||
# organization = organization, | ||
# name = 'dev' | ||
# ) | ||
self.kwargs = { | ||
'app_label': device._meta.app_label, | ||
'model_name': device._meta.model_name, | ||
'model_id': device.id | ||
} | ||
|
||
# self.kwargs = { | ||
# 'model_class': 'device', | ||
# 'model_id': device.id | ||
# } | ||
|
||
|
||
class HistoryViewsetList( | ||
ViewsetCommon, | ||
TestCase, | ||
): | ||
|
||
# class HistoryViewsetList( | ||
# ViewsetCommon, | ||
# TestCase, | ||
# ): | ||
|
||
@classmethod | ||
def setUpTestData(self): | ||
"""Setup Test | ||
# @classmethod | ||
# def setUpTestData(self): | ||
# """Setup Test | ||
1. make list request | ||
""" | ||
|
||
# 1. make list request | ||
# """ | ||
|
||
super().setUpTestData() | ||
|
||
# super().setUpTestData() | ||
|
||
|
||
# client = Client() | ||
client = Client() | ||
|
||
# url = reverse( | ||
# self.route_name + '-list', | ||
# kwargs = self.kwargs | ||
# ) | ||
url = reverse( | ||
self.route_name + '-list', | ||
kwargs = self.kwargs | ||
) | ||
|
||
# client.force_login(self.view_user) | ||
client.force_login(self.view_user) | ||
|
||
# self.http_options_response_list = client.options(url) | ||
self.http_options_response_list = client.options(url) |