|
8 | 8 | from attachments.models import Attachment
|
9 | 9 | from django.contrib.auth.models import Permission
|
10 | 10 | from django.core.exceptions import ValidationError
|
| 11 | +from parameterized import parameterized |
11 | 12 | from tcms_api import xmlrpc
|
12 | 13 |
|
13 | 14 | from tcms.core.helpers import comments
|
@@ -173,12 +174,55 @@ def test_filter_query_none(self):
|
173 | 174 | self.assertIn("author", result[0])
|
174 | 175 | self.assertIn("default_tester", result[0])
|
175 | 176 | self.assertIn("reviewer", result[0])
|
| 177 | + self.assertIn("setup_duration", result[0]) |
| 178 | + self.assertIn("testing_duration", result[0]) |
| 179 | + self.assertIn("expected_duration", result[0]) |
176 | 180 |
|
177 | 181 | def test_filter_by_product_id(self):
|
178 | 182 | cases = self.rpc_client.TestCase.filter({"category__product": self.product.pk})
|
179 | 183 | self.assertIsNotNone(cases)
|
180 | 184 | self.assertEqual(len(cases), self.cases_count)
|
181 | 185 |
|
| 186 | + @parameterized.expand( |
| 187 | + [ |
| 188 | + ("both_values_are_not_set", {}, None, None, 0), |
| 189 | + ( |
| 190 | + "setup_duration_is_not_set", |
| 191 | + {"testing_duration": timedelta(minutes=5)}, |
| 192 | + None, |
| 193 | + 300, |
| 194 | + 300, |
| 195 | + ), |
| 196 | + ( |
| 197 | + "testing_duration_is_not_set", |
| 198 | + {"setup_duration": timedelta(seconds=45)}, |
| 199 | + 45, |
| 200 | + None, |
| 201 | + 45, |
| 202 | + ), |
| 203 | + ( |
| 204 | + "both_values_are_set", |
| 205 | + { |
| 206 | + "setup_duration": timedelta(seconds=45), |
| 207 | + "testing_duration": timedelta(minutes=5), |
| 208 | + }, |
| 209 | + 45, |
| 210 | + 300, |
| 211 | + 345, |
| 212 | + ), |
| 213 | + ] |
| 214 | + ) |
| 215 | + def test_duration_properties_in_result( |
| 216 | + self, _name, init_dict, setup_duration, testing_duration, expected_duration |
| 217 | + ): |
| 218 | + testcase = TestCaseFactory(**init_dict) |
| 219 | + result = self.rpc_client.TestCase.filter({"pk": testcase.pk}) |
| 220 | + |
| 221 | + self.assertIsNotNone(result) |
| 222 | + self.assertEqual(result[0]["setup_duration"], setup_duration) |
| 223 | + self.assertEqual(result[0]["testing_duration"], testing_duration) |
| 224 | + self.assertEqual(result[0]["expected_duration"], expected_duration) |
| 225 | + |
182 | 226 |
|
183 | 227 | class TestUpdate(APITestCase):
|
184 | 228 | non_existing_username = "FakeUsername"
|
|
0 commit comments