def test_list_extensions_error(self): ''' Test suseconnect.list_extensions error ''' result = { 'retcode': 1, 'stdout': 'To list extensions, you must first register ' 'the base product', 'stderr': '' } salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): with self.assertRaises(CommandExecutionError): suseconnect.list_extensions()
def test_list_extensions_params(self): """ Test suseconnect.list_extensions with parameters """ result = { "retcode": 0, "stdout": "Activate with: SUSEConnect -p sle-ha/15.2/x86_64", } salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): self.assertEqual( suseconnect.list_extensions(url="https://scc.suse.com", root="/mnt"), ["sle-ha/15.2/x86_64"], ) salt_mock["cmd.run_all"].assert_called_with([ "SUSEConnect", "--list-extensions", "--url", "https://scc.suse.com", "--root", "/mnt", ])
def test_list_extensions_error(self): """ Test suseconnect.list_extensions error """ result = { "retcode": 1, "stdout": "To list extensions, you must first register " "the base product", "stderr": "", } salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): with self.assertRaises(CommandExecutionError): suseconnect.list_extensions()
def test_list_extensions(self): ''' Test suseconnect.list_extensions without parameters ''' result = { 'retcode': 0, 'stdout': 'Activate with: SUSEConnect -p sle-ha/15.2/x86_64', } salt_mock = { 'cmd.run_all': MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): self.assertEqual(suseconnect.list_extensions(), ['sle-ha/15.2/x86_64']) salt_mock['cmd.run_all'].assert_called_with( ['SUSEConnect', '--list-extensions'])
def test_list_extensions(self): """ Test suseconnect.list_extensions without parameters """ result = { "retcode": 0, "stdout": "Activate with: SUSEConnect -p sle-ha/15.2/x86_64", } salt_mock = { "cmd.run_all": MagicMock(return_value=result), } with patch.dict(suseconnect.__salt__, salt_mock): self.assertEqual(suseconnect.list_extensions(), ["sle-ha/15.2/x86_64"]) salt_mock["cmd.run_all"].assert_called_with( ["SUSEConnect", "--list-extensions"])