52
52
53
53
app = None
54
54
55
- class TestQueryClass (unittest .TestCase ):
55
+
56
+ class QueryTests (unittest .TestCase ):
56
57
""" Unit test class for Query class """
57
58
58
59
@classmethod
59
- def setUpClass (TestQueryClass ):
60
+ def setUpClass (cls ):
60
61
""" Init unit test data """
61
62
# Create Qt application
62
- TestQueryClass .app = QGuiApplication .instance ()
63
- TestQueryClass .clip_ids = []
64
- TestQueryClass .file_ids = []
65
- TestQueryClass .transition_ids = []
66
-
67
- # Import additional classes that need the app defined first
68
- from classes .query import Clip , File , Transition
63
+ cls .app = QGuiApplication .instance ()
64
+ cls .clip_ids = []
65
+ cls .file_ids = []
66
+ cls .transition_ids = []
69
67
70
68
clips = []
71
69
@@ -85,7 +83,7 @@ def setUpClass(TestQueryClass):
85
83
query_clip .save ()
86
84
87
85
# Keep track of the ids
88
- TestQueryClass .clip_ids .append (query_clip .id )
86
+ cls .clip_ids .append (query_clip .id )
89
87
clips .append (query_clip )
90
88
91
89
# Insert some files into the project data
@@ -104,7 +102,7 @@ def setUpClass(TestQueryClass):
104
102
query_file .save ()
105
103
106
104
# Keep track of the ids
107
- TestQueryClass .file_ids .append (query_file .id )
105
+ cls .file_ids .append (query_file .id )
108
106
109
107
# Insert some transitions into the project data
110
108
for c in clips :
@@ -124,7 +122,7 @@ def setUpClass(TestQueryClass):
124
122
query_transition .save ()
125
123
126
124
# Keep track of the ids
127
- TestQueryClass .transition_ids .append (query_transition .id )
125
+ cls .transition_ids .append (query_transition .id )
128
126
129
127
# Don't keep the full query objects around
130
128
del clips
@@ -158,7 +156,7 @@ def test_add_clip(self):
158
156
def test_update_clip (self ):
159
157
""" Test the Clip.save method """
160
158
161
- update_id = TestQueryClass .clip_ids [0 ]
159
+ update_id = self .clip_ids [0 ]
162
160
clip = Clip .get (id = update_id )
163
161
self .assertTrue (clip )
164
162
@@ -172,10 +170,13 @@ def test_update_clip(self):
172
170
self .assertEqual (clip .data ["layer" ], 2 )
173
171
self .assertEqual (clip .data ["title" ], "My Title" )
174
172
173
+ clips = Clip .filter (layer = 2 )
174
+ self .assertEqual (len (clips ), 1 )
175
+
175
176
def test_delete_clip (self ):
176
177
""" Test the Clip.delete method """
177
178
178
- delete_id = TestQueryClass .clip_ids [4 ]
179
+ delete_id = self .clip_ids [4 ]
179
180
clip = Clip .get (id = delete_id )
180
181
self .assertTrue (clip )
181
182
@@ -193,7 +194,7 @@ def test_delete_clip(self):
193
194
def test_filter_clip (self ):
194
195
""" Test the Clip.filter method """
195
196
196
- clips = Clip .filter (id = TestQueryClass .clip_ids [0 ])
197
+ clips = Clip .filter (id = self .clip_ids [0 ])
197
198
self .assertTrue (clips )
198
199
199
200
# Do not find a clip
@@ -203,7 +204,7 @@ def test_filter_clip(self):
203
204
def test_get_clip (self ):
204
205
""" Test the Clip.get method """
205
206
206
- clip = Clip .get (id = TestQueryClass .clip_ids [1 ])
207
+ clip = Clip .get (id = self .clip_ids [1 ])
207
208
self .assertTrue (clip )
208
209
209
210
# Do not find a clip
@@ -254,7 +255,7 @@ def get_times(item):
254
255
def test_update_File (self ):
255
256
""" Test the File.save method """
256
257
257
- update_id = TestQueryClass .file_ids [0 ]
258
+ update_id = self .file_ids [0 ]
258
259
file = File .get (id = update_id )
259
260
self .assertTrue (file )
260
261
@@ -271,7 +272,7 @@ def test_update_File(self):
271
272
def test_delete_File (self ):
272
273
""" Test the File.delete method """
273
274
274
- delete_id = TestQueryClass .file_ids [4 ]
275
+ delete_id = self .file_ids [4 ]
275
276
file = File .get (id = delete_id )
276
277
self .assertTrue (file )
277
278
@@ -289,7 +290,7 @@ def test_delete_File(self):
289
290
def test_filter_File (self ):
290
291
""" Test the File.filter method """
291
292
292
- files = File .filter (id = TestQueryClass .file_ids [0 ])
293
+ files = File .filter (id = self .file_ids [0 ])
293
294
self .assertTrue (files )
294
295
295
296
# Do not find a File
@@ -299,7 +300,7 @@ def test_filter_File(self):
299
300
def test_get_File (self ):
300
301
""" Test the File.get method """
301
302
302
- file = File .get (id = TestQueryClass .file_ids [1 ])
303
+ file = File .get (id = self .file_ids [1 ])
303
304
self .assertTrue (file )
304
305
305
306
# Do not find a File
0 commit comments