Пример #1
0
 def test_get_studies_from_list(self):
     mock_open.return_value = FileNotFoundError
     actual, message = get_studies(self.list_of_studies)
     expected = self.list_of_studies
     assert isinstance(actual, object)
     self.assertEqual(expected, actual)
     self.assertEqual("Studies extracted from list\n", message)
Пример #2
0
 def test_get_studies_integer(self):
     mock_open.return_value = FileNotFoundError
     actual, message = get_studies(47)
     self.assertEqual([], actual)
     self.assertEqual((type(
         47
     ), "is not a valid input type. Nothing will be uploaded. Please enter path to a file or a list of study names\n"
                       ), message)
Пример #3
0
 def test_file_and_fail(self):
     mock_open.return_value = FileNotFoundError
     actual, message = get_studies(self.prok_path)
     #archive_project.GetStudies.open.assert_called_once_with(self.prok_path)
     expected = list(self.prok_path.split(','))
     self.assertEqual(expected, actual)
     self.assertEqual(
         "This file can't be found. Attempt will be made to interpret as a list. If this is not intended then please enter a valid path to a file or a list of study names.\n",
         message)
Пример #4
0
 def test_get_studies_from_file(self):
     with patch("archive_project.GetStudies.open".format(__name__),
                mock_open(read_data="data1\ndata2\ndata3"),
                create=True) as _file:
         actual, message = get_studies(self.prok_path)
     _file.assert_called_once_with(self.prok_path)
     expected = ['data1', 'data2', 'data3']
     self.assertEqual(expected, actual)
     self.assertEqual("Studies extracted from file\n", message)
Пример #5
0
 def test_get_studies_empty_list(self):
     mock_open.return_value = FileNotFoundError
     actual, message = get_studies([])
     self.assertEqual([], actual)
     self.assertEqual("Studies extracted from list\n", message)