Skip to content

Commit

Permalink
Rename NodeType type enum to SemanticManifestNodeType
Browse files Browse the repository at this point in the history
  • Loading branch information
QMalcolm committed Oct 26, 2023
1 parent 77b55d4 commit 8682288
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
4 changes: 3 additions & 1 deletion dbt_semantic_interfaces/type_enums/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
from dbt_semantic_interfaces.type_enums.dimension_type import DimensionType # noqa:F401
from dbt_semantic_interfaces.type_enums.entity_type import EntityType # noqa:F401
from dbt_semantic_interfaces.type_enums.metric_type import MetricType # noqa:F401
from dbt_semantic_interfaces.type_enums.node_type import NodeType # noqa:F401
from dbt_semantic_interfaces.type_enums.semantic_manifest_node_type import ( # noqa:F401
SemanticManifestNodeType,
)
from dbt_semantic_interfaces.type_enums.time_granularity import ( # noqa:F401
TimeGranularity,
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dbt_semantic_interfaces.enum_extension import ExtendedEnum


class NodeType(ExtendedEnum):
class SemanticManifestNodeType(ExtendedEnum):
"""Currently supported node types."""

METRIC = "metric"
Expand Down
16 changes: 11 additions & 5 deletions dbt_semantic_interfaces/validations/unique_valid_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
ElementReference,
SemanticModelElementReference,
)
from dbt_semantic_interfaces.type_enums import EntityType, NodeType, TimeGranularity
from dbt_semantic_interfaces.type_enums import (
EntityType,
SemanticManifestNodeType,
TimeGranularity,
)
from dbt_semantic_interfaces.validations.validator_helpers import (
FileContext,
SemanticManifestValidationRule,
Expand Down Expand Up @@ -170,7 +174,7 @@ def _validate_semantic_model_elements(semantic_model: SemanticModel) -> List[Val
@validate_safely(whats_being_done="checking top level elements of a specific type have unique and valid names")
def _validate_top_level_objects_of_type(
objects: Union[List[SemanticModel], List[Metric], List[SavedQuery]],
object_type: NodeType,
object_type: SemanticManifestNodeType,
) -> List[ValidationIssue]:
"""Validates uniqeness and validaty of top level objects of singular type."""
issues: List[ValidationIssue] = []
Expand Down Expand Up @@ -203,17 +207,19 @@ def _validate_top_level_objects(semantic_manifest: SemanticManifest) -> List[Val

issues.extend(
UniqueAndValidNameRule._validate_top_level_objects_of_type(
semantic_manifest.semantic_models, NodeType.SEMANTIC_MODEL
semantic_manifest.semantic_models, SemanticManifestNodeType.SEMANTIC_MODEL
)
)

issues.extend(
UniqueAndValidNameRule._validate_top_level_objects_of_type(semantic_manifest.metrics, NodeType.METRIC)
UniqueAndValidNameRule._validate_top_level_objects_of_type(
semantic_manifest.metrics, SemanticManifestNodeType.METRIC
)
)

issues.extend(
UniqueAndValidNameRule._validate_top_level_objects_of_type(
semantic_manifest.saved_queries, NodeType.SAVED_QUERY
semantic_manifest.saved_queries, SemanticManifestNodeType.SAVED_QUERY
)
)

Expand Down
17 changes: 10 additions & 7 deletions tests/validations/test_unique_valid_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
PydanticSemanticManifest,
)
from dbt_semantic_interfaces.test_utils import find_semantic_model_with
from dbt_semantic_interfaces.type_enums import NodeType
from dbt_semantic_interfaces.type_enums import SemanticManifestNodeType
from dbt_semantic_interfaces.validations.semantic_manifest_validator import (
SemanticManifestValidator,
)
Expand Down Expand Up @@ -62,8 +62,9 @@ def test_duplicate_semantic_model_name( # noqa: D
model.semantic_models.append(duplicated_semantic_model)
with pytest.raises(
SemanticManifestValidationException,
match=rf"Can't use name `{duplicated_semantic_model.name}` for a {NodeType.SEMANTIC_MODEL} when it was "
f"already used for another {NodeType.SEMANTIC_MODEL}",
match=rf"Can't use name `{duplicated_semantic_model.name}` for a "
f"{SemanticManifestNodeType.SEMANTIC_MODEL} when it was "
f"already used for another {SemanticManifestNodeType.SEMANTIC_MODEL}",
):
SemanticManifestValidator[PydanticSemanticManifest](
[UniqueAndValidNameRule[PydanticSemanticManifest]()]
Expand Down Expand Up @@ -99,8 +100,9 @@ def test_duplicate_metric_name( # noqa:D
model.metrics.append(duplicated_metric)
with pytest.raises(
SemanticManifestValidationException,
match=rf"Can't use name `{duplicated_metric.name}` for a {NodeType.METRIC} when it was already used for "
f"another {NodeType.METRIC}",
match=rf"Can't use name `{duplicated_metric.name}` for a "
f"{SemanticManifestNodeType.METRIC} when it was already used for "
f"another {SemanticManifestNodeType.METRIC}",
):
SemanticManifestValidator[PydanticSemanticManifest]([UniqueAndValidNameRule()]).checked_validations(model)

Expand Down Expand Up @@ -148,8 +150,9 @@ def test_duplicate_saved_query_name( # noqa: D
manifest.saved_queries.append(duplicated_saved_query)
with pytest.raises(
SemanticManifestValidationException,
match=rf"Can't use name `{duplicated_saved_query.name}` for a {NodeType.SAVED_QUERY} when it was already used "
f"for another {NodeType.SAVED_QUERY}",
match=rf"Can't use name `{duplicated_saved_query.name}` for a "
f"{SemanticManifestNodeType.SAVED_QUERY} when it was already used "
f"for another {SemanticManifestNodeType.SAVED_QUERY}",
):
SemanticManifestValidator[PydanticSemanticManifest](
[UniqueAndValidNameRule[PydanticSemanticManifest]()]
Expand Down

0 comments on commit 8682288

Please sign in to comment.