def test_find_deployable_no_files_only_directories(): with patch('flow.utils.commons.print_msg') as mock_printmsg_fn: with pytest.raises(SystemExit): with patch('os.listdir', return_value=['file1.txt', 'file2.txt', 'file3.txt']): with patch('os.path.isfile', return_value=False): _b = MagicMock(BuildConfig) _b.project_name = 'CI-HelloWorld' _b.version_number = 'v2.9.0+1' _b.push_location = 'fordeployment' _cf = CloudFoundry(_b) _cf.find_deployable('txt', 'fake_push_dir') mock_printmsg_fn.assert_called_with('Cloud', 'find_deployable', 'Could not find file of type txt in fake_push_dir', 'ERROR')
def test_find_deployable_one_file(): with patch('flow.utils.commons.print_msg') as mock_printmsg_fn: with patch('zipfile.ZipFile') as mocked_ZipFile: mocked_ZipFile.return_value.returncode = 0 with patch('os.listdir', return_value=['file1.jar', 'file2.abc', 'file3.abc']): with patch('os.path.isfile', return_value=True): _b = MagicMock(BuildConfig) _b.project_name = 'CI-HelloWorld' _b.version_number = 'v2.9.0+1' _b.push_location = 'fordeployment' _cf = CloudFoundry(_b) _cf.find_deployable('jar', 'fake_push_dir') mock_printmsg_fn.assert_any_call('Cloud', 'find_deployable', 'Looking for a jar in fake_push_dir')
def test_find_deployable_multiple_files(): with patch('flow.utils.commons.printMSG') as mock_printmsg_fn: with pytest.raises(SystemExit): with patch('os.listdir', return_value=['file1.txt', 'file2.txt', 'file3.txt']): with patch('os.path.isfile', return_value=True): _b = MagicMock(BuildConfig) _b.project_name = 'CI-HelloWorld' _b.version_number = 'v2.9.0+1' _b.push_location = 'fordeployment' _cf = CloudFoundry(_b) _cf.find_deployable('txt', 'fake_push_dir') mock_printmsg_fn.assert_called_with( 'Cloud', 'find_deployable', 'Found more than 1 artifact in fake_push_dir', 'ERROR')