Skip to content

Commit

Permalink
Reorganize fixtures and implement a happy path test for semantic_mani…
Browse files Browse the repository at this point in the history
…fest (#9930)
  • Loading branch information
ChenyuLInx authored Apr 16, 2024
1 parent 8b5884b commit a70024f
Show file tree
Hide file tree
Showing 9 changed files with 1,061 additions and 899 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240416-150030.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Add a test for semantic manifest and move test fixtures needed for it
time: 2024-04-16T15:00:30.614286-07:00
custom:
Author: ChenyuLInx
Issue: "9665"
2 changes: 1 addition & 1 deletion core/dbt/artifacts/resources/v1/semantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NodeRelation(dbtClassMixin):
alias: str
schema_name: str # TODO: Could this be called simply "schema" so we could reuse StateRelation?
database: Optional[str] = None
relation_name: Optional[str] = None
relation_name: Optional[str] = ""


# ====================================
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from dbt.artifacts.resources.types import NodeType
from dbt.contracts.graph.nodes import SourceDefinition

# All manifest related fixtures.
from tests.unit.utils.manifest import * # noqa


@pytest.fixture
def basic_parsed_source_definition_object():
Expand Down
Empty file.
Empty file.
28 changes: 28 additions & 0 deletions tests/unit/contracts/graph/test_semantic_manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pytest
from dbt.contracts.graph.semantic_manifest import SemanticManifest


# Overwrite the default nods to construct the manifest
@pytest.fixture
def nodes(metricflow_time_spine_model):
return [metricflow_time_spine_model]


@pytest.fixture
def semantic_models(
semantic_model,
) -> list:
return [semantic_model]


@pytest.fixture
def metrics(
metric,
) -> list:
return [metric]


class TestSemanticManifest:
def test_validate(self, manifest):
sm_manifest = SemanticManifest(manifest)
assert sm_manifest.validate()
Loading

0 comments on commit a70024f

Please sign in to comment.