Skip to content

Instantly share code, notes, and snippets.

@kamilglod
Created May 23, 2020 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamilglod/c53283106f6a5641f30a65af36856972 to your computer and use it in GitHub Desktop.
Save kamilglod/c53283106f6a5641f30a65af36856972 to your computer and use it in GitHub Desktop.
import json
from datetime import datetime
from dataclasses import dataclass
from enum import Enum
from typing import List
from warnings import warn
from .config import USERS_DATASET_PATH
@dataclass
class User:
class Status(str, Enum):
NEW = 'NEW'
PAID = "PAID"
TRIAL = "TRIAL"
id: int
enabled: bool
status: Status
custom_properties: dict
first_name: str
last_name: str
address: str
company: str
credit_card: str
currency: str
created_at: datetime
bio: str
budget: float
labels: List[str]
if USERS_DATASET_PATH.exists():
_cached_users: List[User] = [
User(**row)
for row
in json.load(USERS_DATASET_PATH.open())
]
else:
warn("Missing test users dataset.")
async def get_users() -> List[User]:
return _cached_users
async def get_user() -> User:
return _cached_users[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment