-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtestLinkModel.py
117 lines (93 loc) · 3.38 KB
/
testLinkModel.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
105
106
107
108
109
110
111
112
113
114
115
116
117
# ***********************************************************************
# * *
# * Copyright (c) 2023 Ondsel *
# * *
# ***********************************************************************
import unittest
from PySide.QtCore import Qt
from LinkModel import ShareLinkModel
from APIClient import APIClient
import pprint
import os
import time
import config
"""
These unittests are currently hitting the server.
Useful for developing but really should be rewritten to mock the server response
and only test the data model.
Also, an assert here and there wouldn't hurt.
"""
class TestLinkModel(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.base_url = config.base_url
cls.lens_url = config.lens_url
cls.username = config.username
cls.password = config.password
cls.access_token = None
cls.api_client = APIClient(
cls.username, cls.password, cls.base_url, cls.lens_url
)
testfile = "testshape.FCStd"
url, basename = os.path.split(testfile)
created_time = os.path.getctime(testfile)
modified_time = os.path.getmtime(testfile)
fileData = {
"custFileName": basename,
"isFolder": False,
"versions": [basename],
"currentVersion": basename,
"createdAt": created_time,
"updatedAt": modified_time,
"status": "Untracked",
"shouldStartObjGeneration": True,
}
result = cls.api_client.uploadFileToServer(fileData, url)
fileData["uniqueFileName"] = result["uniqueFileName"]
# Test creating a model on the server
model = cls.api_client.createModel(fileData)
cls.modelID = model["_id"]
@classmethod
def tearDownClass(cls):
pass
# result = cls.api_client.deleteModel(cls.modelID)
def setUp(self):
self.base_url = config.base_url
self.username = config.username
self.password = config.password
self.access_token = None
def tearDown(self):
pass
def test_00(self):
# test initial state
sharemodel = ShareLinkModel(self.modelID, self.api_client)
self.assertTrue(sharemodel.rowCount() == 0)
sharemodel.dump()
def test_10(self):
# create a share link data model.
sharemodel = ShareLinkModel(self.modelID, self.api_client)
link = {
"cloneModelId": self.modelID,
"description": "test link",
"canViewModel": True,
"canViewModelAttributes": False,
"canUpdateModel": False,
"canExportFCStd": False,
"canExportSTEP": False,
"canExportSTL": False,
"canExportOBJ": False,
"dummyModelId": "", # self.modelID,
"canDownloadDefaultModel": True,
}
# create a share link
result = sharemodel.add_new_link(link)
print(sharemodel.rowCount())
self.assertTrue(sharemodel.rowCount() == 1)
# delete the link
result = sharemodel.delete_link(result["_id"])
self.assertTrue(sharemodel.rowCount() == 0)
def test_20(self):
# test update.
pass
if __name__ == "__main__":
unittest.main()