def test_missing_output_dir(self, mock_mkstemp, mock_cmd, mock_unlink, mock_close, mock_isdir, mock_makedirs): # Setup timestamp = datetime.datetime.now() filename = "/output/dir/prefix-%s-01.iso" % timestamp.strftime("%Y-%m-%dT%H.%M") expected_command = "mkisofs -r -D -graft-points -path-list spec_file -o %s" % filename # Test that the directory is made and the iso is created like it normally would generate_iso._make_iso([], "/target/dir", "/output/dir", filename) mock_makedirs.assert_called_once_with("/output/dir") mock_cmd.assert_called_once_with(expected_command) mock_unlink.assert_called_once_with("spec_file") self.assertEqual(1, mock_mkstemp.call_count) self.assertEqual(1, mock_close.call_count) self.assertEqual(1, mock_isdir.call_count)
def test_make_iso(self, mock_mkstemp, mock_cmd, mock_unlink, mock_close, mock_isdir): # Setup timestamp = datetime.datetime.now() output_dir = '/output/dir' filename = 'prefix-%s-01.iso' % timestamp.strftime("%Y-%m-%dT%H.%M") file_path = os.path.join(output_dir, filename) expected_command = "mkisofs -r -D -graft-points -path-list spec_file -o %s" % file_path # Test generate_iso._make_iso([], '/target/dir', output_dir, filename) mock_cmd.assert_called_once_with(expected_command) mock_unlink.assert_called_once_with('spec_file') self.assertEqual(1, mock_mkstemp.call_count) self.assertEqual(1, mock_close.call_count) self.assertEqual(1, mock_isdir.call_count)
def test_missing_output_dir(self, mock_mkstemp, mock_cmd, mock_unlink, mock_close, mock_isdir, mock_makedirs): # Setup timestamp = datetime.datetime.now() filename = '/output/dir/prefix-%s-01.iso' % timestamp.strftime( "%Y-%m-%dT%H.%M") expected_command = "mkisofs -r -D -graft-points -path-list spec_file -o %s" % filename # Test that the directory is made and the iso is created like it normally would generate_iso._make_iso([], '/target/dir', '/output/dir', filename) mock_makedirs.assert_called_once_with('/output/dir') mock_cmd.assert_called_once_with(expected_command) mock_unlink.assert_called_once_with('spec_file') self.assertEqual(1, mock_mkstemp.call_count) self.assertEqual(1, mock_close.call_count) self.assertEqual(1, mock_isdir.call_count)