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: collect rich user input for tests with subprocess #238

Merged
merged 4 commits into from
May 2, 2021

Conversation

virvirlopez
Copy link
Contributor

@virvirlopez virvirlopez commented May 2, 2021

Description

Adding the ability to add custom tests and execute the tests with subprocess.

Things to have in mind:

  • If the test is malformed all the tests that you add can not be checked, and as a result, they will not be added.
  • The process of adding tests is really simple, we add all the tests we execute dbt test in the model, get the response and calculate which model is PASS and which FAIL or ERROR. We remove all the tests that the status is not PASS.

How was the change tested

Ran it in local.

Closes #65

Checklist

(Ideally, all boxes are checked by the time we merged the PR, if you don't know how to do any of these don't hesitate to say so in the PR and we'll help you out.)

  • I formatted my PR name according to CONTRIBUTING.md
  • I added a news fragment to help populating the changelog as encouraged in CONTRIBUTING.md
  • I added "Closes #<issue_number>" in the "Issue Information" section (if no issue, feel free to tick thick the box anyway).

@codecov
Copy link

codecov bot commented May 2, 2021

Codecov Report

Merging #238 (c446458) into dev/0.1.0 (71d16a9) will decrease coverage by 0.06%.
The diff coverage is 66.03%.

Impacted file tree graph

@@              Coverage Diff              @@
##           dev/0.1.0     #238      +/-   ##
=============================================
- Coverage      82.60%   82.53%   -0.07%     
=============================================
  Files             19       19              
  Lines           1173     1197      +24     
=============================================
+ Hits             969      988      +19     
- Misses           204      209       +5     
Flag Coverage Δ
unittests 82.53% <66.03%> (-0.07%) ⬇️

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

Impacted Files Coverage Δ
dbt_sugar/core/task/doc.py 67.69% <48.48%> (+0.83%) ⬆️
dbt_sugar/core/ui/cli_ui.py 93.12% <95.00%> (-0.34%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 71d16a9...c446458. Read the comment docs.

Copy link
Member

@bastienboutonnet bastienboutonnet left a comment

Choose a reason for hiding this comment

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

This looks mostly good!

Check my code suggestions for the error message.

Can you also add a news fragment describing the change as well as add "Resolves #<issue_number>" in the PR info.

from collections import OrderedDict
from pathlib import Path
from shlex import quote
Copy link
Member

Choose a reason for hiding this comment

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

oh nice on using this! I learned about it only recently!

dbt_sugar/core/task/doc.py Outdated Show resolved Hide resolved
dbt_sugar/core/task/doc.py Outdated Show resolved Hide resolved
@virvirlopez virvirlopez force-pushed the feat/collect_rich_tests branch from 6aadefe to 356dc06 Compare May 2, 2021 15:04
Make nicer the logs

Secure variable
@virvirlopez virvirlopez force-pushed the feat/collect_rich_tests branch from d3fb949 to 8a45988 Compare May 2, 2021 15:08
@virvirlopez virvirlopez changed the title feat: collect rich user input for tests with subprocess feat: collect rich user input for tests with subprocess Resolves#108 May 2, 2021
Copy link
Member

@bastienboutonnet bastienboutonnet left a comment

Choose a reason for hiding this comment

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

All good!

@bastienboutonnet bastienboutonnet changed the title feat: collect rich user input for tests with subprocess Resolves#108 feat: collect rich user input for tests with subprocess May 2, 2021
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 2, 2021

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 1.09%.

Quality metrics Before After Change
Complexity 3.71 ⭐ 4.35 ⭐ 0.64 👎
Method Length 74.32 🙂 75.58 🙂 1.26 👎
Working memory 11.65 😞 11.94 😞 0.29 👎
Quality 66.64% 🙂 65.55% 🙂 -1.09% 👎
Other metrics Before After Change
Lines 2092 2200 108
Changed files Quality Before Quality After Quality Change
dbt_sugar/core/task/doc.py 66.31% 🙂 64.13% 🙂 -2.18% 👎
dbt_sugar/core/ui/cli_ui.py 70.85% 🙂 70.80% 🙂 -0.05% 👎
tests/cli_ui_test.py 57.44% 🙂 56.80% 🙂 -0.64% 👎
tests/doc_task_test.py 64.93% 🙂 64.20% 🙂 -0.73% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
tests/doc_task_test.py test_order_schema_yml 0 ⭐ 417 ⛔ 34 ⛔ 34.92% 😞 Try splitting into smaller methods. Extract out complex expressions
dbt_sugar/core/ui/cli_ui.py UserInputCollector._iterate_through_columns 29 😞 155 😞 12 😞 35.39% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
tests/cli_ui_test.py test__document_undocumented_columns 0 ⭐ 188 😞 29 ⛔ 43.98% 😞 Try splitting into smaller methods. Extract out complex expressions
dbt_sugar/core/task/doc.py DocumentationTask.check_tests 12 🙂 144 😞 15 😞 44.18% 😞 Try splitting into smaller methods. Extract out complex expressions
tests/doc_task_test.py test_column_has_primary_key_tests 0 ⭐ 140 😞 26 ⛔ 49.25% 😞 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

@virvirlopez virvirlopez merged commit bf10608 into dev/0.1.0 May 2, 2021
@virvirlopez virvirlopez deleted the feat/collect_rich_tests branch May 2, 2021 17:05
bastienboutonnet pushed a commit that referenced this pull request May 3, 2021
* feat: collect rich user input for tests with subprocess

* fix: order of the combine list

Make nicer the logs

Secure variable

* add: feature.md
bastienboutonnet added a commit that referenced this pull request May 5, 2021
* feat: add describe table logic in snowflake connector (#212)

* implement `describe table` logic in SnowflakeConnector

* add flag for experimental feature in config

* update test expectations to have use_describe_snowflake False

* add use_describe_snowflake CLI arg parsing

* update cli consumption tests

* 'Refactored by Sourcery' (#213)

Co-authored-by: Sourcery AI <>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add changelog entry

* lowercase column names

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: automatic insertion of primary key tests (#203)

* feat: automatic insertion of primary key tests.

* feat: adding tests

feat: adding tests

* feat: cleaning documentation

* feat: change the way of getting the SQL file

* Add new tests

* 'Refactored by Sourcery' (#216)

Co-authored-by: Sourcery AI <>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: adding changelog defintion primary key tests

* feat: adding changelog defintion primary key tests

* rename and rephrase news fragment (#219)

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bastien Boutonnet <bastien.b1@gmail.com>

* refactor: add use_describe to base (#236)

* add `use_describe` to the base `get_columns_from_table` def

* 'Refactored by Sourcery' (#237)

Co-authored-by: Sourcery AI <>

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

* feat: bootstrap task (#233)

* setup arg parser and skeleton of bootstrap task

* implement barebone all dbt models dict building

* iterate through models and get col list and schema path

* combine getting columns and finding descriptor

* update tests for bootstrap_task

* update tests for audit_task

* add model placeholders in bootstrap_task

add all models placeholders

* refactor dbt models info in a dataclass for cleaner type checking

* feat: bootstrap task (Sourcery refactored) (#234)

* 'Refactored by Sourcery'

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: Sourcery AI <>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix typo in new fragment

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: allow audit task to run bootstrap (#239)

* add bootstrap option to `audit` and call it if passed

* add news fragement

* feat: collect rich user input for tests with subprocess (#238)

* feat: collect rich user input for tests with subprocess

* fix: order of the combine list

Make nicer the logs

Secure variable

* add: feature.md

* [pre-commit.ci] pre-commit autoupdate (#242)

updates:
- [github.com/psf/black: 21.4b0 → 21.4b2](psf/black@21.4b0...21.4b2)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* add dbt sugar logo

* chore(deps): Bump sqlalchemy from 1.4.12 to 1.4.13 (#243)

Bumps [sqlalchemy](https://github.com/sqlalchemy/sqlalchemy) from 1.4.12 to 1.4.13.
- [Release notes](https://github.com/sqlalchemy/sqlalchemy/releases)
- [Changelog](https://github.com/sqlalchemy/sqlalchemy/blob/master/CHANGES)
- [Commits](https://github.com/sqlalchemy/sqlalchemy/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps-dev): Bump pytest from 6.2.3 to 6.2.4 (#244)

* feat: add redshift connector (#229)

* add RedshiftConnector engine creation module

* add news fragment

* move pytest-dictsdiff to dev requirements

* make read_profile use PostgresDbtProfilesModel pydantic validation class

* 'Refactored by Sourcery' (#231)

Co-authored-by: Sourcery AI <>

* Bump version: 0.0.0 → 0.1.0-a.0

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: virvirlopez <virbyte@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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