You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello developers, 👋
I am seeking guidance on whether the way I am using Polyfactory is correct.
I've simplified my code to focus only on two environments (DEV and QA) while keeping the applications_s3_path_list and policies fields.
Could someone confirm if this usage is correct or suggest any improvements?
from enum import Enum
from polyfactory.factories.pydantic_factory import ModelFactory
from polyfactory import Use
class ENV(Enum):
DEV = "dev"
QA = "qa"
class PolicyFactory(ModelFactory):
policy = "DEFAULT_POLICY" # Default policy value for all environments
# JungleRequest Factory with Defaults
class JungleRequestFactory(ModelFactory):
__ENV__ = ENV.DEV
applications_s3_path_list = Use(lambda: {
ENV.DEV: ["s3://path1/"],
ENV.QA: ["s3://path2"],
}.get(JungleRequestFactory.__ENV__, ["s3://default_path/"]))
policies = [PolicyFactory.build()]
# Generate a request for DEV environment
JungleRequestFactory.__ENV__ = ENV.DEV
dev_request = JungleRequestFactory.build()
print("\nDEV Request:", dev_request)
# Generate a request for QA environment
JungleRequestFactory.__ENV__ = ENV.QA
qa_request = JungleRequestFactory.build()
print("\nQA Request:", qa_request)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello developers, 👋
I am seeking guidance on whether the way I am using Polyfactory is correct.
I've simplified my code to focus only on two environments (DEV and QA) while keeping the applications_s3_path_list and policies fields.
Could someone confirm if this usage is correct or suggest any improvements?
Beta Was this translation helpful? Give feedback.
All reactions