-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update example tests on kedro-starters templates (#261)
* Update example tests Signed-off-by: Laura Couto <[email protected]> * Remove unused fixture Signed-off-by: Laura Couto <[email protected]> * Base example tests on KedroSession Signed-off-by: Laura Couto <[email protected]> * Handle config loader tests through the session Signed-off-by: Laura Couto <[email protected]> * Add a little runner test Signed-off-by: Laura Couto <[email protected]> * Simplify session.run() test Signed-off-by: Laura Couto <[email protected]> --------- Signed-off-by: Laura Couto <[email protected]>
- Loading branch information
Showing
6 changed files
with
66 additions
and
169 deletions.
There are no files selected for viewing
39 changes: 11 additions & 28 deletions
39
astro-airflow-iris/{{ cookiecutter.repo_name }}/tests/test_run.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,20 @@ | ||
""" | ||
This module contains an example test. | ||
This module contains example tests for a Kedro project. | ||
Tests should be placed in ``src/tests``, in modules that mirror your | ||
project's structure, and in files named test_*.py. They are simply functions | ||
named ``test_*`` which test a unit of logic. | ||
project's structure, and in files named test_*.py. | ||
""" | ||
from pathlib import Path | ||
|
||
import pytest | ||
from kedro.config import OmegaConfigLoader | ||
from kedro.framework.context import KedroContext | ||
from kedro.framework.hooks import _create_hook_manager | ||
|
||
|
||
@pytest.fixture | ||
def config_loader(): | ||
return OmegaConfigLoader(conf_source=str(Path.cwd())) | ||
|
||
|
||
@pytest.fixture | ||
def project_context(config_loader): | ||
return KedroContext( | ||
package_name="{{ cookiecutter.python_package }}", | ||
project_path=Path.cwd(), | ||
env="local", | ||
config_loader=config_loader, | ||
hook_manager=_create_hook_manager(), | ||
) | ||
|
||
from kedro.framework.session import KedroSession | ||
from kedro.framework.startup import bootstrap_project | ||
|
||
# The tests below are here for the demonstration purpose | ||
# and should be replaced with the ones testing the project | ||
# functionality | ||
class TestProjectContext: | ||
def test_project_path(self, project_context): | ||
assert project_context.project_path == Path.cwd() | ||
|
||
class TestKedroRun: | ||
def test_kedro_run(self): | ||
bootstrap_project(Path.cwd()) | ||
|
||
with KedroSession.create(project_path=Path.cwd()) as session: | ||
assert session.run() is not None |
40 changes: 11 additions & 29 deletions
40
databricks-iris/{{ cookiecutter.repo_name }}/tests/test_run.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,20 @@ | ||
""" | ||
This module contains an example test. | ||
This module contains example tests for a Kedro project. | ||
Tests should be placed in ``src/tests``, in modules that mirror your | ||
project's structure, and in files named test_*.py. They are simply functions | ||
named ``test_*`` which test a unit of logic. | ||
project's structure, and in files named test_*.py. | ||
""" | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
from kedro.config import OmegaConfigLoader | ||
from kedro.framework.context import KedroContext | ||
from kedro.framework.hooks import _create_hook_manager | ||
|
||
|
||
@pytest.fixture | ||
def config_loader(): | ||
return OmegaConfigLoader(conf_source=str(Path.cwd())) | ||
|
||
|
||
@pytest.fixture | ||
def project_context(config_loader): | ||
return KedroContext( | ||
package_name="{{ cookiecutter.python_package }}", | ||
project_path=Path.cwd(), | ||
env="local", | ||
config_loader=config_loader, | ||
hook_manager=_create_hook_manager(), | ||
) | ||
|
||
from kedro.framework.session import KedroSession | ||
from kedro.framework.startup import bootstrap_project | ||
|
||
# The tests below are here for the demonstration purpose | ||
# and should be replaced with the ones testing the project | ||
# functionality | ||
class TestProjectContext: | ||
def test_project_path(self, project_context): | ||
assert project_context.project_path == Path.cwd() | ||
|
||
class TestKedroRun: | ||
def test_kedro_run(self): | ||
bootstrap_project(Path.cwd()) | ||
|
||
with KedroSession.create(project_path=Path.cwd()) as session: | ||
assert session.run() is not None |
39 changes: 11 additions & 28 deletions
39
spaceflights-pandas-viz/{{ cookiecutter.repo_name }}/tests/test_run.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,20 @@ | ||
""" | ||
This module contains an example test. | ||
This module contains example tests for a Kedro project. | ||
Tests should be placed in ``src/tests``, in modules that mirror your | ||
project's structure, and in files named test_*.py. They are simply functions | ||
named ``test_*`` which test a unit of logic. | ||
project's structure, and in files named test_*.py. | ||
""" | ||
from pathlib import Path | ||
|
||
import pytest | ||
from kedro.config import OmegaConfigLoader | ||
from kedro.framework.context import KedroContext | ||
from kedro.framework.hooks import _create_hook_manager | ||
|
||
|
||
@pytest.fixture | ||
def config_loader(): | ||
return OmegaConfigLoader(conf_source=str(Path.cwd())) | ||
|
||
|
||
@pytest.fixture | ||
def project_context(config_loader): | ||
return KedroContext( | ||
package_name="{{ cookiecutter.python_package }}", | ||
project_path=Path.cwd(), | ||
env="local", | ||
config_loader=config_loader, | ||
hook_manager=_create_hook_manager(), | ||
) | ||
|
||
from kedro.framework.session import KedroSession | ||
from kedro.framework.startup import bootstrap_project | ||
|
||
# The tests below are here for the demonstration purpose | ||
# and should be replaced with the ones testing the project | ||
# functionality | ||
class TestProjectContext: | ||
def test_project_path(self, project_context): | ||
assert project_context.project_path == Path.cwd() | ||
|
||
class TestKedroRun: | ||
def test_kedro_run(self): | ||
bootstrap_project(Path.cwd()) | ||
|
||
with KedroSession.create(project_path=Path.cwd()) as session: | ||
assert session.run() is not None |
39 changes: 11 additions & 28 deletions
39
spaceflights-pandas/{{ cookiecutter.repo_name }}/tests/test_run.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,20 @@ | ||
""" | ||
This module contains an example test. | ||
This module contains example tests for a Kedro project. | ||
Tests should be placed in ``src/tests``, in modules that mirror your | ||
project's structure, and in files named test_*.py. They are simply functions | ||
named ``test_*`` which test a unit of logic. | ||
project's structure, and in files named test_*.py. | ||
""" | ||
from pathlib import Path | ||
|
||
import pytest | ||
from kedro.config import OmegaConfigLoader | ||
from kedro.framework.context import KedroContext | ||
from kedro.framework.hooks import _create_hook_manager | ||
|
||
|
||
@pytest.fixture | ||
def config_loader(): | ||
return OmegaConfigLoader(conf_source=str(Path.cwd())) | ||
|
||
|
||
@pytest.fixture | ||
def project_context(config_loader): | ||
return KedroContext( | ||
package_name="{{ cookiecutter.python_package }}", | ||
project_path=Path.cwd(), | ||
env="local", | ||
config_loader=config_loader, | ||
hook_manager=_create_hook_manager(), | ||
) | ||
|
||
from kedro.framework.session import KedroSession | ||
from kedro.framework.startup import bootstrap_project | ||
|
||
# The tests below are here for the demonstration purpose | ||
# and should be replaced with the ones testing the project | ||
# functionality | ||
class TestProjectContext: | ||
def test_project_path(self, project_context): | ||
assert project_context.project_path == Path.cwd() | ||
|
||
class TestKedroRun: | ||
def test_kedro_run(self): | ||
bootstrap_project(Path.cwd()) | ||
|
||
with KedroSession.create(project_path=Path.cwd()) as session: | ||
assert session.run() is not None |
39 changes: 11 additions & 28 deletions
39
spaceflights-pyspark-viz/{{ cookiecutter.repo_name }}/tests/test_run.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,20 @@ | ||
""" | ||
This module contains an example test. | ||
This module contains example tests for a Kedro project. | ||
Tests should be placed in ``src/tests``, in modules that mirror your | ||
project's structure, and in files named test_*.py. They are simply functions | ||
named ``test_*`` which test a unit of logic. | ||
project's structure, and in files named test_*.py. | ||
""" | ||
from pathlib import Path | ||
|
||
import pytest | ||
from kedro.config import OmegaConfigLoader | ||
from kedro.framework.context import KedroContext | ||
from kedro.framework.hooks import _create_hook_manager | ||
|
||
|
||
@pytest.fixture | ||
def config_loader(): | ||
return OmegaConfigLoader(conf_source=str(Path.cwd())) | ||
|
||
|
||
@pytest.fixture | ||
def project_context(config_loader): | ||
return KedroContext( | ||
package_name="{{ cookiecutter.python_package }}", | ||
project_path=Path.cwd(), | ||
env="local", | ||
config_loader=config_loader, | ||
hook_manager=_create_hook_manager(), | ||
) | ||
|
||
from kedro.framework.session import KedroSession | ||
from kedro.framework.startup import bootstrap_project | ||
|
||
# The tests below are here for the demonstration purpose | ||
# and should be replaced with the ones testing the project | ||
# functionality | ||
class TestProjectContext: | ||
def test_project_path(self, project_context): | ||
assert project_context.project_path == Path.cwd() | ||
|
||
class TestKedroRun: | ||
def test_kedro_run(self): | ||
bootstrap_project(Path.cwd()) | ||
|
||
with KedroSession.create(project_path=Path.cwd()) as session: | ||
assert session.run() is not None |
39 changes: 11 additions & 28 deletions
39
spaceflights-pyspark/{{ cookiecutter.repo_name }}/tests/test_run.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,20 @@ | ||
""" | ||
This module contains an example test. | ||
This module contains example tests for a Kedro project. | ||
Tests should be placed in ``src/tests``, in modules that mirror your | ||
project's structure, and in files named test_*.py. They are simply functions | ||
named ``test_*`` which test a unit of logic. | ||
project's structure, and in files named test_*.py. | ||
""" | ||
from pathlib import Path | ||
|
||
import pytest | ||
from kedro.config import OmegaConfigLoader | ||
from kedro.framework.context import KedroContext | ||
from kedro.framework.hooks import _create_hook_manager | ||
|
||
|
||
@pytest.fixture | ||
def config_loader(): | ||
return OmegaConfigLoader(conf_source=str(Path.cwd())) | ||
|
||
|
||
@pytest.fixture | ||
def project_context(config_loader): | ||
return KedroContext( | ||
package_name="{{ cookiecutter.python_package }}", | ||
project_path=Path.cwd(), | ||
env="local", | ||
config_loader=config_loader, | ||
hook_manager=_create_hook_manager(), | ||
) | ||
|
||
from kedro.framework.session import KedroSession | ||
from kedro.framework.startup import bootstrap_project | ||
|
||
# The tests below are here for the demonstration purpose | ||
# and should be replaced with the ones testing the project | ||
# functionality | ||
class TestProjectContext: | ||
def test_project_path(self, project_context): | ||
assert project_context.project_path == Path.cwd() | ||
|
||
class TestKedroRun: | ||
def test_kedro_run(self): | ||
bootstrap_project(Path.cwd()) | ||
|
||
with KedroSession.create(project_path=Path.cwd()) as session: | ||
assert session.run() is not None |