Open nskmda opened 2 months ago
Hi,
I would make it this way:
class Configuration:
@classmethod
def env(cls):
c := cls()
c.bucket_name = os.getenv('BUCKET', c.bucket_name)
...
return c
@classmethod
def test(cls):
...
def __init__(self):
self.bucket_name = 'bucket'
self.users_table_name = 'users'
self.s3_bucket = 'mybucket'
And later I would bind Configuration
manually to different providers in inject
, i.e. to Configuration.env
and to Configuration.test
.
I would make it this way:
Provided how [poorly] I can understand 'this way' 😃 it mostly means replacement of lib/built-ins is not really supported. Which is fine.
Now, just to confirm (since I haven't used it just yet): inject
supports 'custom factories', right?
I'm thinking about having a custom factory now which will do the boto3.client
and map it to some text-based name/key in the injector and then simply inject it.
This way I should be able to inject those instances into my class constructor and re-map them in the feature spec to verify behavior, right?
Team,
Is there any way to 'inject' a class attribute when a 'static' reference is used for the dependency.
Example:
I would like to have these values overridden in a test spec. so far i have to 'manually' override these values in the spec:
which would be nice to do 'automagically'.