Skip to content

Introduce generator for Pydantic Model#73

Merged
yezz123 merged 3 commits into
mainfrom
feat/generator
Dec 15, 2022
Merged

Introduce generator for Pydantic Model#73
yezz123 merged 3 commits into
mainfrom
feat/generator

Conversation

@yezz123

@yezz123 yezz123 commented Dec 15, 2022

Copy link
Copy Markdown
Owner

Usage

Given a Pydantic model type can generate instances of that model with randomly generated values.

Example

from enum import auto, Enum
from uuid import UUID

from ormdantic.generator import Generator
from pydantic import BaseModel


class Flavor(Enum):
    MOCHA = auto()
    VANILLA = auto()


class Brand(BaseModel):
    brand_name: str


class Coffee(BaseModel):
    id: UUID
    description: str
    cream: bool
    sweetener: int
    flavor: Flavor
    brand: Brand


print(Generator(Coffee))

Result:

id=UUID('93b517c2-083b-457d-a0e5-6e1bd2a927e4')
description='ctWOb' cream=True sweetener=234
flavor=<Flavor.VANILLA: 2> brand=Brand(brand_name='LMrIf')

@yezz123 yezz123 added the enhancement New feature or request label Dec 15, 2022
@yezz123 yezz123 self-assigned this Dec 15, 2022
@codecov-commenter

codecov-commenter commented Dec 15, 2022

Copy link
Copy Markdown

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (f61da86) compared to base (a351591).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##              main       #73    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           20        22     +2     
  Lines          744       852   +108     
==========================================
+ Hits           744       852   +108     
Impacted Files Coverage Δ
ormdantic/generator/__init__.py 100.00% <100.00%> (ø)
ormdantic/generator/_lazy.py 100.00% <100.00%> (ø)
tests/test_generator.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@yezz123 yezz123 merged commit 765faae into main Dec 15, 2022
@yezz123 yezz123 deleted the feat/generator branch December 15, 2022 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants