def test_make_http_dir(self): """ Tests the the http publishing directory is created by publish_isos if it does not exist """ # Setup os.path.isdir.return_value = False # Confirm that when https_dir is not None and the directory doesn't exist, it is created export_utils.publish_isos('/working/dir', 'prefix', http_dir='/http/dir') os.makedirs.assert_called_once_with('/http/dir')
def test_removing_dirs(self): """ Tests that publish_isos cleans out all the directories in the working directory except the ISOs. Since storing stuff in the working directory is bad form and should eventually change, this """ # Setup os.walk.return_value = [('/root', ['dir1', 'dir2'], [])] # Test that for each directory, rmtree is called export_utils.publish_isos('/working/dir', 'prefix') self.assertEqual(2, shutil.rmtree.call_count) self.assertEqual('/root/dir1', shutil.rmtree.call_args_list[0][0][0]) self.assertEqual('/root/dir2', shutil.rmtree.call_args_list[1][0][0])
def test_linking_http_iso_images(self): """ Tests that each file in the working directory (after it is cleaned up) is symlinked to the http publishing directory """ # Setup os.walk.return_value = [('/root', [], ['file1', 'file2'])] expected_call1 = ('/root/file1', '/http/dir/file1') expected_call2 = ('/root/file2', '/http/dir/file2') # Test that for each file, os.symlink is called correctly export_utils.publish_isos('/working/dir', 'prefix', http_dir='/http/dir') self.assertEqual(2, os.symlink.call_count) self.assertEqual(expected_call1, os.symlink.call_args_list[0][0]) self.assertEqual(expected_call2, os.symlink.call_args_list[1][0])