0

I use django-minio-backend in order to integrate Django and Minio. I want to create a test bucket for created media files during tests running.

I tried to do that in a custom test runner as follows:

class CoreTestRunner(DiscoverRunner):

    def setup_test_environment(self, **kwargs):
        super(CoreTestRunner, self).setup_test_environment()
        self._make_test_file_storage()

    def _make_test_file_storage(self):
        minio_test_bucket = "test-bucket"
        settings.MINIO_MEDIA_FILES_BUCKET = minio_test_bucket
        settings.MINIO_PRIVATE_BUCKETS = [minio_test_bucket]
        call_command("initialize_buckets")

The problem is that when I run the test command, Minio creates the test-bucket, but uploads all files to the old bucket (the available bucket before creating test-bucket)
The old bucket in settings.py is project-media-bucket and all the files are uploaded in this bucket instead of uploading on test-bucket.

How can I solve the problem?

1 Answer 1

0

Are you trying to change the Django settings during runtime? That may not work. Take a look at this.

Can you add these settings to the settings.py and in your tests you can create bucket during init and delete after each test runner is done?

Sign up to request clarification or add additional context in comments.

Comments

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.