tests package

Subpackages

Submodules

tests.test_cmdline module

class tests.test_cmdline.TestCmdline(methodName='runTest')

Bases: unittest.case.TestCase

tests.test_generator module

class tests.test_generator.ConfigurableSourceDestGenerator(source_roots_val, destination_root_val)

Bases: lor.generator.Generator

destination_root()

Returns the destination root directory.

Relative destination paths are resolved relative to this root. By default, the destination root is the current workspace if a current workspace can be established; otherwise, an AssertionError is raised.

Returns:The destination root directory as a string
run(argv)

Run the generator.

Parameters:argv – Command-line arguments for the generator

:raises Exception For a wide variety of reasons (CLI parsing, cannot copy file, cannot create file, invaild args, etc.)

source_roots()

Returns a list of source folders from which source files/templates should be read.

By default, returns the “templates/” directory, if a templates/ dir exists in the generator’s package. Otherwise, returns the path of the generator’s package.

Returns:A list of source folders as strings.
class tests.test_generator.MinimalGeneratorImpl

Bases: lor.generator.Generator

run(argv)

Run the generator.

Parameters:argv – Command-line arguments for the generator

:raises Exception For a wide variety of reasons (CLI parsing, cannot copy file, cannot create file, invaild args, etc.)

class tests.test_generator.TestGenerator(methodName='runTest')

Bases: unittest.case.TestCase

test_copy_file_copies_file_to_destination()
test_copy_file_raises_FileExistsError_if_destination_already_exists()
test_copy_file_raises_FileNotFoundError_if_source_does_not_exist()
test_create_file_creates_file_with_content()
test_create_file_creates_subdirs_when_required()
test_create_file_raises_FileExistsError_if_file_already_exists()
test_description_default_returns_object_name()
test_destination_root_default_raises_AssertionError_if_not_in_a_workspace()
test_destination_root_default_returns_workspace()
test_mkdir_is_ok_if_dir_already_exists()
test_mkdir_makes_empty_dir()
test_mkdir_makes_parent_dirs()
test_render_template_creates_subdirs_when_required()
test_render_template_raises_FileExistsError_if_destination_already_exists()
test_render_template_raises_FileNotFound_if_template_does_not_exist()
test_render_template_writes_rendered_template_to_destination_root()
test_run_default_raises_NotImplementedError()
test_source_roots_default_returns_implementation_package_path_if_templates_doesnt_exist()
test_source_roots_default_returns_implementation_templates_dir_if_exists()

tests.test_path module

class tests.test_path.TestPaths(methodName='runTest')

Bases: unittest.case.TestCase

test__set_overlay_paths_causes_get_overlay_paths_to_return_the_supplied_paths()
test__set_overlay_paths_raises_FileNotFoundError_if_list_entry_does_not_exist()
test__set_overlay_paths_raises_NotADirectoryError_if_path_is_to_a_file()
test__set_overlay_paths_raises_ValueError_if_supplied_a_list_of_non_strings()
test__set_overlay_paths_raises_ValueError_if_supplied_a_non_list()
test__set_overlay_paths_works_with_list_of_existient_dirs()
test_get_overlay_paths_returns_a_list()
test_join_all_returns_a_list()
test_join_all_returns_list_of_overlays_then_workspace()
test_join_raises_ValueError_if_no_overlays_and_not_in_workspace()
test_join_returns_paths_joined_onto_first_overlay_if_overlays_assigned()
test_join_returns_paths_joined_onto_workspace_if_no_overlay_paths_available()
test_join_works_with_multiple_fragments()
test_resolve_all_list_contains_elements_that_do_exist()
test_resolve_all_list_is_empty_if_no_overlays_or_workspace()
test_resolve_all_returns_a_list()
test_resolve_raises_FileNotFoundError_if_file_doesnt_exist_in_any_location()
test_resolve_raises_ValueError_if_overlays_empty_and_not_in_workspace()
test_resolve_returns_result_from_another_overlay_if_exists_in_different_overlay()
test_resolve_returns_result_from_overlay_if_exists_and_in_overlay()
test_resolve_returns_result_from_workspace_if_workspace_has_file()

tests.test_props module

class tests.test_props.TestProperties(methodName='runTest')

Bases: unittest.case.TestCase

