def test_store_plan(self): p = plan.Plan(name="super_huge", description="very huge thing", config={"serviceofferingid": "abcdef123"}) self.storage.store_plan(p) got_plan = self.storage.find_plan(p.name) self.assertEqual(p.to_dict(), got_plan.to_dict())
def test_delete_plan(self): p = plan.Plan(name="super_huge", description="very huge thing", config={"serviceofferingid": "abcdef123"}) self.storage.store_plan(p) self.storage.delete_plan(p.name) with self.assertRaises(storage.PlanNotFoundError): self.storage.find_plan(p.name)
def test_update_plan_partial(self): p = plan.Plan(name="super_huge", description="very huge thing", config={"serviceofferingid": "abcdef123"}) self.storage.store_plan(p) self.storage.update_plan(p.name, config={"serviceofferingid": "abcdef123459"}) p = self.storage.find_plan(p.name) self.assertEqual("super_huge", p.name) self.assertEqual("very huge thing", p.description) self.assertEqual({"serviceofferingid": "abcdef123459"}, p.config)
def create_plan(): name = request.form.get("name") description = request.form.get("description") config = json.loads(request.form.get("config", "null")) manager = get_manager() p = plan.Plan(name=name, description=description, config=config) try: manager.storage.store_plan(p) except storage.DuplicateError: return "plan already exists", 409 except plan.InvalidPlanError as e: return unicode(e), 400 return "", 201
def _plan_from_dict(self, dict): dict["name"] = dict["_id"] del dict["_id"] return plan.Plan(**dict)
def test_store_plan_duplicate(self): p = plan.Plan(name="small", description="small thing", config={"serviceofferingid": "abcdef123"}) with self.assertRaises(storage.DuplicateError): self.storage.store_plan(p)