0

I am overriding settings for the entire test class like this:

@mock_aws
@override_settings(
        AWS_CLOUDFRONT_DOMAIN="fake_domain",
        AWS_CLOUDFRONT_KEY="fake_key",
        AWS_CLOUDFRONT_KEY_ID="fake_key_id",
        AWS_CLOUDFRONT_DISTRIBUTION_ID="fake_distribution_id",
    )
class TestCloudfrontClient(TestCase):
    def setUp(self):
        self.cf_client = CloudfrontClient()

and here is the CloudfrontClient class:

class CloudfrontClient:
    """Client to interact with AWS S3 through Cloudfront"""
    
    def __init__(
        self, 
        cloudfront_pk_id=settings.AWS_CLOUDFRONT_KEY_ID,
        cloudfront_key=settings.AWS_CLOUDFRONT_KEY,
        cloudfront_distribution_id=settings.AWS_CLOUDFRONT_DISTRIBUTION_ID,
        cloudfront_domain=settings.AWS_CLOUDFRONT_DOMAIN,
        rsa_signer=rsa_signer
    ):
        self.cf_client = client('cloudfront')
        self.distribution_id = cloudfront_distribution_id
        self.cloudfront_signer = CloudFrontSigner(cloudfront_pk_id, rsa_signer)
        self.cloudfront_domain = cloudfront_domain
        breakpoint()

At the breakpoint if I print settings.AWS_CLOUDFRONT_KEY_ID I get the fake_key_id but when I print cloudfront_pk_id I get empty string. This is also the case for other variables and it is messing my test results. Am I missing something about how override_settings work?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.