test_DictPropertyLoader_get_all_returns_same_dict_as_supplied_in_ctor()
test_DictPropertyLoader_get_name_returns_supplied_name()
test_DictPropertyLoader_get_raises_KeyError_if_property_does_not_exist()
test_DictPropertyLoader_get_returns_property_from_dict()
test_DictPropertyLoader_init_works_with_standard_args()
test_DictPropertyLoader_try_get_returns_None_if_property_does_not_exist()
test_DictPropertyLoader_try_get_returns_property_from_dict()
test_YAMLFilePropertyLoader_get_all_returns_dict_of_values_loaded_from_YAML_file()
test_YAMLFilePropertyLoader_get_name_contains_YAML_file_name()
test_YAMLFilePropertyLoader_get_returns_variable_in_YAML_file()
test_YAMLFilePropertyLoader_get_throws_KeyError_if_variable_not_in_YAML_file()
test_YAMLFilePropertyLoader_init_raises_FileNotFoundError_if_path_does_not_exist()
test_YAMLFilePropertyLoader_init_raises_RuntimeError_if_file_is_invalid()
test_YAMLFilePropertyLoader_try_get_returns_None_if_variable_not_in_YAML_file()
test_YAMLFilePropertyLoader_try_get_returns_variable_in_YAML_file()
test__set_loaders_allows_None_as_arg()
test__set_loaders_allows_setting_list_of_loaders()
test__set_loaders_loads_props_from_workspace_if_previously_set_to_None()
test__set_loaders_raises_ValueError_if_passed_list_containing_non_prop_loader()
test__set_loaders_raises_ValueError_if_passed_non_list()
test__set_loaders_then_uses_loader_with_get_all_call()
test__set_loaders_then_uses_loader_with_get_call()
test__set_loaders_to_None_then_raises_RuntimeError_if_not_in_workspace()
test_get_all_dict_contains_expected_results()
test_get_all_returns_a_dict()
test_get_property_from_list_of_loaders_overwrites_properties()
test_get_property_from_list_of_loaders_raises_KeyError_if_property_is_not_in_loaders()
test_get_property_from_list_of_loaders_returns_prop_from_multiple_loaders()
test_get_property_from_list_of_loaders_returns_prop_from_single_loader()
test_get_raises_KeyError_for_non_existent_property()
test_get_returns_property_from_loaders()
test_merge_list_of_property_loaders_merges_properties_from_multiple_loaders_as_expected()
test_merge_list_of_property_loaders_takes_list_and_returns_dict()

tests.test_test module

class tests.test_test.TestTest(methodName='runTest')

Bases: unittest.case.TestCase

tests.test_util module

class tests.test_util.TestHelpers(methodName='runTest')

Bases: unittest.case.TestCase

test_file_uri_returns_expected_results()
test_or_join_returns_expected_results()
test_read_file_to_string_raises_FileNotFoundError_for_non_existent_path()
test_read_file_to_string_raises_UnicodeDecodeError_for_binary_file()
test_read_file_to_string_returns_file_contents_as_string()
test_to_camel_case_returns_expected_results()
test_to_snake_case_returns_expected_results()
test_uri_subfolder_returns_expected_result()
test_write_str_to_file()
test_write_str_to_file_raises_FileExistsError_if_file_exists()

tests.test_workspace module

class tests.test_workspace.TestWorkspaces(methodName='runTest')

Bases: unittest.case.TestCase

test__set_path_raises_FileNotFoundError_if_arg_does_not_exist()
test__set_path_raises_NotADirectoryError_if_arg_is_file()
test__set_path_raises_ValueError_if_arg_is_no_a_workspace()
test__set_path_runs_ok_with_valid_workspace()
test__set_path_to_None_works_ok()
test_get_package_name_raises_Exception_if_properties_file_missing_WORKSPACE_NAME_key()
test_get_package_name_raises_Exception_if_properties_file_missing_from_workspace()
test_get_package_name_raises_Exception_if_supplied_non_workspace()
test_get_package_name_returns_a_string_for_new_workspace()
test_get_package_name_uses_WORKSPACE_NAME_variable()
test_get_path_returns_None_if_manual_ws_set_is_None_and_cwd_is_not_a_workspace()
test_get_path_returns_cwd_if_cwd_is_workspace_and_no_manual_override_set()
test_get_path_returns_manually_set_path()
test_get_path_returns_manually_set_path_even_if_supplied_cwd()
test_is_workspace_raises_FileNotFoundError_if_path_does_not_exist()
test_is_workspace_raises_NotADirectoryError_if_path_is_a_file()
test_is_workspace_returns_false_if_dir_doesnt_contain_binstub()
test_is_workspace_returns_true_if_path_contains_binstub()
test_run_install_script_raises_FileNotFoundError_if_workspace_doesnt_contain_installer()
test_run_install_script_raises_FileNotFoundError_if_workspace_path_does_not_exist()
test_run_install_script_raises_NotADirectoryError_if_workspace_path_is_not_a_dir()
test_run_install_script_runs_bin_install()
test_try_locate_returns_LOR_HOME_if_it_is_set_in_env()
test_try_locate_returns_cwd_if_cwd_is_a_workspace()
test_try_locate_returns_env_cwd_if_env_cwd_is_a_workspace()
test_try_locate_returns_none_if_lor_home_is_not_set_and_cwd_is_not_a_workspace()

tests.tst_helpers module

tests.tst_helpers.fixture(path_rel_to_fixtures_dir)

Returns a path to a fixture :param path_rel_to_fixtures_dir Path relative to the fixtures dir

Module contents