This repository was archived by the owner on Mar 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtestVersionModel.py
75 lines (59 loc) · 2.16 KB
/
testVersionModel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# ***********************************************************************
# * *
# * Copyright (c) 2023 Ondsel *
# * *
# ***********************************************************************
import unittest
from PySide.QtCore import Qt
from VersionModel import LocalVersionModel, OndselVersionModel
import pprint
import shutil
import os
import time
import FreeCAD as App
class TestLocalVersionModel(unittest.TestCase):
@classmethod
def setUpClass(cls):
os.mkdir("test_dir")
pg = App.ParamGet("User parameter:BaseApp/Preferences/Document")
cls.backupcount = pg.GetInt("CountBackupFiles")
pg.SetInt("CountBackupFiles", 3)
cls.create_file("test_dir/file1.FCStd")
cls.filename = "test_dir/file1.FCStd"
cls.model = LocalVersionModel(cls.filename)
@classmethod
def tearDownClass(cls):
# Remove the test directory and all its contents
shutil.rmtree("test_dir")
pg = App.ParamGet("User parameter:BaseApp/Preferences/Document")
pg.SetInt("CountBackupFiles", cls.backupcount)
@classmethod
def create_file(self, file_path):
doc = App.newDocument()
doc.saveAs(file_path)
doc.saveAs(file_path)
doc.saveAs(file_path)
App.closeDocument(doc.Name)
time.sleep(1)
def test_00_initial_state(self):
pprint.pprint(self.model.dump())
self.assertEqual(self.model.rowCount(), 2)
self.assertEqual(self.model.columnCount(None), 2)
def test_10_add_version(self):
doc = App.openDocument(self.filename)
doc.save()
doc.save()
time.sleep(1)
self.assertEqual(self.model.rowCount(), 3)
class TestOndselVersionModel(unittest.TestCase):
@classmethod
def setUpClass(cls):
modelID = 9999
cls.model = OndselVersionModel(modelID)
@classmethod
def tearDownClass(cls):
pass
def test_00_initial_state(self):
self.assertTrue(True)
if __name__ == "__main__":
unittest.main()