def test_create_jail(): """ Test if it creates a new poudriere jail if one does not exist. """ mock_stack = MagicMock(return_value="90amd64 stack") mock_true = MagicMock(return_value=True) with patch.dict(poudriere.__salt__, {"cmd.run": mock_stack}), patch( "salt.modules.poudriere._check_config_exists", MagicMock(return_value=True) ): assert poudriere.create_jail("90amd64", "amd64") == "90amd64 already exists" with patch.object(poudriere, "make_pkgng_aware", mock_true): assert ( poudriere.create_jail("80amd64", "amd64") == "Issue creating jail 80amd64" ) with patch.object(poudriere, "make_pkgng_aware", mock_true), patch( "salt.modules.poudriere._check_config_exists", MagicMock(return_value=True) ): with patch.object(poudriere, "is_jail", MagicMock(side_effect=[False, True])): with patch.dict(poudriere.__salt__, {"cmd.run": mock_stack}): assert ( poudriere.create_jail("80amd64", "amd64") == "Created jail 80amd64" )
def test_create_jail(self): ''' Test if it creates a new poudriere jail if one does not exist. ''' mock_stack = MagicMock(return_value='90amd64 stack') mock_true = MagicMock(return_value=True) with patch.dict(poudriere.__salt__, {'cmd.run': mock_stack}): self.assertEqual(poudriere.create_jail('90amd64', 'amd64'), '90amd64 already exists') with patch.object(poudriere, 'make_pkgng_aware', mock_true): self.assertEqual(poudriere.create_jail('80amd64', 'amd64'), 'Issue creating jail 80amd64') with patch.object(poudriere, 'make_pkgng_aware', mock_true): with patch.object(poudriere, 'is_jail', MagicMock(side_effect=[False, True])): with patch.dict(poudriere.__salt__, {'cmd.run': mock_stack}): self.assertEqual(poudriere.create_jail('80amd64', 'amd64'), 'Created jail 80amd64')