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

Parameterized testing examples utilizing happy path fixture #10480

Merged
merged 11 commits into from
Aug 7, 2024

Conversation

QMalcolm
Copy link
Contributor

@QMalcolm QMalcolm commented Jul 23, 2024

Resolves #10287

Problem

We lacked broad parameterized testing examples using the happy path fixture.

Solution

Make some parameterized happy path testing examples.

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

ChenyuLInx and others added 8 commits June 26, 2024 12:22
The commit c783a86 removed the snapshot file from the happy path fixture.
This was done because the snapshot was breaking the tests we were adding,
`test_run_commands`. However this broke `test_ls` in `test_list.py`. In order
to move forward, we need everything to be working. Maybe the idea was to delete
the `test_list.py` file, however that is not noted anywhere, and was not done.
Thus this commit ensures that test is not broken nor or new tests.
@cla-bot cla-bot bot added the cla:yes label Jul 23, 2024
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.84%. Comparing base (21a4633) to head (fd075ec).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10480   +/-   ##
=======================================
  Coverage   88.84%   88.84%           
=======================================
  Files         180      180           
  Lines       22717    22717           
=======================================
+ Hits        20182    20183    +1     
+ Misses       2535     2534    -1     
Flag Coverage Δ
integration 86.07% <ø> (+<0.01%) ⬆️
unit 62.31% <ø> (ø)

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

Components Coverage Δ
Unit Tests 62.31% <ø> (ø)
Integration Tests 86.07% <ø> (+<0.01%) ⬆️

@QMalcolm QMalcolm added the Skip Changelog Skips GHA to check for changelog file label Aug 6, 2024
@QMalcolm QMalcolm marked this pull request as ready for review August 6, 2024 19:39
@QMalcolm QMalcolm requested a review from a team as a code owner August 6, 2024 19:39
@QMalcolm QMalcolm changed the title Cl/happy path scretch Parameterized testing examples utilizing happy path fixture Aug 6, 2024
Copy link
Contributor

@ChenyuLInx ChenyuLInx left a comment

Choose a reason for hiding this comment

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

Looks mostly good to me! I will leave the approval to whoever haven't touched this file.

Seems to be database related. Ideally snapshots should work in these tests. It's a bad sign that they don't. That
may have more to do with our fixture setup than the source code though.

Note: that the `happy_path_fixture_files` are a _class_ based fixture. Thus although this fixture _modifies_ the
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for this comment!

"macro",
"exposure",
"group",
"unit_test",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why unit_test is excluded here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current happy_path_project fixture doesn't have any unit tests. Thus when the test is run against the unit_test resource type, the following failure is the result.

___________________________________________________ TestSelectResourceType.test_select_by_resource_type[unit_test] ___________________________________________________

self = <test_commands.TestSelectResourceType object at 0x1233d1ed0>, resource_type = 'unit_test'
happy_path_project = <dbt.tests.fixtures.project.TestProjInfo object at 0x1233ab0d0>, runner = <dbt.cli.main.dbtRunner object at 0x12742ee90>
catcher = EventCatcher(event_to_catch=<class 'dbt.events.types.NoNodesSelected'>, caught_events=[info {
  name: "NoNodesSelected"  seconds: 1723041301
    nanos: 398960000
  }
}
data {
}
], predicate=<function EventCatcher.<lambda> at 0x1233c4790>)

    @pytest.mark.parametrize("resource_type", resource_types)
    def test_select_by_resource_type(
        self,
        resource_type: str,
        happy_path_project,
        runner: dbtRunner,
        catcher: EventCatcher,
    ) -> None:
        runner.invoke(["list", "--select", f"resource_type:{resource_type}"])
>       assert len(catcher.caught_events) == 0
E       assert 1 == 0
E        +  where 1 = len([info {\n  name: "NoNodesSelected"\n  code: "Q038"\n  msg: "No nodes selected!"\n  level: "warn"\n  invocation_id: "1658b1b...-9b5a0b185114"\n  pid: 59592\n  thread: "MainThread"\n  ts {\n    seconds: 1723041301\n    nanos: 398960000\n  }\n}\ndata {\n}\n])
E        +    where [info {\n  name: "NoNodesSelected"\n  code: "Q038"\n  msg: "No nodes selected!"\n  level: "warn"\n  invocation_id: "1658b1b...-9b5a0b185114"\n  pid: 59592\n  thread: "MainThread"\n  ts {\n    seconds: 1723041301\n    nanos: 398960000\n  }\n}\ndata {\n}\n] = EventCatcher(event_to_catch=<class 'dbt.events.types.NoNodesSelected'>, caught_events=[info {\n  name: "NoNodesSelected" seconds: 1723041301\n    nanos: 398960000\n  }\n}\ndata {\n}\n], predicate=<function EventCatcher.<lambda> at 0x1233c4790>).caught_events

/Users/quigleymalcolm/Developer/dbt-labs/dbt-core/tests/functional/list/test_commands.py:105: AssertionError

@QMalcolm QMalcolm merged commit 8622360 into main Aug 7, 2024
63 checks passed
@QMalcolm QMalcolm deleted the cl/happy_path_scretch branch August 7, 2024 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes Skip Changelog Skips GHA to check for changelog file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create parameterized test which tries each resource type with the resource_type: selector
3 participants