Example #1
0
 def test_incorrect_executable(self):
     errors = validate_openmalaria("<>")
     # Error message is different on different platforms
     # os.name == "nt" : [Errno 2] No such file or directory: '/non-existent'
     # "linux": [Error 2] The system cannot find the file specified
     self.assertIsNotNone(errors[0])
     self.assertNotEqual(errors[0], "")
     self.assertEqual(len(errors), 1)
Example #2
0
 def test_openmalaria_segfault(self):
     with patch("website.apps.om_validate.utils.subprocess.check_output"
                ) as func:
         func.side_effect = subprocess.CalledProcessError(returncode=-11,
                                                          cmd="openmalaria",
                                                          output="")
         errors = validate_openmalaria(get_xml("scenario.xml"))
     self.assertIn("Segmentation fault", errors[1])
Example #3
0
 def test_broken_xml_2(self):
     # WARNING: this test runs openmalaria in background
     # Note that scenario_om_error.xml should pass schema validation, but fails openmalaria validation
     # See diff with scenario.xml to see what's wrong
     # (missing <anopheles mosquito="gambiae1"> in intervention description)
     errors = validate_openmalaria(get_xml("scenario_om_error.xml"))
     self.assertIn("Error: Unrecognised survey option: \"nHost11\"",
                   errors[1])
     self.assertEqual(len(errors), 4)
Example #4
0
 def test_success(self):
     # WARNING: this test runs openmalaria in background
     # Note that scenario_.xml should pass all checks, including openmalaria validation
     errors = validate_openmalaria(get_xml("scenario.xml"))
     self.assertIsNone(errors)
Example #5
0
 def test_file_creation_failed(self, get_random_string_func):
     get_random_string_func.return_value = "#/\\?%*:<>"
     errors = validate_openmalaria(get_xml("scenario.xml"))
     self.assertIn("Can't write file:", errors[0])
Example #6
0
 def test_directory_creation(self):
     # This test normally should remove test directory, but if not - additional clean up might be required
     errors = validate_openmalaria(get_xml("scenario.xml"))
     self.assertTrue(os.path.exists(os.path.join(DATA_DIR, "tmp")))
     os.rmdir(os.path.join(DATA_DIR, "tmp"))
     self.assertIsNone(errors)
Example #7
0
 def test_bad_media_root(self):
     # WARNING: this test tried to create a directory in random place (/non-existent/directory/)
     # It normally should fail, but if not - additional clean up might be required
     errors = validate_openmalaria(get_xml("scenario.xml"))
     self.assertIn("MEDIA_ROOT problem", errors[0])
Example #8
0
 def test_broken_xml_1(self):
     # WARNING: this test runs openmalaria in background
     errors = validate_openmalaria("<>")
     self.assertIn("XSD error: instance document parsing failed", errors[1])
     self.assertEqual(len(errors), 4)