Skip to content

Unit Testing ConfigurableResource Classes #21801

Answered by dehume
rover-wagnar asked this question in Q&A
Discussion options

You must be logged in to vote

Playing around with this. If you patch the method on the class before instantiating the configurable resource, that avoids the Pydantic reassignment issue.

Slightly cleaning up the original code so it will run:

from typing import Optional
from pydantic import Field
import dagster as dg
from pydantic import BaseModel
import requests
from typing import List, Dict


class ApiToken(BaseModel):
    value: str = Field(description="The API token value")
    has_expired: bool = Field(description="Whether the token has expired")


class RestApiClient(dg.ConfigurableResource):
    _api_token: Optional[ApiToken] = None

    @property
    def api_token(self) -> ApiToken:
        if not self._api_token 

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by cmpadden
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area: resource Related to Resources
3 participants