File: test_generate_secret_key.py

package info (click to toggle)
python-django-extensions 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,820 kB
  • sloc: python: 18,601; javascript: 7,354; makefile: 108; xml: 17
file content (22 lines) | stat: -rw-r--r-- 667 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# -*- coding: utf-8 -*-
from io import StringIO

from django.core.management import call_command
from django.test import TestCase

from unittest.mock import patch


class GenerateSecretKeyTests(TestCase):
    """Tests for generate_secret_key command."""

    @patch(
        "django_extensions.management.commands.generate_secret_key.get_random_secret_key"
    )
    @patch("sys.stdout", new_callable=StringIO)
    def test_should_return_random_secret_key(self, m_stdout, m_get_random_secret):
        m_get_random_secret.return_value = "random_secret_key"

        call_command("generate_secret_key")

        self.assertIn("random_secret_key", m_stdout.getvalue())