R: Test Inheritance and update initial data

This commit is contained in:
Ivan 2024-08-02 15:15:53 +03:00
parent e96206b7db
commit 95d38cea7c
4 changed files with 8893 additions and 5448 deletions

View File

@ -1,4 +1,5 @@
''' Tests for Django Models. ''' ''' Tests for Django Models. '''
from .t_Argument import * from .t_Argument import *
from .t_Inheritance import *
from .t_Operation import * from .t_Operation import *
from .t_Substitution import * from .t_Substitution import *

View File

@ -0,0 +1,51 @@
''' Testing models: Inheritance. '''
from django.test import TestCase
from apps.oss.models import Inheritance, Operation, OperationSchema, OperationType
from apps.rsform.models import Constituenta, RSForm
class TestInheritance(TestCase):
''' Testing Inheritance model. '''
def setUp(self):
self.oss = OperationSchema.create(alias='T1')
self.ks1 = RSForm.create(title='Test1', alias='KS1')
self.ks2 = RSForm.create(title='Test2', alias='KS2')
self.operation = Operation.objects.create(
oss=self.oss.model,
alias='KS1',
operation_type=OperationType.INPUT,
result=self.ks1.model
)
self.ks1_x1 = self.ks1.insert_new('X1')
self.ks2_x1 = self.ks2.insert_new('X1')
self.inheritance = Inheritance.objects.create(
operation=self.operation,
parent=self.ks1_x1,
child=self.ks2_x1
)
def test_str(self):
testStr = f'{self.ks1_x1} -> {self.ks2_x1}'
self.assertEqual(str(self.inheritance), testStr)
def test_cascade_delete_operation(self):
self.assertEqual(Inheritance.objects.count(), 1)
self.operation.delete()
self.assertEqual(Inheritance.objects.count(), 0)
def test_cascade_delete_parent(self):
self.assertEqual(Inheritance.objects.count(), 1)
self.ks1_x1.delete()
self.assertEqual(Inheritance.objects.count(), 0)
def test_cascade_delete_child(self):
self.assertEqual(Inheritance.objects.count(), 1)
self.ks2_x1.delete()
self.assertEqual(Inheritance.objects.count(), 0)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 122 KiB