Skip to content

Commit

Permalink
Don't test controller classes
Browse files Browse the repository at this point in the history
  • Loading branch information
piercefreeman committed Dec 15, 2024
1 parent 98a12f9 commit 3aa67d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@


# Test Models and Enums
class TestStatus(Enum):
class ExampleStatus(Enum):
ACTIVE = "active"
INACTIVE = "inactive"


class ExampleBaseModel(BaseModel):
name: str
status: TestStatus
status: ExampleStatus


class ExampleRequestModel(BaseModel):
Expand All @@ -48,29 +48,29 @@ class ExampleResponseModel(BaseModel):
total: int


class TestRenderModel(RenderBase):
class ExampleRenderModel(RenderBase):
title: str
items: List[ExampleBaseModel]


# Test Controllers
class TestBaseController(ControllerBase):
class ExampleBaseController(ControllerBase):
@passthrough
def base_action(self) -> ExampleResponseModel: # type: ignore
"""Base action that returns a response model"""
pass


class ExampleController(TestBaseController):
class ExampleController(ExampleBaseController):
url = "/test"
view_path = "/test.tsx"

async def render( # type: ignore
self,
path_param: str,
query_param: int = 0,
enum_param: TestStatus = TestStatus.ACTIVE,
) -> TestRenderModel: # type: ignore
enum_param: ExampleStatus = ExampleStatus.ACTIVE,
) -> ExampleRenderModel: # type: ignore
"""Main render method"""
pass

Expand Down Expand Up @@ -230,10 +230,10 @@ def test_script_generation(self, generator: LocalModelGenerator) -> None:
# Check for model exports
assert "export type { ExampleRequestModel as ExampleRequestModel }" in content
assert "export type { ExampleResponseModel as ExampleResponseModel }" in content
assert "export type { TestRenderModel as TestRenderModel }" in content
assert "export type { ExampleRenderModel as ExampleRenderModel }" in content

# Check for enum exports
assert "export { TestStatus as TestStatus }" in content
assert "export { ExampleStatus as ExampleStatus }" in content


class TestLocalUseServerGenerator:
Expand Down
4 changes: 2 additions & 2 deletions mountaineer/__tests__/client_builder/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest
from fastapi import File, Form, UploadFile
from pydantic import BaseModel, validator
from pydantic import BaseModel, field_validator, validator

from mountaineer.actions.fields import FunctionActionType
from mountaineer.actions.passthrough_dec import passthrough
Expand Down Expand Up @@ -39,7 +39,7 @@ class ExampleModelBase(BaseModel):
int_field: int
enum_field: TestEnum

@validator("string_field")
@field_validator("string_field")
def validate_string(cls, v):
if len(v) < 3:
raise ValueError("String too short")
Expand Down

0 comments on commit 3aa67d5

Please sign in to comment.