Exemple #1
0
 def check_nonexistent_rpm_returns_none(self, mock_valid_rpm, is_absolute_path):
     mock_valid_rpm.side_effect = SystemExit('...File does not exist...')
     fd = -1
     absolute_path_nonexistent_rpm = None
     try:
         fd, absolute_path_nonexistent_rpm = tempfile.mkstemp()
         if is_absolute_path:
             local_finder = server.LocalPrestoRpmFinder(absolute_path_nonexistent_rpm)
         else:
             relative_path_nonexistent_rpm = os.path.basename(absolute_path_nonexistent_rpm)
             local_finder = server.LocalPrestoRpmFinder(relative_path_nonexistent_rpm)
     finally:
         os.close(fd)
         os.remove(absolute_path_nonexistent_rpm)
     self.assertTrue(local_finder.find_local_presto_rpm() is None)
Exemple #2
0
 def check_find_valid_rpm_returns_absolute_path(self, mock_valid_rpm, is_absolute_path):
     fd = -1
     absolute_path_valid_rpm = None
     try:
         fd, absolute_path_valid_rpm = tempfile.mkstemp()
         if is_absolute_path:
             local_finder = server.LocalPrestoRpmFinder(absolute_path_valid_rpm)
         else:
             relative_path_valid_rpm = os.path.basename(absolute_path_valid_rpm)
             local_finder = server.LocalPrestoRpmFinder(relative_path_valid_rpm)
         self.assertEqual(local_finder.find_local_presto_rpm(), absolute_path_valid_rpm)
         self.assertTrue(mock_valid_rpm.called)
     finally:
         os.close(fd)
         os.remove(absolute_path_valid_rpm)
Exemple #3
0
 def check_corrupt_rpm_removed_and_returns_none(self, mock_valid_rpm, is_absolute_path):
     mock_valid_rpm.side_effect = SystemExit('...Corrupted RPM...')
     fd = -1
     absolute_path_corrupt_rpm = None
     try:
         fd, absolute_path_corrupt_rpm = tempfile.mkstemp()
         if is_absolute_path:
             local_finder = server.LocalPrestoRpmFinder(absolute_path_corrupt_rpm)
         else:
             relative_path_corrupt_rpm = os.path.basename(absolute_path_corrupt_rpm)
             local_finder = server.LocalPrestoRpmFinder(relative_path_corrupt_rpm)
         self.assertTrue(local_finder.find_local_presto_rpm() is None)
         self.assertTrue(mock_valid_rpm.called)
     finally:
         os.close(fd)
         self.assertRaises(OSError, os.remove, absolute_path_corrupt_rpm)