forked from Ondsel-Development/Ondsel-Lens-Addon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestFileListModel.py
104 lines (92 loc) · 3.39 KB
/
testFileListModel.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# ***********************************************************************
# * *
# * Copyright (c) 2023 Ondsel *
# * *
# ***********************************************************************
import unittest
from PySide.QtCore import Qt, QModelIndex
from DataModels import FileListModel
class TestFileListModel(unittest.TestCase):
@classmethod
def setUpClass(cls):
# Run once before all tests
cls.files = [
{
"_id": "r45zef415zef1515",
"custFileName": "part1.fcstd",
"uniqueFileName": "23ef23e-f23zefe-23zz-ef123.fcstd",
"created": "2023-01-01",
"localUrl": "something/something/",
"isFolder": True,
"versions": [
"part1.fcstd",
"part1-01012023-154023.fcbak",
"part1-01022023-101021.fcbak",
],
"currentVersion": "part1.fcstd",
},
]
@classmethod
def tearDownClass(cls):
# Run once after all tests
pass
def setUp(self):
# Run before each test
self.model = FileListModel(self.files)
def tearDown(self):
# Run after each test
pass
def test_rowCount(self):
# Test initial row count
self.assertEqual(self.model.rowCount(), 1)
# Test row count after updating data
files = [
{
"_id": "r45zef415zef1515",
"custFileName": "part1.fcstd",
"uniqueFileName": "23ef23e-f23zefe-23zz-ef123.fcstd",
"created": "2023-01-01",
"localUrl": "something/something/",
"isFolder": True,
"versions": [
"part1.fcstd",
"part1-01012023-154023.fcbak",
"part1-01022023-101021.fcbak",
],
"currentVersion": "part1.fcstd",
},
{
"_id": "abc123",
"custFileName": "part2.fcstd",
"uniqueFileName": "xyz789",
"created": "2023-01-02",
"localUrl": "something/something/else/",
"isFolder": False,
"versions": ["part2.fcstd", "part2-01012023-154023.fcbak"],
"currentVersion": "part2.fcstd",
},
]
self.model.updateData(files)
self.assertEqual(self.model.rowCount(), 2)
def test_data(self):
# Test data retrieval
index = self.model.index(0)
data = self.model.data(index, Qt.DisplayRole)
expected_data = {
"_id": "r45zef415zef1515",
"custFileName": "part1.fcstd",
"uniqueFileName": "23ef23e-f23zefe-23zz-ef123.fcstd",
"created": "2023-01-01",
"localUrl": "something/something/",
"isFolder": True,
"versions": [
"part1.fcstd",
"part1-01012023-154023.fcbak",
"part1-01022023-101021.fcbak",
],
"currentVersion": "part1.fcstd",
}
self.assertEqual(data, expected_data)
# Add more tests for other methods if needed
if __name__ == "__main__":
unittest.main()