Ejemplo n.º 1
0
 def test_ext_nodes(self):
     '''
     Confirm that subprocess.Popen works as expected and does not raise an
     exception (see https://github.com/saltstack/salt/pull/46863).
     '''
     stdout = salt.utils.stringutils.to_bytes(
         textwrap.dedent('''\
         classes:
           - one
           - two'''))
     communicate_mock = MagicMock(return_value=(stdout, None))
     with patch.object(subprocess.Popen, 'communicate', communicate_mock):
         ret = ext_nodes.top(opts={'id': 'foo'})
     self.assertEqual(ret, {'base': ['one', 'two']})
Ejemplo n.º 2
0
 def test_ext_nodes(self):
     """
     Confirm that subprocess.Popen works as expected and does not raise an
     exception (see https://github.com/saltstack/salt/pull/46863).
     """
     stdout = salt.utils.stringutils.to_bytes(
         textwrap.dedent("""\
         classes:
           - one
           - two"""))
     communicate_mock = MagicMock(return_value=(stdout, None))
     with patch.object(subprocess.Popen, "communicate", communicate_mock):
         ret = ext_nodes.top(opts={"id": "foo"})
     self.assertEqual(ret, {"base": ["one", "two"]})
Ejemplo n.º 3
0
 def test_ext_nodes_with_environment(self):
     '''
     Same as above, but also tests that the matches are assigned to the proper
     environment if one is returned by the ext_nodes command.
     '''
     stdout = salt.utils.stringutils.to_bytes(
         textwrap.dedent('''\
         classes:
           - one
           - two
         environment: dev'''))
     communicate_mock = MagicMock(return_value=(stdout, None))
     with patch.object(subprocess.Popen, 'communicate', communicate_mock):
         ret = ext_nodes.top(opts={'id': 'foo'})
     self.assertEqual(ret, {'dev': ['one', 'two']})
Ejemplo n.º 4
0
 def test_ext_nodes_with_environment(self):
     """
     Same as above, but also tests that the matches are assigned to the proper
     environment if one is returned by the ext_nodes command.
     """
     stdout = salt.utils.stringutils.to_bytes(
         textwrap.dedent("""\
         classes:
           - one
           - two
         environment: dev"""))
     communicate_mock = MagicMock(return_value=(stdout, None))
     with patch.object(subprocess.Popen, "communicate", communicate_mock):
         ret = ext_nodes.top(opts={"id": "foo"})
     self.assertEqual(ret, {"dev": ["one", "two"]})
Ejemplo n.º 5
0
 def test_ext_nodes(self):
     """
     Confirm that subprocess.Popen works as expected and does not raise an
     exception (see https://github.com/saltstack/salt/pull/46863).
     """
     stdout = salt.utils.stringutils.to_bytes(
         textwrap.dedent("""\
         classes:
           - one
           - two"""))
     run_mock = MagicMock()
     run_mock.return_value.stdout = stdout
     with patch.object(subprocess, "run", run_mock):
         ret = ext_nodes.top(opts={"id": "foo"})
     self.assertEqual(ret, {"base": ["one", "two"]})
     run_mock.assert_called_once_with(["echo", "foo"],
                                      check=True,
                                      stdout=-1)
Ejemplo n.º 6
0
 def test_ext_nodes_with_environment(self):
     """
     Same as above, but also tests that the matches are assigned to the proper
     environment if one is returned by the ext_nodes command.
     """
     stdout = salt.utils.stringutils.to_bytes(
         textwrap.dedent("""\
         classes:
           - one
           - two
         environment: dev"""))
     run_mock = MagicMock()
     run_mock.return_value.stdout = stdout
     with patch.object(subprocess, "run", run_mock):
         ret = ext_nodes.top(opts={"id": "foo"})
     self.assertEqual(ret, {"dev": ["one", "two"]})
     run_mock.assert_called_once_with(["echo", "foo"],
                                      check=True,
                                      stdout=-1)