I am not able to successfully mock pasue_time
and max_tries
in the command. Suggestions please.
Command
class Command(BaseCommand):
"""Update seat expire dates."""
help = 'Fooo'
pause_time = 5
max_tries = 5
def handle(self, *args, **options):
if self.max_tries < tries:
logger.error('error')
Test
@mock.patch('foo.bar.path.to.file.Command.max_tries')
def test_update_course_with_exception(self, param):
param = 1
expected = [
# some information which is logged by management command
]
with LogCapture(LOGGER_NAME) as lc:
call_command('foo_command_name_bar')
lc.check(*expected)
Aucun commentaire:
Enregistrer un commentaire