Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Add fixture to clear tables between test #680

Merged
merged 7 commits into from
Jul 7, 2022
Merged

Add fixture to clear tables between test #680

merged 7 commits into from
Jul 7, 2022

Conversation

sanders41
Copy link
Contributor

@sanders41 sanders41 commented Jun 19, 2022

Purpose

Clears the database tables between each test even if the test fails.

Changes

  • Added clear_db_tables as an autouse fixture.

Checklist

  • Update CHANGELOG.md file
    • Merge in main so the most recent CHANGELOG.md file is being appended to
    • Add description within the Unreleased section in an appropriate category. Add a new category from the list at the top of the file if the needed one isn't already there.
    • Add a link to this PR at the end of the description with the PR number as the text. example: #1
  • Applicable documentation updated (guides, quickstart, postman collections, tutorial, fidesdemo, database diagram.
  • If docs updated (select one):
    • documentation complete, or draft/outline provided (tag docs-team to complete/review on this branch)
    • documentation issue created (tag docs-team to complete issue separately)
  • Good unit test/integration test coverage
  • This PR contains a DB migration. If checked, the reviewer should confirm with the author that the down_revision correctly references the previous migration before merging
  • The Run Unsafe PR Checks label has been applied, and checks have passed, if this PR touches any external services

Ticket

Fixes #678
Fixes #679

@sanders41 sanders41 changed the title Add fixture to clear tables between test runs Add fixture to clear tables between test Jun 19, 2022
@seanpreston seanpreston self-assigned this Jun 20, 2022
@seanpreston seanpreston added the run unsafe ci checks Triggers running of unsafe CI checks label Jun 20, 2022
@sanders41
Copy link
Contributor Author

Looking at the failing test, does that test ever pass? It looks like it will always fail. This line is referencing host from stripe_connection_config, but there isn't a host in the data.

@pytest.fixture(scope="function")
def stripe_connection_config(
    db: Session, stripe_config: Dict[str, Dict], stripe_secrets: Dict[str, Any]
) -> Generator:
    fides_key = stripe_config["fides_key"]
    connection_config = ConnectionConfig.create(
        db=db,
        data={
            "key": fides_key,
            "name": fides_key,
            "connection_type": ConnectionType.saas,
            "access": AccessLevel.write,
            "secrets": stripe_secrets,
            "saas_config": stripe_config,
        },
    )
    yield connection_config
    connection_config.delete(db)

@seanpreston seanpreston merged commit 5f509a5 into main Jul 7, 2022
@seanpreston seanpreston deleted the clear-tables branch July 7, 2022 13:45
sanders41 added a commit that referenced this pull request Sep 22, 2022
* Add fixture to clear tables between test runs

* Update CHANGELOG

* Add missing ordering to customer_details logs query in test.

* update import path

Co-authored-by: Paul Sanders <pau@ethyca.com>
Co-authored-by: Dawn Pattison <pattisdr@users.noreply.github.com>
Co-authored-by: Sean Preston <sean@ethyca.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
run unsafe ci checks Triggers running of unsafe CI checks
Projects
None yet
3 participants