Skip to content

Commit

Permalink
Ct-603 docs generate test conversion (#116)
Browse files Browse the repository at this point in the history
* Update test_basic with docs_generate test

* Implement DocsGenerate and DocsGenReferences tests

* Remove existing docs_generate_tests

* Fix docs gen references test, and skip
  • Loading branch information
gshank authored May 20, 2022
1 parent 9209e1a commit 50399f5
Show file tree
Hide file tree
Showing 25 changed files with 144 additions and 1,985 deletions.
100 changes: 100 additions & 0 deletions tests/functional/adapter/expected_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
from dbt.tests.util import AnyStringWith, AnyFloat, AnyString


def redshift_stats():
return {
"has_stats": {
"id": "has_stats",
"label": "Has Stats?",
"value": True,
"description": "Indicates whether there are statistics for this table",
"include": False,
},
"encoded": {
"id": "encoded",
"label": "Encoded",
"value": AnyStringWith("Y"),
"description": "Indicates whether any column in the table has compression encoding defined.",
"include": True,
},
"diststyle": {
"id": "diststyle",
"label": "Dist Style",
"value": AnyStringWith("AUTO"),
"description": "Distribution style or distribution key column, if key distribution is defined.",
"include": True,
},
"max_varchar": {
"id": "max_varchar",
"label": "Max Varchar",
"value": AnyFloat(),
"description": "Size of the largest column that uses a VARCHAR data type.",
"include": True,
},
"size": {
"id": "size",
"label": "Approximate Size",
"value": AnyFloat(),
"description": "Approximate size of the table, calculated from a count of 1MB blocks",
"include": True,
},
"sortkey1": {
"id": "sortkey1",
"label": "Sort Key 1",
"value": AnyString(),
"description": "First column in the sort key.",
"include": True,
},
"pct_used": {
"id": "pct_used",
"label": "Disk Utilization",
"value": AnyFloat(),
"description": "Percent of available space that is used by the table.",
"include": True,
},
"stats_off": {
"id": "stats_off",
"label": "Stats Off",
"value": AnyFloat(),
"description": "Number that indicates how stale the table statistics are; 0 is current, 100 is out of date.",
"include": True,
},
"rows": {
"id": "rows",
"label": "Approximate Row Count",
"value": AnyFloat(),
"description": "Approximate number of rows in the table. This value includes rows marked for deletion, but not yet vacuumed.",
"include": True,
},
}


def redshift_ephemeral_summary_stats():
additional = {
"skew_sortkey1": {
"description": "Ratio of the size of the largest non-sort "
"key column to the size of the first column "
"of the sort key.",
"id": "skew_sortkey1",
"include": True,
"label": "Sort Key Skew",
"value": 1.0,
},
"sortkey_num": {
"description": "Number of columns defined as sort keys.",
"id": "sortkey_num",
"include": True,
"label": "# Sort Keys",
"value": 1.0,
},
"unsorted": {
"description": "Percent of unsorted rows in the table.",
"id": "unsorted",
"include": True,
"label": "Unsorted %",
"value": 0.0,
},
}
stats = redshift_stats()
stats.update(additional)
return stats
45 changes: 44 additions & 1 deletion tests/functional/adapter/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest

from dbt.tests.util import AnyStringWith, AnyFloat

from dbt.tests.adapter.basic.test_base import BaseSimpleMaterializations
from dbt.tests.adapter.basic.test_singular_tests import BaseSingularTests
from dbt.tests.adapter.basic.test_singular_tests_ephemeral import (
Expand All @@ -12,6 +14,9 @@
from dbt.tests.adapter.basic.test_snapshot_check_cols import BaseSnapshotCheckCols
from dbt.tests.adapter.basic.test_snapshot_timestamp import BaseSnapshotTimestamp
from dbt.tests.adapter.basic.test_adapter_methods import BaseAdapterMethod
from dbt.tests.adapter.basic.test_docs_generate import BaseDocsGenerate, BaseDocsGenReferences
from dbt.tests.adapter.basic.expected_catalog import base_expected_catalog, no_stats, expected_references_catalog
from tests.functional.adapter.expected_stats import redshift_stats, redshift_ephemeral_summary_stats

from dbt.tests.adapter.basic.files import seeds_base_csv, seeds_added_csv, seeds_newcolumns_csv

Expand Down Expand Up @@ -80,4 +85,42 @@ def models(self):
}

class TestBaseAdapterMethod(BaseAdapterMethod):
pass
pass



class TestDocsGenerateRedshift(BaseDocsGenerate):
@pytest.fixture(scope="class")
def expected_catalog(self, project, profile_user):
return base_expected_catalog(
project,
role=profile_user,
id_type="integer",
text_type=AnyStringWith("character varying"),
time_type="timestamp without time zone",
view_type="VIEW",
table_type="BASE TABLE",
model_stats=no_stats(),
seed_stats=redshift_stats(),
)


@pytest.mark.skip(reason="Needs updated dbt-core code")
class TestDocsGenReferencesRedshift(BaseDocsGenReferences):
@pytest.fixture(scope="class")
def expected_catalog(self, project, profile_user):
return expected_references_catalog(
project,
role=profile_user,
id_type="integer",
text_type=AnyStringWith("character varying"),
time_type="timestamp without time zone",
bigint_type="bigint",
view_type="VIEW",
table_type="BASE TABLE",
model_stats=redshift_stats(),
seed_stats=redshift_stats(),
view_summary_stats=no_stats(),
ephemeral_summary_stats=redshift_ephemeral_summary_stats(),
)

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions tests/integration/docs_generate_tests/cross_db_models/schema.yml

This file was deleted.

3 changes: 0 additions & 3 deletions tests/integration/docs_generate_tests/fail_macros/failure.sql

This file was deleted.

9 changes: 0 additions & 9 deletions tests/integration/docs_generate_tests/macros/dummy_test.sql

This file was deleted.

8 changes: 0 additions & 8 deletions tests/integration/docs_generate_tests/macros/macro.md

This file was deleted.

10 changes: 0 additions & 10 deletions tests/integration/docs_generate_tests/macros/schema.yml

This file was deleted.

8 changes: 0 additions & 8 deletions tests/integration/docs_generate_tests/models/model.sql

This file was deleted.

1 change: 0 additions & 1 deletion tests/integration/docs_generate_tests/models/readme.md

This file was deleted.

82 changes: 0 additions & 82 deletions tests/integration/docs_generate_tests/models/schema.yml

This file was deleted.

13 changes: 0 additions & 13 deletions tests/integration/docs_generate_tests/models/second_model.sql

This file was deleted.

31 changes: 0 additions & 31 deletions tests/integration/docs_generate_tests/ref_models/docs.md

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 50399f5

Please sign in to comment.