|
@@ 339-383 (lines=45) @@
|
| 336 |
|
'Loaded', |
| 337 |
|
'Errors in EBI API endpoints. Please try again later') |
| 338 |
|
|
| 339 |
|
@patch("validation.helpers.validation.read_in_ruleset", |
| 340 |
|
side_effect=RulesetError(["test exception"])) |
| 341 |
|
@patch("validation.tasks.ValidateTask.retry") |
| 342 |
|
def test_issues_with_ruleset( |
| 343 |
|
self, my_retry, my_validate): |
| 344 |
|
"""Test errors with ruleset""" |
| 345 |
|
|
| 346 |
|
# call task. No retries with issues at EBI |
| 347 |
|
res = self.my_task.run(submission_id=self.submission_id) |
| 348 |
|
|
| 349 |
|
# assert a success with validation taks |
| 350 |
|
self.assertEqual(res, "success") |
| 351 |
|
|
| 352 |
|
# check submission status and message |
| 353 |
|
self.submission.refresh_from_db() |
| 354 |
|
|
| 355 |
|
# this is the message I want |
| 356 |
|
message = ( |
| 357 |
|
"Error in IMAGE-metadata ruleset. Please inform InjectTool team") |
| 358 |
|
|
| 359 |
|
# check submission.status changed to ERROR |
| 360 |
|
self.assertEqual(self.submission.status, ERROR) |
| 361 |
|
self.assertIn( |
| 362 |
|
message, |
| 363 |
|
self.submission.message) |
| 364 |
|
|
| 365 |
|
# test email sent |
| 366 |
|
self.assertGreater(len(mail.outbox), 1) |
| 367 |
|
|
| 368 |
|
# read email |
| 369 |
|
email = mail.outbox[0] |
| 370 |
|
|
| 371 |
|
self.assertEqual( |
| 372 |
|
"Error in IMAGE Validation: %s" % message, |
| 373 |
|
email.subject) |
| 374 |
|
|
| 375 |
|
self.assertTrue(my_validate.called) |
| 376 |
|
self.assertFalse(my_retry.called) |
| 377 |
|
|
| 378 |
|
# asserting create validationsummary not called |
| 379 |
|
self.assertEqual(self.create_vsummary.call_count, 0) |
| 380 |
|
|
| 381 |
|
self.check_async_called( |
| 382 |
|
'Error', |
| 383 |
|
'Error in IMAGE-metadata ruleset. Please inform InjectTool team') |
| 384 |
|
|
| 385 |
|
@patch("validation.tasks.MetaDataValidation.read_in_ruleset") |
| 386 |
|
@patch("validation.helpers.validation.check_ruleset", |
|
@@ 293-337 (lines=45) @@
|
| 290 |
|
'Errors in EBI API endpoints. Please try again later' |
| 291 |
|
) |
| 292 |
|
|
| 293 |
|
@patch("validation.helpers.validation.read_in_ruleset", |
| 294 |
|
side_effect=OntologyCacheError("test exception")) |
| 295 |
|
@patch("validation.tasks.ValidateTask.retry") |
| 296 |
|
def test_issues_with_ontologychache( |
| 297 |
|
self, my_retry, my_validate): |
| 298 |
|
"""Test errors with validation API when loading OntologyCache |
| 299 |
|
objects""" |
| 300 |
|
|
| 301 |
|
# call task. No retries with issues at EBI |
| 302 |
|
res = self.my_task.run(submission_id=self.submission_id) |
| 303 |
|
|
| 304 |
|
# assert a success with validation taks |
| 305 |
|
self.assertEqual(res, "success") |
| 306 |
|
|
| 307 |
|
# check submission status and message |
| 308 |
|
self.submission.refresh_from_db() |
| 309 |
|
|
| 310 |
|
# this is the message I want |
| 311 |
|
message = "Errors in EBI API endpoints. Please try again later" |
| 312 |
|
|
| 313 |
|
# check submission.status changed to LOADED |
| 314 |
|
self.assertEqual(self.submission.status, LOADED) |
| 315 |
|
self.assertIn( |
| 316 |
|
message, |
| 317 |
|
self.submission.message) |
| 318 |
|
|
| 319 |
|
# test email sent |
| 320 |
|
self.assertEqual(len(mail.outbox), 1) |
| 321 |
|
|
| 322 |
|
# read email |
| 323 |
|
email = mail.outbox[0] |
| 324 |
|
|
| 325 |
|
self.assertEqual( |
| 326 |
|
"Error in IMAGE Validation: %s" % message, |
| 327 |
|
email.subject) |
| 328 |
|
|
| 329 |
|
self.assertTrue(my_validate.called) |
| 330 |
|
self.assertFalse(my_retry.called) |
| 331 |
|
|
| 332 |
|
# asserting create validationsummary not called |
| 333 |
|
self.assertEqual(self.create_vsummary.call_count, 0) |
| 334 |
|
|
| 335 |
|
self.check_async_called( |
| 336 |
|
'Loaded', |
| 337 |
|
'Errors in EBI API endpoints. Please try again later') |
| 338 |
|
|
| 339 |
|
@patch("validation.helpers.validation.read_in_ruleset", |
| 340 |
|
side_effect=RulesetError(["test exception"])) |