示例#1
0
 def test_createsuperuser(self):
     mock = MagicMock()
     with patch.dict(django.__salt__, {'cmd.run': mock}):
         django.createsuperuser('settings.py', 'testuser',
                                '*****@*****.**')
         mock.assert_called_once_with(
             'django-admin.py createsuperuser --settings=settings.py '
             '--noinput --username=testuser [email protected]')
示例#2
0
文件: django.py 项目: Barrybaby/salt
 def test_createsuperuser(self):
     mock = MagicMock()
     with patch.dict(django.__salt__, {"cmd.run": mock}):
         django.createsuperuser("settings.py", "testuser", "*****@*****.**")
         mock.assert_called_once_with(
             "django-admin.py createsuperuser --settings=settings.py "
             "--noinput --username=testuser [email protected]"
         )
示例#3
0
 def test_createsuperuser(self):
     mock = MagicMock()
     with patch.dict(django.__salt__,
                     {'cmd.run': mock}):
         django.createsuperuser(
             'settings.py', 'testuser', '*****@*****.**'
         )
         mock.assert_called_once_with(
             'django-admin.py createsuperuser --settings=settings.py '
             '--noinput --username=testuser [email protected]',
             env=None
         )
示例#4
0
 def test_django_admin_cli_createsuperuser(self):
     mock = MagicMock()
     with patch.dict(djangomod.__salt__, {"cmd.run": mock}):
         djangomod.createsuperuser("settings.py", "testuser",
                                   "*****@*****.**")
         self.assertEqual(mock.call_count, 1)
         mock.assert_called_with(
             "django-admin.py createsuperuser --settings=settings.py --noinput "
             "[email protected] --username=testuser",
             env=None,
             python_shell=False,
             runas=None,
         )
示例#5
0
 def test_django_admin_cli_createsuperuser(self):
     mock = MagicMock()
     with patch.dict(djangomod.__salt__, {'cmd.run': mock}):
         djangomod.createsuperuser('settings.py', 'testuser',
                                   '*****@*****.**')
         self.assertEqual(mock.call_count, 1)
         args, kwargs = mock.call_args
         # cmdline arguments are extracted from a kwargs dict so order isn't guaranteed.
         self.assertEqual(len(args), 1)
         self.assertTrue(
             args[0].startswith('django-admin.py createsuperuser --'))
         self.assertEqual(
             set(args[0].split()),
             set('django-admin.py createsuperuser --settings=settings.py --noinput '
                 '--username=testuser [email protected]'.split()))
         self.assertDictEqual(kwargs, {'python_shell': False, 'env': None})
示例#6
0
 def test_createsuperuser(self):
     """
     Test if it create a super user for the database.
     """
     mock = MagicMock(return_value=True)
     with patch.dict(djangomod.__salt__, {"cmd.run": mock}):
         self.assertTrue(
             djangomod.createsuperuser("DJANGO_SETTINGS_MODULE", "SALT",
                                       "*****@*****.**"))
示例#7
0
 def test_createsuperuser(self):
     '''
     Test if it create a super user for the database.
     '''
     mock = MagicMock(return_value=True)
     with patch.dict(djangomod.__salt__, {'cmd.run': mock}):
         self.assertTrue(djangomod.createsuperuser('DJANGO_SETTINGS_MODULE',
                                                   'SALT',
                                                   '*****@*****.**'))
示例#8
0
 def test_django_admin_cli_createsuperuser(self):
     mock = MagicMock()
     with patch.dict(djangomod.__salt__, {"cmd.run": mock}):
         djangomod.createsuperuser("settings.py", "testuser", "*****@*****.**")
         self.assertEqual(mock.call_count, 1)
         args, kwargs = mock.call_args
         # cmdline arguments are extracted from a kwargs dict so order isn't guaranteed.
         self.assertEqual(len(args), 1)
         self.assertTrue(args[0].startswith("django-admin.py createsuperuser --"))
         self.assertEqual(
             set(args[0].split()),
             set(
                 "django-admin.py createsuperuser --settings=settings.py --noinput "
                 "--username=testuser [email protected]".split()
             ),
         )
         self.assertDictEqual(
             kwargs, {"python_shell": False, "env": None, "runas": None}
         )