def test_is_deleted(self, mock__manager): mock__manager.return_value.get.return_value = [] fres = resources.FuelEnvironment() fres.id = mock.Mock() self.assertTrue(fres.is_deleted()) mock__manager.return_value.get.return_value = ["env"] self.assertFalse(fres.is_deleted())
def test_is_deleted(self, mock__manager): mock__manager.return_value.get.return_value = None fres = resources.FuelEnvironment() fres.id = mock.Mock() self.assertTrue(fres.is_deleted()) mock__manager.return_value.get.return_value = "env" self.assertFalse(fres.is_deleted()) mock__manager.return_value.get.assert_called_with(fres.id.return_value)
def test_list(self, mock_name_matches_object, mock__manager): envs = [{"name": "rally_one"}, {"name": "rally_two"}, {"name": "three"}] mock__manager.return_value.list.return_value = envs mock_name_matches_object.side_effect = ( lambda n, o: n.startswith("rally_")) fres = resources.FuelEnvironment() self.assertEqual(envs[:-1], fres.list())
def test_list(self, mock__manager): envs = [{ "name": "rally_one" }, { "name": "rally_two" }, { "name": "three" }] mock__manager.return_value.list.return_value = envs fres = resources.FuelEnvironment() self.assertEqual(envs[:-1], fres.list())
def test_id(self): fres = resources.FuelEnvironment() fres.raw_resource = {"id": 42, "name": "chavez"} self.assertEqual(42, fres.id())