code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def test_get_latest_starters_version_error(
self, mock_env_vars, requests_mock, caplog
):
"""Test _get_latest_starters_version when the request raises an exception"""
with caplog.at_level(logging.ERROR):
# Mock the request to raise a RequestException
requests_mock.get... | Test _get_latest_starters_version when the request raises an exception | test_get_latest_starters_version_error | python | kedro-org/kedro | tests/framework/cli/test_starters.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/test_starters.py | Apache-2.0 |
def test_kedro_version_equal_or_lower_to_starters_equal(self, mocker):
"""Test when version is equal to starters_version"""
mocker.patch(
"kedro.framework.cli.starters._get_latest_starters_version",
return_value="1.2.3",
)
version = "1.2.3"
result = _kedr... | Test when version is equal to starters_version | test_kedro_version_equal_or_lower_to_starters_equal | python | kedro-org/kedro | tests/framework/cli/test_starters.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/test_starters.py | Apache-2.0 |
def test_kedro_version_equal_or_lower_to_starters_lower(self, mocker):
"""Test when version is lower than starters_version"""
mocker.patch(
"kedro.framework.cli.starters._get_latest_starters_version",
return_value="1.3.0",
)
version = "1.2.3"
result = _ke... | Test when version is lower than starters_version | test_kedro_version_equal_or_lower_to_starters_lower | python | kedro-org/kedro | tests/framework/cli/test_starters.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/test_starters.py | Apache-2.0 |
def test_kedro_version_equal_or_lower_to_starters_higher(self, mocker):
"""Test when version is higher than starters_version"""
mocker.patch(
"kedro.framework.cli.starters._get_latest_starters_version",
return_value="1.2.3",
)
version = "1.2.4"
result = _... | Test when version is higher than starters_version | test_kedro_version_equal_or_lower_to_starters_higher | python | kedro-org/kedro | tests/framework/cli/test_starters.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/test_starters.py | Apache-2.0 |
def test_hook_manager_can_call_hooks_defined_in_specs(hook_specs, hook_name):
"""Tests to make sure that the hook manager can call all hooks defined by specs."""
cli_hook_manager = CLIHooksManager()
hook = getattr(cli_hook_manager.hook, hook_name)
assert hook.spec.namespace == hook_specs
# kedro-tel... | Tests to make sure that the hook manager can call all hooks defined by specs. | test_hook_manager_can_call_hooks_defined_in_specs | python | kedro-org/kedro | tests/framework/cli/hooks/test_manager.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/hooks/test_manager.py | Apache-2.0 |
def test_micropkg_package_same_name_as_package_name(
self, fake_metadata, fake_project_cli, fake_repo_path
):
"""Create modular pipeline with the same name as the
package name, then package as is. The command should run
and the resulting sdist should have all expected contents.
... | Create modular pipeline with the same name as the
package name, then package as is. The command should run
and the resulting sdist should have all expected contents.
| test_micropkg_package_same_name_as_package_name | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_package.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_package.py | Apache-2.0 |
def test_micropkg_package_same_name_as_package_name_alias(
self, fake_metadata, fake_project_cli, fake_repo_path
):
"""Create modular pipeline, then package under alias
the same name as the package name. The command should run
and the resulting sdist should have all expected contents... | Create modular pipeline, then package under alias
the same name as the package name. The command should run
and the resulting sdist should have all expected contents.
| test_micropkg_package_same_name_as_package_name_alias | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_package.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_package.py | Apache-2.0 |
def test_pull_local_sdist(
self,
fake_project_cli,
fake_repo_path,
fake_package_path,
env,
alias,
destination,
fake_metadata,
):
"""Test for pulling a valid sdist file locally."""
call_pipeline_create(fake_project_cli, fake_metadata)
... | Test for pulling a valid sdist file locally. | test_pull_local_sdist | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_pull.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_pull.py | Apache-2.0 |
def test_pull_local_sdist_compare(
self,
fake_project_cli,
fake_repo_path,
fake_package_path,
env,
alias,
destination,
fake_metadata,
):
"""Test for pulling a valid sdist file locally, unpack it
into another location and check that unpa... | Test for pulling a valid sdist file locally, unpack it
into another location and check that unpacked files
are identical to the ones in the original modular pipeline.
| test_pull_local_sdist_compare | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_pull.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_pull.py | Apache-2.0 |
def test_pull_sdist_fs_args(
self, fake_project_cli, fake_repo_path, mocker, tmp_path, fake_metadata
):
"""Test for pulling a sdist file with custom fs_args specified."""
call_pipeline_create(fake_project_cli, fake_metadata)
call_micropkg_package(fake_project_cli, fake_metadata)
... | Test for pulling a sdist file with custom fs_args specified. | test_pull_sdist_fs_args | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_pull.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_pull.py | Apache-2.0 |
def test_pull_tests_missing(
self,
fake_project_cli,
fake_repo_path,
fake_package_path,
env,
alias,
fake_metadata,
):
"""Test for pulling a valid sdist file locally,
but `tests` directory is missing from the sdist file.
"""
call... | Test for pulling a valid sdist file locally,
but `tests` directory is missing from the sdist file.
| test_pull_tests_missing | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_pull.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_pull.py | Apache-2.0 |
def test_pull_config_missing(
self,
fake_project_cli,
fake_repo_path,
fake_package_path,
env,
alias,
fake_metadata,
):
"""
Test for pulling a valid sdist file locally, but `config` directory is missing
from the sdist file.
"""
... |
Test for pulling a valid sdist file locally, but `config` directory is missing
from the sdist file.
| test_pull_config_missing | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_pull.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_pull.py | Apache-2.0 |
def test_pull_from_pypi(
self,
fake_project_cli,
fake_repo_path,
mocker,
tmp_path,
fake_package_path,
env,
alias,
fake_metadata,
temp_dir_with_context_manager,
):
"""
Test for pulling a valid sdist file from pypi.
... |
Test for pulling a valid sdist file from pypi.
| test_pull_from_pypi | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_pull.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_pull.py | Apache-2.0 |
def test_invalid_pull_from_pypi(
self,
fake_project_cli,
mocker,
tmp_path,
fake_metadata,
temp_dir_with_context_manager,
):
"""
Test for pulling package from pypi, and it cannot be found.
"""
pypi_error_message = (
"ERROR: ... |
Test for pulling package from pypi, and it cannot be found.
| test_invalid_pull_from_pypi | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_pull.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_pull.py | Apache-2.0 |
def test_pull_from_pypi_more_than_one_sdist_file(
self,
fake_project_cli,
mocker,
tmp_path,
fake_metadata,
temp_dir_with_context_manager,
):
"""
Test for pulling a sdist file with `pip download`, but there are more than one sdist
file to unzip.... |
Test for pulling a sdist file with `pip download`, but there are more than one sdist
file to unzip.
| test_pull_from_pypi_more_than_one_sdist_file | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_pull.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_pull.py | Apache-2.0 |
def test_micropkg_pull_invalid_sdist(
self, fake_project_cli, fake_repo_path, fake_metadata, tmp_path
):
"""
Test for pulling an invalid sdist file locally with more than one package.
"""
error_message = (
"Invalid sdist was extracted: exactly one directory was ex... |
Test for pulling an invalid sdist file locally with more than one package.
| test_micropkg_pull_invalid_sdist | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_pull.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_pull.py | Apache-2.0 |
def test_path_traversal(
self,
tar_members,
path_name,
):
"""Test for checking path traversal attempt in tar file"""
tar = Mock()
tar.getmembers.return_value = [
tarfile.TarInfo(name=tar_name) for tar_name in tar_members
]
path = Path(path_... | Test for checking path traversal attempt in tar file | test_path_traversal | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_pull.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_pull.py | Apache-2.0 |
def test_existing_complex_project_requirements_txt(
self, fake_project_cli, fake_metadata, fake_package_path, fake_repo_path
):
"""Pipeline requirements.txt and project requirements.txt."""
project_requirements_txt = fake_repo_path / "requirements.txt"
with open(project_requirements_... | Pipeline requirements.txt and project requirements.txt. | test_existing_complex_project_requirements_txt | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_requirements.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_requirements.py | Apache-2.0 |
def test_missing_project_requirements_txt(
self,
fake_project_cli,
fake_metadata,
fake_package_path,
fake_repo_path,
):
"""Pipeline requirements.txt without requirements.txt at
project level."""
# Remove project requirements.txt
project_requir... | Pipeline requirements.txt without requirements.txt at
project level. | test_missing_project_requirements_txt | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_requirements.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_requirements.py | Apache-2.0 |
def test_no_requirements(
self,
fake_project_cli,
fake_metadata,
fake_repo_path,
):
"""No pipeline requirements.txt, and also no requirements.txt
at project level."""
# Remove project requirements.txt
project_requirements_txt = fake_repo_path / "requir... | No pipeline requirements.txt, and also no requirements.txt
at project level. | test_no_requirements | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_requirements.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_requirements.py | Apache-2.0 |
def test_all_requirements_already_covered(
self, fake_project_cli, fake_metadata, fake_repo_path, fake_package_path
):
"""All requirements from pipeline requirements.txt already exist at project
level requirements.txt."""
self.call_pipeline_create(fake_project_cli, fake_metadata)
... | All requirements from pipeline requirements.txt already exist at project
level requirements.txt. | test_all_requirements_already_covered | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_requirements.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_requirements.py | Apache-2.0 |
def test_no_pipeline_requirements_txt(
self, fake_project_cli, fake_metadata, fake_repo_path
):
"""No pipeline requirements.txt and no project requirements.txt does not
create project requirements.txt."""
# Remove project requirements.txt
project_requirements_txt = fake_repo... | No pipeline requirements.txt and no project requirements.txt does not
create project requirements.txt. | test_no_pipeline_requirements_txt | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_requirements.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_requirements.py | Apache-2.0 |
def test_empty_pipeline_requirements_txt(
self, fake_project_cli, fake_metadata, fake_package_path, fake_repo_path
):
"""Empty pipeline requirements.txt and no project requirements.txt does not
create project requirements.txt."""
# Remove project requirements.txt
project_req... | Empty pipeline requirements.txt and no project requirements.txt does not
create project requirements.txt. | test_empty_pipeline_requirements_txt | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_requirements.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_requirements.py | Apache-2.0 |
def test_complex_requirements(
self, requirement, fake_project_cli, fake_metadata, fake_package_path
):
"""Options that are valid in requirements.txt but cannot be packaged in
pyproject.toml."""
self.call_pipeline_create(fake_project_cli, fake_metadata)
pipeline_requirements_... | Options that are valid in requirements.txt but cannot be packaged in
pyproject.toml. | test_complex_requirements | python | kedro-org/kedro | tests/framework/cli/micropkg/test_micropkg_requirements.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/micropkg/test_micropkg_requirements.py | Apache-2.0 |
def fake_local_template_dir(fake_repo_path):
"""Set up a local template directory. This won't be functional we're just testing the actual layout works.
Note that this is not scoped to module because we don't want to have this folder present in most of the tests,
so we will tear it down every time.
"""
... | Set up a local template directory. This won't be functional we're just testing the actual layout works.
Note that this is not scoped to module because we don't want to have this folder present in most of the tests,
so we will tear it down every time.
| fake_local_template_dir | python | kedro-org/kedro | tests/framework/cli/pipeline/conftest.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/conftest.py | Apache-2.0 |
def test_create_pipeline_skip_config(
self, fake_repo_path, fake_project_cli, fake_metadata, env
):
"""Test creation of a pipeline with no config"""
cmd = ["pipeline", "create", "--skip-config", PIPELINE_NAME]
cmd += ["-e", env] if env else []
result = CliRunner().invoke(fa... | Test creation of a pipeline with no config | test_create_pipeline_skip_config | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_catalog_and_params(
self, fake_repo_path, fake_project_cli, fake_metadata, fake_package_path
):
"""Test that catalog and parameter configs generated in pipeline
sections propagate into the context"""
pipelines_dir = fake_package_path / "pipelines"
assert pipelines_di... | Test that catalog and parameter configs generated in pipeline
sections propagate into the context | test_catalog_and_params | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_skip_copy(self, fake_repo_path, fake_project_cli, fake_metadata):
"""Test skipping the copy of conf and test files if those already exist"""
# create catalog and parameter files
for dirname in ("catalog", "parameters"):
path = (
fake_repo_path
... | Test skipping the copy of conf and test files if those already exist | test_skip_copy | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_failed_copy(
self, fake_project_cli, fake_metadata, fake_package_path, mocker
):
"""Test the error if copying some file fails"""
error = Exception("Mock exception")
mocked_copy = mocker.patch("shutil.copyfile", side_effect=error)
cmd = ["pipeline", "create", PIPELIN... | Test the error if copying some file fails | test_failed_copy | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_no_pipeline_arg_error(
self, fake_project_cli, fake_metadata, fake_package_path
):
"""Test the error when no pipeline name was provided"""
pipelines_dir = fake_package_path / "pipelines"
assert pipelines_dir.is_dir()
result = CliRunner().invoke(
fake_pro... | Test the error when no pipeline name was provided | test_no_pipeline_arg_error | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_bad_pipeline_name(
self, fake_project_cli, fake_metadata, bad_name, error_message
):
"""Test error message when bad pipeline name was provided"""
result = CliRunner().invoke(
fake_project_cli, ["pipeline", "create", bad_name], obj=fake_metadata
)
assert r... | Test error message when bad pipeline name was provided | test_bad_pipeline_name | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_duplicate_pipeline_name(
self, fake_project_cli, fake_metadata, fake_package_path
):
"""Test error when attempting to create pipelines with duplicate names"""
pipelines_dir = fake_package_path / "pipelines"
assert pipelines_dir.is_dir()
cmd = ["pipeline", "create", ... | Test error when attempting to create pipelines with duplicate names | test_duplicate_pipeline_name | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_create_pipeline_ensures_init_file(
self, fake_repo_path, fake_project_cli, fake_metadata, fake_package_path
):
"""Test that creating a pipeline ensures pipelines/__init__.py exists"""
# Setup: make sure pipelines directory exists but remove __init__.py
pipelines_dir = fake_p... | Test that creating a pipeline ensures pipelines/__init__.py exists | test_create_pipeline_ensures_init_file | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_delete_pipeline_skip(
self, fake_repo_path, fake_project_cli, fake_metadata, fake_package_path
):
"""Tests that delete pipeline handles missing or already deleted files gracefully"""
source_path = fake_package_path / "pipelines" / PIPELINE_NAME
shutil.rmtree(str(source_path... | Tests that delete pipeline handles missing or already deleted files gracefully | test_delete_pipeline_skip | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_bad_pipeline_name(
self, fake_project_cli, fake_metadata, bad_name, error_message
):
"""Test error message when bad pipeline name was provided."""
result = CliRunner().invoke(
fake_project_cli, ["pipeline", "delete", "-y", bad_name], obj=fake_metadata
)
a... | Test error message when bad pipeline name was provided. | test_bad_pipeline_name | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_bad_env(self, fake_project_cli, fake_metadata):
"""Test error when provided conf environment does not exist."""
result = CliRunner().invoke(
fake_project_cli,
["pipeline", "delete", "-y", "-e", "invalid_env", PIPELINE_NAME],
obj=fake_metadata,
)
... | Test error when provided conf environment does not exist. | test_bad_env | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_pipeline_delete_confirmation(
self, fake_repo_path, fake_project_cli, fake_metadata, fake_package_path, input_
):
"""Test that user confirmation of deletion works"""
result = CliRunner().invoke(
fake_project_cli,
["pipeline", "delete", PIPELINE_NAME],
... | Test that user confirmation of deletion works | test_pipeline_delete_confirmation | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_pipeline_delete_confirmation_skip(
self, fake_repo_path, fake_project_cli, fake_metadata, fake_package_path, input_
):
"""Test that user confirmation of deletion works when
some of the files are missing or already deleted
"""
source_path = fake_package_path / "pipel... | Test that user confirmation of deletion works when
some of the files are missing or already deleted
| test_pipeline_delete_confirmation_skip | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_sync_target_exists(self, source, tmp_path):
"""Test _sync_dirs utility function if target exists."""
target = Path(tmp_path) / "target"
target.mkdir()
(target / "existing").mkdir()
(target / "existing" / "target_file").touch()
(target / "existing" / "common").wri... | Test _sync_dirs utility function if target exists. | test_sync_target_exists | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_sync_no_target(self, source, tmp_path):
"""Test _sync_dirs utility function if target doesn't exist."""
target = Path(tmp_path) / "target"
_sync_dirs(source, target)
assert (source / "existing" / "source_file").is_file()
assert (source / "existing" / "common").read_tex... | Test _sync_dirs utility function if target doesn't exist. | test_sync_no_target | python | kedro-org/kedro | tests/framework/cli/pipeline/test_pipeline.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/cli/pipeline/test_pipeline.py | Apache-2.0 |
def test_rich_traceback_configuration_extend_suppress(mocker, default_logging_config):
"""Test the configuration is not overrided but extend for `suppress`"""
import click
rich_traceback_install = mocker.patch("rich.traceback.install")
rich_pretty_install = mocker.patch("rich.pretty.install")
sys_... | Test the configuration is not overrided but extend for `suppress` | test_rich_traceback_configuration_extend_suppress | python | kedro-org/kedro | tests/framework/project/test_logging.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/project/test_logging.py | Apache-2.0 |
def mock_package_name_with_settings_file(tmpdir):
"""This mock settings file tests everything that can be customised in settings.py.
Where there are suggestions in the project template settings.py (e.g. as for
CONFIG_LOADER_CLASS), those suggestions should be tested."""
old_settings = settings.as_dict()... | This mock settings file tests everything that can be customised in settings.py.
Where there are suggestions in the project template settings.py (e.g. as for
CONFIG_LOADER_CLASS), those suggestions should be tested. | mock_package_name_with_settings_file | python | kedro-org/kedro | tests/framework/project/test_settings.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/project/test_settings.py | Apache-2.0 |
def mock_package_name_without_settings_file(tmpdir):
"""This mocks a project that doesn't have a settings.py file.
When configured, the project should have sensible default settings."""
package_name = "test_package_without_settings"
project_path, _, _ = str(tmpdir.mkdir(package_name)).rpartition(package... | This mocks a project that doesn't have a settings.py file.
When configured, the project should have sensible default settings. | mock_package_name_without_settings_file | python | kedro-org/kedro | tests/framework/project/test_settings.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/project/test_settings.py | Apache-2.0 |
def _assert_hook_call_record_has_expected_parameters(
call_record: logging.LogRecord, expected_parameters: list[str]
):
"""Assert the given call record has all expected parameters."""
for param in expected_parameters:
assert hasattr(call_record, param) | Assert the given call record has all expected parameters. | _assert_hook_call_record_has_expected_parameters | python | kedro-org/kedro | tests/framework/session/conftest.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/conftest.py | Apache-2.0 |
def logs_listener():
"""Fixture to start the logs listener before a test and clean up after the test finishes"""
listener = LogsListener()
listener.start()
yield listener
logger.removeHandler(listener.log_handler)
listener.stop() | Fixture to start the logs listener before a test and clean up after the test finishes | logs_listener | python | kedro-org/kedro | tests/framework/session/conftest.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/conftest.py | Apache-2.0 |
def create_attrs_autospec(spec: type, spec_set: bool = True) -> Any:
"""Creates a mock of an attr class (creates mocks recursively on all attributes).
https://github.com/python-attrs/attrs/issues/462#issuecomment-1134656377
:param spec: the spec to mock
:param spec_set: if True, AttributeError will be ... | Creates a mock of an attr class (creates mocks recursively on all attributes).
https://github.com/python-attrs/attrs/issues/462#issuecomment-1134656377
:param spec: the spec to mock
:param spec_set: if True, AttributeError will be raised if an attribute that is not in the spec is set.
| create_attrs_autospec | python | kedro-org/kedro | tests/framework/session/test_session.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/test_session.py | Apache-2.0 |
def test_git_describe(
self, fake_project, fake_commit_hash, fake_git_status, mocker
):
"""Test that git information is added to the session store"""
mocker.patch(
"subprocess.check_output",
side_effect=[fake_commit_hash.encode(), fake_git_status.encode()],
)
... | Test that git information is added to the session store | test_git_describe | python | kedro-org/kedro | tests/framework/session/test_session.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/test_session.py | Apache-2.0 |
def test_git_describe_error(self, fake_project, exception, mocker, caplog):
"""Test that git information is not added to the session store
if call to git fails
"""
caplog.set_level(logging.DEBUG, logger="kedro")
mocker.patch("subprocess.check_output", side_effect=exception)
... | Test that git information is not added to the session store
if call to git fails
| test_git_describe_error | python | kedro-org/kedro | tests/framework/session/test_session.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/test_session.py | Apache-2.0 |
def test_get_username_error(self, fake_project, mocker, caplog):
"""Test that username information is not added to the session store
if call to getuser() fails
"""
caplog.set_level(logging.DEBUG, logger="kedro")
mocker.patch("subprocess.check_output")
mocker.patch("getpa... | Test that username information is not added to the session store
if call to getuser() fails
| test_get_username_error | python | kedro-org/kedro | tests/framework/session/test_session.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/test_session.py | Apache-2.0 |
def test_log_error(self, fake_project):
"""Test logging the error by the session"""
# test that the error is not swallowed by the session
with pytest.raises(FakeException), KedroSession.create(fake_project) as session:
raise FakeException
exception = session.store["exception... | Test logging the error by the session | test_log_error | python | kedro-org/kedro | tests/framework/session/test_session.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/test_session.py | Apache-2.0 |
def test_run(
self,
fake_project,
fake_session_id,
fake_pipeline_name,
mock_context_class,
mock_runner,
mocker,
):
"""Test running the project via the session"""
mock_hook = mocker.patch(
"kedro.framework.session.session._create_ho... | Test running the project via the session | test_run | python | kedro-org/kedro | tests/framework/session/test_session.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/test_session.py | Apache-2.0 |
def test_run_multiple_times(
self,
fake_project,
fake_session_id,
fake_pipeline_name,
mock_context_class,
mock_runner,
mocker,
):
"""Test running the project more than once via the session"""
mock_hook = mocker.patch(
"kedro.framew... | Test running the project more than once via the session | test_run_multiple_times | python | kedro-org/kedro | tests/framework/session/test_session.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/test_session.py | Apache-2.0 |
def test_run_exception(
self,
fake_project,
fake_session_id,
fake_pipeline_name,
mock_context_class,
mock_runner,
mocker,
):
"""Test exception being raised during the run"""
mock_hook = mocker.patch(
"kedro.framework.session.session... | Test exception being raised during the run | test_run_exception | python | kedro-org/kedro | tests/framework/session/test_session.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/test_session.py | Apache-2.0 |
def test_run_broken_pipeline_multiple_times(
self,
fake_project,
fake_session_id,
fake_pipeline_name,
mock_context_class,
mock_runner,
mocker,
):
"""Test exception being raised during the first run and
a second run is allowed to be executed in ... | Test exception being raised during the first run and
a second run is allowed to be executed in the same session. | test_run_broken_pipeline_multiple_times | python | kedro-org/kedro | tests/framework/session/test_session.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/test_session.py | Apache-2.0 |
def test_calling_register_hooks_twice(self, project_hooks, mock_session):
"""Calling hook registration multiple times should not raise"""
hook_manager = mock_session._hook_manager
assert hook_manager.is_registered(project_hooks)
_register_hooks(hook_manager, (project_hooks,))
_r... | Calling hook registration multiple times should not raise | test_calling_register_hooks_twice | python | kedro-org/kedro | tests/framework/session/test_session_hook_manager.py | https://github.com/kedro-org/kedro/blob/master/tests/framework/session/test_session_hook_manager.py | Apache-2.0 |
def test_unresolve_credentials(self, correct_config):
"""Test unresolve dataset credentials to original format."""
config = correct_config["catalog"]
credentials = correct_config["credentials"]
resolved_configs = CatalogConfigResolver.resolve_credentials(
config, credentials
... | Test unresolve dataset credentials to original format. | test_unresolve_credentials | python | kedro-org/kedro | tests/io/test_catalog_config_resolver.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_catalog_config_resolver.py | Apache-2.0 |
def test_unresolve_credentials_two_keys(self, correct_config):
"""Test unresolve dataset credentials to original format when two credentials keys provided."""
config = correct_config["catalog"]
credentials = correct_config["credentials"]
resolved_configs = CatalogConfigResolver.resolve_... | Test unresolve dataset credentials to original format when two credentials keys provided. | test_unresolve_credentials_two_keys | python | kedro-org/kedro | tests/io/test_catalog_config_resolver.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_catalog_config_resolver.py | Apache-2.0 |
def test_parse_dataset_definition_invalid_uppercase_s_in_dataset(self):
"""Test that an invalid dataset type with uppercase 'S' in 'Dataset' raises a warning"""
config = {"type": "LambdaDataSet"} # Invalid type with uppercase 'S'
# Check that the warning is issued
with pytest.warns(
... | Test that an invalid dataset type with uppercase 'S' in 'Dataset' raises a warning | test_parse_dataset_definition_invalid_uppercase_s_in_dataset | python | kedro-org/kedro | tests/io/test_core.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_core.py | Apache-2.0 |
def test_version_str_repr(self, load_version, save_version):
"""Test that version is in string representation of the class instance
when applicable."""
filepath = "test.csv"
ds_versioned = MyVersionedDataset(
filepath=filepath, version=Version(load_version, save_version)
... | Test that version is in string representation of the class instance
when applicable. | test_version_str_repr | python | kedro-org/kedro | tests/io/test_core.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_core.py | Apache-2.0 |
def test_save_and_load(self, my_versioned_dataset, dummy_data):
"""Test that saved and reloaded data matches the original one for
the versioned dataset."""
my_versioned_dataset.save(dummy_data)
reloaded = my_versioned_dataset.load()
assert dummy_data == reloaded | Test that saved and reloaded data matches the original one for
the versioned dataset. | test_save_and_load | python | kedro-org/kedro | tests/io/test_core.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_core.py | Apache-2.0 |
def test_no_versions(self, my_versioned_dataset):
"""Check the error if no versions are available for load."""
pattern = r"Did not find any versions for MyVersionedDataset\(.+\)"
with pytest.raises(DatasetError, match=pattern):
my_versioned_dataset.load() | Check the error if no versions are available for load. | test_no_versions | python | kedro-org/kedro | tests/io/test_core.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_core.py | Apache-2.0 |
def test_local_exists(self, dummy_data):
"""Check the error if no versions are available for load (_local_exists())."""
version = Version(load=None, save=None)
my_versioned_dataset = MyLocalVersionedDataset("test.csv", version=version)
assert my_versioned_dataset.exists() is False
... | Check the error if no versions are available for load (_local_exists()). | test_local_exists | python | kedro-org/kedro | tests/io/test_core.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_core.py | Apache-2.0 |
def test_exists_general_exception(self):
"""Check if all exceptions are shown as DatasetError for exists() check"""
version = Version(load=None, save=None)
my_other_versioned_dataset = MyOtherVersionedDataset(
"test.csv", version=version
)
# Override the _exists() fun... | Check if all exceptions are shown as DatasetError for exists() check | test_exists_general_exception | python | kedro-org/kedro | tests/io/test_core.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_core.py | Apache-2.0 |
def test_exists(self, my_versioned_dataset, dummy_data):
"""Test `exists` method invocation for versioned dataset."""
assert not my_versioned_dataset.exists()
my_versioned_dataset.save(dummy_data)
assert my_versioned_dataset.exists()
shutil.rmtree(my_versioned_dataset._filepath) | Test `exists` method invocation for versioned dataset. | test_exists | python | kedro-org/kedro | tests/io/test_core.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_core.py | Apache-2.0 |
def test_prevent_overwrite(self, my_versioned_dataset, dummy_data):
"""Check the error when attempting to override the dataset if the
corresponding json file for a given save version already exists."""
my_versioned_dataset.save(dummy_data)
pattern = (
r"Save path \'.+\' for M... | Check the error when attempting to override the dataset if the
corresponding json file for a given save version already exists. | test_prevent_overwrite | python | kedro-org/kedro | tests/io/test_core.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_core.py | Apache-2.0 |
def test_save_version_warning(
self, my_versioned_dataset, load_version, save_version, dummy_data
):
"""Check the warning when saving to the path that differs from
the subsequent load path."""
pattern = (
f"Save version '{save_version}' did not match "
f"load ... | Check the warning when saving to the path that differs from
the subsequent load path. | test_save_version_warning | python | kedro-org/kedro | tests/io/test_core.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_core.py | Apache-2.0 |
def test_versioning_existing_dataset(
self, my_dataset, my_versioned_dataset, dummy_data
):
"""Check the error when attempting to save a versioned dataset on top of an
already existing (non-versioned) dataset."""
my_dataset.save(dummy_data)
assert my_dataset.exists()
... | Check the error when attempting to save a versioned dataset on top of an
already existing (non-versioned) dataset. | test_versioning_existing_dataset | python | kedro-org/kedro | tests/io/test_core.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_core.py | Apache-2.0 |
def test_saving_none(self, my_legacy_dataset):
"""Check the error when attempting to save the dataset without
providing the data"""
pattern = r"Saving 'None' to a 'Dataset' is not allowed"
with pytest.raises(DatasetError, match=pattern):
my_legacy_dataset.save(None) | Check the error when attempting to save the dataset without
providing the data | test_saving_none | python | kedro-org/kedro | tests/io/test_core.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_core.py | Apache-2.0 |
def test_save_and_load(self, data_catalog, dummy_dataframe):
"""Test saving and reloading the dataset"""
data_catalog.save("test", dummy_dataframe)
reloaded_df = data_catalog.load("test")
assert_frame_equal(reloaded_df, dummy_dataframe) | Test saving and reloading the dataset | test_save_and_load | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_add_save_and_load(self, dataset, dummy_dataframe):
"""Test adding and then saving and reloading the dataset"""
catalog = DataCatalog(datasets={})
catalog.add("test", dataset)
catalog.save("test", dummy_dataframe)
reloaded_df = catalog.load("test")
assert_frame_e... | Test adding and then saving and reloading the dataset | test_add_save_and_load | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_add_all_save_and_load(self, dataset, dummy_dataframe):
"""Test adding all to the data catalog and then saving and reloading
the dataset"""
catalog = DataCatalog(datasets={})
catalog.add_all({"test": dataset})
catalog.save("test", dummy_dataframe)
reloaded_df = ca... | Test adding all to the data catalog and then saving and reloading
the dataset | test_add_all_save_and_load | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_load_error(self, data_catalog):
"""Check the error when attempting to load a dataset
from nonexistent source"""
pattern = r"Failed while loading data from dataset CSVDataset"
with pytest.raises(DatasetError, match=pattern):
data_catalog.load("test") | Check the error when attempting to load a dataset
from nonexistent source | test_load_error | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_add_dataset_twice(self, data_catalog, dataset):
"""Check the error when attempting to add the dataset twice"""
pattern = r"Dataset 'test' has already been registered"
with pytest.raises(DatasetAlreadyExistsError, match=pattern):
data_catalog.add("test", dataset) | Check the error when attempting to add the dataset twice | test_add_dataset_twice | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_load_from_unregistered(self):
"""Check the error when attempting to load unregistered dataset"""
catalog = DataCatalog(datasets={})
pattern = r"Dataset 'test' not found in the catalog"
with pytest.raises(DatasetNotFoundError, match=pattern):
catalog.load("test") | Check the error when attempting to load unregistered dataset | test_load_from_unregistered | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_save_to_unregistered(self, dummy_dataframe):
"""Check the error when attempting to save to unregistered dataset"""
catalog = DataCatalog(datasets={})
pattern = r"Dataset 'test' not found in the catalog"
with pytest.raises(DatasetNotFoundError, match=pattern):
catalog... | Check the error when attempting to save to unregistered dataset | test_save_to_unregistered | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_feed_dict(self, memory_catalog, conflicting_feed_dict):
"""Test feed dict overriding some of the datasets"""
memory_catalog.add_feed_dict(conflicting_feed_dict, replace=True)
assert "data" in memory_catalog.load("ds1")
assert memory_catalog.load("ds1")["data"] == 0
asser... | Test feed dict overriding some of the datasets | test_feed_dict | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_exists_not_implemented(self, caplog):
"""Test calling `exists` on the dataset, which didn't implement it"""
catalog = DataCatalog(datasets={"test": LambdaDataset(None, None)})
result = catalog.exists("test")
log_record = caplog.records[0]
assert log_record.levelname == ... | Test calling `exists` on the dataset, which didn't implement it | test_exists_not_implemented | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_release_unregistered(self, data_catalog):
"""Check the error when calling `release` on unregistered dataset"""
pattern = r"Dataset \'wrong_key\' not found in the catalog"
with pytest.raises(DatasetNotFoundError, match=pattern) as e:
data_catalog.release("wrong_key")
... | Check the error when calling `release` on unregistered dataset | test_release_unregistered | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_release_unregistered_typo(self, data_catalog):
"""Check the error when calling `release` on mistyped dataset"""
pattern = (
"Dataset 'text' not found in the catalog"
" - did you mean one of these instead: test"
)
with pytest.raises(DatasetNotFoundError, m... | Check the error when calling `release` on mistyped dataset | test_release_unregistered_typo | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_multi_catalog_list(self, multi_catalog):
"""Test data catalog which contains multiple datasets"""
entries = multi_catalog.list()
assert "abc" in entries
assert "xyz" in entries | Test data catalog which contains multiple datasets | test_multi_catalog_list | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_multi_catalog_list_bad_regex(self, multi_catalog):
"""Test that bad regex is caught accordingly"""
escaped_regex = r"\(\("
pattern = f"Invalid regular expression provided: '{escaped_regex}'"
with pytest.raises(SyntaxError, match=pattern):
multi_catalog.list("((") | Test that bad regex is caught accordingly | test_multi_catalog_list_bad_regex | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_datasets_on_init(self, data_catalog_from_config):
"""Check datasets are loaded correctly on construction"""
assert isinstance(data_catalog_from_config.datasets.boats, CSVDataset)
assert isinstance(data_catalog_from_config.datasets.cars, CSVDataset) | Check datasets are loaded correctly on construction | test_datasets_on_init | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_datasets_on_add(self, data_catalog_from_config):
"""Check datasets are updated correctly after adding"""
data_catalog_from_config.add("new_dataset", CSVDataset(filepath="some_path"))
assert isinstance(data_catalog_from_config.datasets.new_dataset, CSVDataset)
assert isinstance(d... | Check datasets are updated correctly after adding | test_datasets_on_add | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_adding_datasets_not_allowed(self, data_catalog_from_config):
"""Check error if user tries to update the datasets attribute"""
pattern = r"Please use DataCatalog.add\(\) instead"
with pytest.raises(AttributeError, match=pattern):
data_catalog_from_config.datasets.new_dataset ... | Check error if user tries to update the datasets attribute | test_adding_datasets_not_allowed | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_add_feed_dict_should_grow_linearly(self, mocker, data_catalog_from_config):
"""Check number of calls to `_sub_nonword_chars` when adding feed dict
should grow linearly with the number of keys in the dict.
Simulate this issue: https://github.com/kedro-org/kedro/issues/951
"""
... | Check number of calls to `_sub_nonword_chars` when adding feed dict
should grow linearly with the number of keys in the dict.
Simulate this issue: https://github.com/kedro-org/kedro/issues/951
| test_add_feed_dict_should_grow_linearly | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_from_correct_config(self, data_catalog_from_config, dummy_dataframe):
"""Test populating the data catalog from config"""
data_catalog_from_config.save("boats", dummy_dataframe)
reloaded_df = data_catalog_from_config.load("boats")
assert_frame_equal(reloaded_df, dummy_dataframe) | Test populating the data catalog from config | test_from_correct_config | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_config_missing_type(self, correct_config):
"""Check the error if type attribute is missing for some dataset(s)
in the config"""
del correct_config["catalog"]["boats"]["type"]
pattern = (
"An exception occurred when parsing config for dataset 'boats':\n"
"... | Check the error if type attribute is missing for some dataset(s)
in the config | test_config_missing_type | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_config_invalid_module(self, correct_config):
"""Check the error if the type points to nonexistent module"""
correct_config["catalog"]["boats"]["type"] = (
"kedro.invalid_module_name.io.CSVDataset"
)
error_msg = "No module named 'kedro.invalid_module_name'"
w... | Check the error if the type points to nonexistent module | test_config_invalid_module | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_config_relative_import(self, correct_config):
"""Check the error if the type points to a relative import"""
correct_config["catalog"]["boats"]["type"] = ".CSVDatasetInvalid"
pattern = "'type' class path does not support relative paths"
with pytest.raises(DatasetError, match=re.... | Check the error if the type points to a relative import | test_config_relative_import | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_config_import_kedro_datasets(self, correct_config, mocker):
"""Test kedro_datasets default path to the dataset class"""
# Spy _load_obj because kedro_datasets is not installed and we can't import it.
import kedro.io.core
spy = mocker.spy(kedro.io.core, "_load_obj")
par... | Test kedro_datasets default path to the dataset class | test_config_import_kedro_datasets | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_config_missing_class(self, correct_config):
"""Check the error if the type points to nonexistent class"""
correct_config["catalog"]["boats"]["type"] = "kedro.io.CSVDatasetInvalid"
with pytest.raises(DatasetError) as exc_info:
DataCatalog.from_config(**correct_config)
... | Check the error if the type points to nonexistent class | test_config_missing_class | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_config_invalid_dataset(self, correct_config):
"""Check the error if the type points to invalid class"""
correct_config["catalog"]["boats"]["type"] = "DataCatalog"
pattern = (
"An exception occurred when parsing config for dataset 'boats':\n"
"Dataset type 'kedro.... | Check the error if the type points to invalid class | test_config_invalid_dataset | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_config_invalid_arguments(self, correct_config):
"""Check the error if the dataset config contains invalid arguments"""
correct_config["catalog"]["boats"]["save_and_load_args"] = False
pattern = (
r"Dataset 'boats' must only contain arguments valid for "
r"the con... | Check the error if the dataset config contains invalid arguments | test_config_invalid_arguments | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_config_invalid_class_path_format(self, correct_config):
"""Check the error if the dataset type has an invalid format causing ValueError"""
# An invalid type path that doesn't include a dot or is otherwise malformed
correct_config["catalog"]["boats"]["type"] = "InvalidFormatNoDot"
... | Check the error if the dataset type has an invalid format causing ValueError | test_config_invalid_class_path_format | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_missing_credentials(self, correct_config):
"""Check the error if credentials can't be located"""
correct_config["catalog"]["cars"]["credentials"] = "missing"
with pytest.raises(KeyError, match=r"Unable to find credentials \'missing\'"):
DataCatalog.from_config(**correct_conf... | Check the error if credentials can't be located | test_missing_credentials | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_link_credentials(self, correct_config, mocker):
"""Test credentials being linked to the relevant dataset"""
mock_client = mocker.patch("kedro_datasets.pandas.csv_dataset.fsspec")
config = deepcopy(correct_config)
del config["catalog"]["boats"]
DataCatalog.from_config(**... | Test credentials being linked to the relevant dataset | test_link_credentials | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_idempotent_catalog(self, correct_config):
"""Test that data catalog instantiations are idempotent"""
_ = DataCatalog.from_config(**correct_config)
catalog = DataCatalog.from_config(**correct_config)
assert catalog | Test that data catalog instantiations are idempotent | test_idempotent_catalog | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_error_dataset_init(self, bad_config):
"""Check the error when trying to instantiate erroneous dataset"""
pattern = r"Failed to instantiate dataset \'bad\' of type '.*BadDataset'"
with pytest.raises(DatasetError, match=pattern):
DataCatalog.from_config(bad_config, None) | Check the error when trying to instantiate erroneous dataset | test_error_dataset_init | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_bad_confirm(self, correct_config, dataset_name, pattern):
"""Test confirming non existent dataset or the one that
does not have `confirm` method"""
data_catalog = DataCatalog.from_config(**correct_config)
with pytest.raises(DatasetError, match=re.escape(pattern)):
da... | Test confirming non existent dataset or the one that
does not have `confirm` method | test_bad_confirm | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
def test_from_correct_config_versioned(self, correct_config, dummy_dataframe):
"""Test load and save of versioned datasets from config"""
correct_config["catalog"]["boats"]["versioned"] = True
# Decompose `generate_timestamp` to keep `current_ts` reference.
current_ts = datetime.now(tz=... | Test load and save of versioned datasets from config | test_from_correct_config_versioned | python | kedro-org/kedro | tests/io/test_data_catalog.py | https://github.com/kedro-org/kedro/blob/master/tests/io/test_data_catalog.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.