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

feat: align test suits #39

Merged
merged 5 commits into from
Sep 3, 2024
Merged

feat: align test suits #39

merged 5 commits into from
Sep 3, 2024

Conversation

AlexTheWizardL
Copy link
Collaborator

This PR covers changes that align test suits to a common standard.

  1. Removed docstrings from test suits and renamed them instead. Example:

from:

def test_keep_extra_columns() -> None:
    """Test dropping columns not in the required or optional lists."""

to:

def test_drop_extra_columns_with_keep_extra_columns_false():
  1. Deleted useless branches of code that are not possible by the system, specifically we can not have entries with the same ID.
    Example (this code is removed):
elif len(result) > 1:
            raise ValueError(f"Multiple paths found for account category id: {id}")
  1. Removed useless type hints for the fixtures and tests suits. For further details, see the discussions on type annotations for fixtures, the pytest documentation and the Django project.

@AlexTheWizardL AlexTheWizardL requested a review from lasuk July 5, 2024 06:11
Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Flag Coverage Δ
unittests 93.86% <100.00%> (+0.72%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cashctrl_api/cashed_client.py 94.02% <ø> (+1.83%) ⬆️
cashctrl_api/client.py 92.95% <100.00%> (ø)

Copy link
Contributor

@lasuk lasuk left a comment

Choose a reason for hiding this comment

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

Thanks for streamlining unit tests. I left a few minor comments. Back to you @AlexTheWizardL .

@@ -6,13 +6,11 @@


def random_word(length: int) -> str:
"""Generate a random word using lowercase letters."""
Copy link
Contributor

Choose a reason for hiding this comment

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

I found this comment helpful and would leave it.

@@ -7,101 +7,83 @@


@pytest.fixture(scope="module")
Copy link
Contributor

Choose a reason for hiding this comment

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

Any benefit of using a fixture?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only lines of code are reduced since no need to define a class instance in every test suit

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Decided on the meeting to remove fixture for this case

@@ -7,101 +7,83 @@


@pytest.fixture(scope="module")
def cc_client() -> CachedCashCtrlClient:
def cc_client():
return CachedCashCtrlClient()


@pytest.fixture(scope="module")
Copy link
Contributor

Choose a reason for hiding this comment

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

Any benefit of using a fixture?

return CachedCashCtrlClient()


@pytest.fixture(scope="module")
def accounts() -> pd.DataFrame:
def accounts():
"""Explicitly call the base class method to circumvent the cache."""
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a comment, not a docstring.
Applies to all test_cached_....

return CachedCashCtrlClient()


@pytest.fixture(scope="module")
def accounts() -> pd.DataFrame:
def accounts():
"""Explicitly call the base class method to circumvent the cache."""
cc_client = CachedCashCtrlClient()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this in line with the comment 'Explicitly call the base class method to circumvent the cache.'?

Also applies to test_cached_accounts.py, test_cached_tax_rates.py, test_cached_tax_rates.py

def mock_directory(tmp_path: Path) -> Path:
def mock_directory(tmp_path: Path):
Copy link
Contributor

Choose a reason for hiding this comment

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

I found a return type hint for fixtures and other local helper functions helpful.
Let's discuss which is better

@lasuk
Copy link
Contributor

lasuk commented Sep 3, 2024

Merging. Thanks for the changes!

@lasuk lasuk merged commit 2a9a8bd into main Sep 3, 2024
6 checks passed
@lasuk lasuk deleted the feat/align-test-suits branch September 3, 2024 15:45
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.

2 participants