<commit_before># -*- coding: utf-8 -*-
import os
import shutil

from django.conf import settings
from django.core.management import CommandError, call_command
from django.test import TestCase
from django.test.utils import override_settings
from six import StringIO

import django_extensions.management.commands.sync_s3
from django_extensions.management.commands.sync_s3 import Command

try:
    from unittest.mock import Mock, patch
except ImportError:
    from mock import patch


class SyncS3ExceptionsTests(TestCase):

    @patch('django_extensions.management.commands.sync_s3.HAS_BOTO', new=False)
    def test_should_raise_ImportError_if_boto_is_not_installed(self,):
        with self.assertRaisesRegexp(ImportError, "The boto Python library is not installed."):
            call_command('sync_s3')

    @override_settings(AWS_ACCESS_KEY_ID=None)
    @patch('django_extensions.management.commands.sync_s3.HAS_BOTO', new=True)
    def test_should_raise_CommandError_if_AWS_ACCESS_KEY_ID_is_not_set_or_is_set_to_None(self):
        with self.assertRaisesRegexp(CommandError, "Missing AWS keys from settings file.  Please supply both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY"):
            call_command('sync_s3')

    @override_settings(AWS_SECRET_ACCESS_KEY=None)
    @patch('django_extensions.management.commands.sync_s3.HAS_BOTO', new=True)
    def test_should_raise_CommandError_if_AWS_SECRET_ACCESS_KEY_is_not_set_or_is_set_to_None(self):
        with self.assertRaisesRegexp(CommandError, "Missing AWS keys from settings file.  Please supply both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY"):
            call_command('sync_s3')

    @override_settings(
        AWS_ACCESS_KEY_ID='access_key_id',
        AWS_SECRET_ACCESS_KEY='secret_access_key',
        AWS_BUCKET_NAME=''
    )
    def test_should_raise_CommandError_if_AWS_BUCKET_NAME_is_set_to_None(self):<commit_msg>added missing Mock import<commit_after># -*- coding: utf-8 -*-
import os
import shutil

from django.conf import settings
from django.core.management import CommandError, call_command
from django.test import TestCase
from django.test.utils import override_settings
from six import StringIO

import django_extensions.management.commands.sync_s3
from django_extensions.management.commands.sync_s3 import Command

try:
    from unittest.mock import Mock, patch
except ImportError:
    from mock import Mock, patch


class SyncS3ExceptionsTests(TestCase):

    @patch('django_extensions.management.commands.sync_s3.HAS_BOTO', new=False)
    def test_should_raise_ImportError_if_boto_is_not_installed(self,):
        with self.assertRaisesRegexp(ImportError, "The boto Python library is not installed."):
            call_command('sync_s3')

    @override_settings(AWS_ACCESS_KEY_ID=None)
    @patch('django_extensions.management.commands.sync_s3.HAS_BOTO', new=True)
    def test_should_raise_CommandError_if_AWS_ACCESS_KEY_ID_is_not_set_or_is_set_to_None(self):
        with self.assertRaisesRegexp(CommandError, "Missing AWS keys from settings file.  Please supply both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY"):
            call_command('sync_s3')

    @override_settings(AWS_SECRET_ACCESS_KEY=None)
    @patch('django_extensions.management.commands.sync_s3.HAS_BOTO', new=True)
    def test_should_raise_CommandError_if_AWS_SECRET_ACCESS_KEY_is_not_set_or_is_set_to_None(self):
        with self.assertRaisesRegexp(CommandError, "Missing AWS keys from settings file.  Please supply both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY"):
            call_command('sync_s3')

    @override_settings(
        AWS_ACCESS_KEY_ID='access_key_id',
        AWS_SECRET_ACCESS_KEY='secret_access_key',
        AWS_BUCKET_NAME=''
    )
    def test_should_raise_CommandError_if_AWS_BUCKET_NAME_is_set_to_None(self):
{'fraction_non_alphanumeric': 0.07203166226912928, 'fraction_numerical': 0.005277044854881266, 'mean_word_length': 5.414551607445008, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7546204', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1221, 'n_words': 219}