Mocking / whitelisting specific services with v5 #7854
Replies: 2 comments 2 replies
-
Hi @jwhitaker-gridcog! It is possible to blacklist services - does that work for you? I know it's not quite the same, but that is currently possible by (ab)using the
The original idea behind the config is to mock most services, but allow some services to still talk to AWS. As long as |
Beta Was this translation helpful? Give feedback.
-
If your application makes a request to a service that's not listed here, it will throw a Feedback would be welcome @jwhitaker-gridcog - let us know if that works for you! |
Beta Was this translation helpful? Give feedback.
-
Hey guys,
Thanks for this great library, it's been invaluable in many orgs I've worked at.
With v5, you've changed the API from mocking specific services (
@moto_s3
) to mocking all services at once (@moto
). This is overall fine and simplifies things.However, one aspect I appreciated from the specific services API was that I could expose dodgy app code that calls out to AWS when it shouldn't. If I ran my tests with
@moto_s3
and no AWS credentials, then if some random lib e.g. decides to call out to Dynamo behind my back, then it would be exposed by failing in the tests. This was a great way to nail down inappropriate behaviour that has snuck into big codebases.With v5, I can't do this: the random lib would successfully go on being able to talk to Dynamo (enabled via Moto in the tests) and I would be blissfully ignorant.
Is there any way to achieve this "service whitelisting" aspect of the v4 api? I wouldn't necessarily need the
@moto_s3
service-specific decorator pattern; there could be other ways to achieve this - e.g. a "whitelist" arg to@moto
?Beta Was this translation helpful? Give feedback.
All reactions