def test_list_vhosts(self): ''' Test if it return a list of vhost based on rabbitmqctl list_vhosts. ''' mock_run = MagicMock(return_value='...\nsaltstack\n...') with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}): self.assertListEqual(rabbitmq.list_vhosts(), ['saltstack'])
def test_list_vhosts_trailing_done(self): ''' Ensure any trailing '...done' line is stripped from output. ''' mock_run = MagicMock(return_value='...\nsaltstack\n...done') with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}): self.assertListEqual(rabbitmq.list_vhosts(), ['...', 'saltstack'])
def test_list_vhosts_succeeding_listing(self): ''' Ensure succeeding 'Listing ...' line is stripped from output ''' mock_run = MagicMock(return_value='Listing vhosts ...\nsaltstack\n...') with patch.dict(rabbitmq.__salt__, {'cmd.run': mock_run}): self.assertListEqual(rabbitmq.list_vhosts(), ['saltstack', '...'])
def test_list_vhosts(self): ''' Test if it return a list of vhost based on rabbitmqctl list_vhosts. ''' mock_run = MagicMock(return_value={'retcode': 0, 'stdout': '/\nsaltstack\n...', 'stderr': ''}) with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}): self.assertListEqual(rabbitmq.list_vhosts(), ['/', 'saltstack', '...'])
def test_list_vhosts(self): ''' Test if it return a list of vhost based on rabbitmqctl list_vhosts. ''' mock_run = MagicMock(return_value={'retcode': 0, 'stdout': '...\nsaltstack\n...', 'stderr': ''}) with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}): self.assertListEqual(rabbitmq.list_vhosts(), ['...', 'saltstack', '...'])
def test_list_vhosts(self): """ Test if it return a list of vhost based on rabbitmqctl list_vhosts. """ mock_run = MagicMock( return_value={"retcode": 0, "stdout": "/\nsaltstack\n...", "stderr": ""} ) with patch.dict(rabbitmq.__salt__, {"cmd.run_all": mock_run}): self.assertListEqual(rabbitmq.list_vhosts(), ["/", "saltstack", "..."])
def test_list_vhosts_with_warning(self): ''' Test if it return a list of vhost based on rabbitmqctl list_vhosts even with a leading WARNING. ''' rtn_stdout = '\n'.join([ 'WARNING: ignoring /etc/rabbitmq/rabbitmq.conf -- location has moved to /etc/rabbitmq/rabbitmq-env.conf', 'Listing users ...', '/', 'saltstack', '...\n', ]) mock_run = MagicMock(return_value={'retcode': 0, 'stdout': rtn_stdout, 'stderr': ''}) with patch.dict(rabbitmq.__salt__, {'cmd.run_all': mock_run}): self.assertListEqual(rabbitmq.list_vhosts(), ['/', 'saltstack', '...'])
def test_list_vhosts_with_warning(): """ Test if it return a list of vhost based on rabbitmqctl list_vhosts even with a leading WARNING. """ rtn_stdout = "\n".join([ "WARNING: ignoring /etc/rabbitmq/rabbitmq.conf -- location has moved to /etc/rabbitmq/rabbitmq-env.conf", "Listing users ...", "/", "saltstack", "...\n", ]) mock_run = MagicMock(return_value={ "retcode": 0, "stdout": rtn_stdout, "stderr": "" }) with patch.dict(rabbitmq.__salt__, {"cmd.run_all": mock_run}): assert rabbitmq.list_vhosts() == ["/", "saltstack", "..."]