Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewriting the IPython test #2046

Merged
merged 8 commits into from
Dec 7, 2022
Merged

Rewriting the IPython test #2046

merged 8 commits into from
Dec 7, 2022

Conversation

noklam
Copy link
Contributor

@noklam noklam commented Nov 21, 2022

Signed-off-by: Nok Chan [email protected]

NOTE: Kedro datasets are moving from kedro.extras.datasets to a separate kedro-datasets package in
kedro-plugins repository. Any changes to the dataset implementations
should be done by opening a pull request in that repository.

Description

Fix #1839

Development notes

The plan is to break down TestLoadKedroObjects into proper unit tests. the original tests are testing many things at the same time and arguably duplicated. The e2e behaviour is tested in behave already, so this test should really just focus on one thing at a time. This can reduce the mocking a little bit (a few mocking are still needed), but they are now easier to reason.

Main Changes:

  • Remove all the mocking of IPython when possible, replace with the ipython fixture instead
  • Remove the duplicate tests - tests are now more atomic with single focus - there are more but shorter tests.
  • Bug fixes - previously the assertion about pipeline are wrong
  • Mock the pipelines object instead of _ProjectPipelines, previously the tests will pass/fail sometimes because of the order of instantiation of the global or mocking sometimes flipped.

Notes:

self._hook_manager.hook.after_context_created( # pylint: disable=no-member
context=context
)

_ProjectPipelines is supposed to be lazy-loaded, but I found out that this line of code triggers the _load_data twice for some reason. Need more investigation.

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the RELEASE.md file
  • Added tests to cover my changes

@noklam noklam linked an issue Nov 21, 2022 that may be closed by this pull request
@AhdraMeraliQB AhdraMeraliQB mentioned this pull request Nov 30, 2022
5 tasks
@noklam noklam marked this pull request as ready for review December 4, 2022 23:42
@noklam noklam requested a review from idanov as a code owner December 4, 2022 23:42
Copy link
Member

@merelcht merelcht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are so much cleaner and easier to follow now! Great work on refactoring them ⭐

_ProjectPipelines is supposed to be lazy-loaded, but I found out that this line of code triggers the _load_data twice for some reason. Need more investigation.

Did you already found out what's happening with the above or do we need a follow up issue for that?

PROJECT_NAME = "fake_project_name"
PROJECT_VERSION = "0.1"
@pytest.fixture(autouse=True)
def fake_metadata(tmp_path):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup here in making this a fixture 🧹

@AhdraMeraliQB AhdraMeraliQB merged commit 5c7b051 into main Dec 7, 2022
@AhdraMeraliQB AhdraMeraliQB deleted the fix/ipython_test branch December 7, 2022 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rewrite IPython extension tests
3 participants