Пример #1
0
 def test_register_error(self):
     '''
     Test suseconnect.register error
     '''
     result = {
         'retcode': 1,
         'stdout': 'Unknown Registration Code',
         'stderr': ''
     }
     salt_mock = {
         'cmd.run_all': MagicMock(return_value=result),
     }
     with patch.dict(suseconnect.__salt__, salt_mock):
         with self.assertRaises(CommandExecutionError):
             suseconnect.register('regcode')
Пример #2
0
 def test_register_error(self):
     """
     Test suseconnect.register error
     """
     result = {
         "retcode": 1,
         "stdout": "Unknown Registration Code",
         "stderr": ""
     }
     salt_mock = {
         "cmd.run_all": MagicMock(return_value=result),
     }
     with patch.dict(suseconnect.__salt__, salt_mock):
         with self.assertRaises(CommandExecutionError):
             suseconnect.register("regcode")
Пример #3
0
 def test_register_params(self):
     """
     Test suseconnect.register with parameters
     """
     result = {"retcode": 0, "stdout": "Successfully registered system"}
     salt_mock = {
         "cmd.run_all": MagicMock(return_value=result),
     }
     with patch.dict(suseconnect.__salt__, salt_mock):
         self.assertEqual(
             suseconnect.register(
                 "regcode",
                 product="sle-ha/15.2/x86_64",
                 email="*****@*****.**",
                 url="https://scc.suse.com",
                 root="/mnt",
             ),
             "Successfully registered system",
         )
         salt_mock["cmd.run_all"].assert_called_with([
             "SUSEConnect",
             "--regcode",
             "regcode",
             "--product",
             "sle-ha/15.2/x86_64",
             "--email",
             "*****@*****.**",
             "--url",
             "https://scc.suse.com",
             "--root",
             "/mnt",
         ])
Пример #4
0
 def test_register(self):
     '''
     Test suseconnect.register without parameters
     '''
     result = {'retcode': 0, 'stdout': 'Successfully registered system'}
     salt_mock = {
         'cmd.run_all': MagicMock(return_value=result),
     }
     with patch.dict(suseconnect.__salt__, salt_mock):
         self.assertEqual(suseconnect.register('regcode'),
                          'Successfully registered system')
         salt_mock['cmd.run_all'].assert_called_with(
             ['SUSEConnect', '--regcode', 'regcode'])
Пример #5
0
 def test_register(self):
     """
     Test suseconnect.register without parameters
     """
     result = {"retcode": 0, "stdout": "Successfully registered system"}
     salt_mock = {
         "cmd.run_all": MagicMock(return_value=result),
     }
     with patch.dict(suseconnect.__salt__, salt_mock):
         self.assertEqual(suseconnect.register("regcode"),
                          "Successfully registered system")
         salt_mock["cmd.run_all"].assert_called_with(
             ["SUSEConnect", "--regcode", "regcode"])
Пример #6
0
 def test_register_params(self):
     '''
     Test suseconnect.register with parameters
     '''
     result = {'retcode': 0, 'stdout': 'Successfully registered system'}
     salt_mock = {
         'cmd.run_all': MagicMock(return_value=result),
     }
     with patch.dict(suseconnect.__salt__, salt_mock):
         self.assertEqual(
             suseconnect.register('regcode',
                                  product='sle-ha/15.2/x86_64',
                                  email='*****@*****.**',
                                  url='https://scc.suse.com',
                                  root='/mnt'),
             'Successfully registered system')
         salt_mock['cmd.run_all'].assert_called_with([
             'SUSEConnect', '--regcode', 'regcode', '--product',
             'sle-ha/15.2/x86_64', '--email', '*****@*****.**', '--url',
             'https://scc.suse.com', '--root', '/mnt'
         ])