def testUpdateStatus(self): data = sample.copy() created_plan = self.service.create(Plan(**data)) self.assertTrue(created_plan.is_active) plan = self.service.update_status(created_plan.plan_id, False) self.assertFalse(plan.is_active)
def test_create(client_mock, plan_sample, plan_response_sample): client_mock.post.return_value = plan_response_sample service = Service(client_mock) plan = service.create(Plan(**plan_sample)) assert isinstance(plan, Plan) assert plan_response_sample.get("plan_id") == str(plan.plan_id)
def testCreate(self, client_mock): client_mock.post.return_value = response_sample service = Service(client_mock) plan = service.create(Plan(**sample)) self.assertIsInstance(plan, Plan) self.assertEqual(response_sample.get("plan_id"), str(plan.plan_id))
def test_get(client, plan_sample): created_plan = Service(client).create(Plan(**plan_sample)) plan = Service(client).get(created_plan.plan_id) assert isinstance(plan, Plan) assert created_plan == plan assert created_plan.plan_id == plan.plan_id
def testGet(self): data = sample.copy() created_plan = self.service.create(Plan(**data)) plan = self.service.get(created_plan.plan_id) self.assertIsInstance(plan, Plan) self.assertEqual(created_plan, plan) self.assertEqual(created_plan.plan_id, plan.plan_id)
def test_update(client, plan_sample): created_plan = Service(client).create(Plan(**plan_sample)) plan1 = Service(client).update(created_plan.plan_id, "FooBar #1", created_plan.description) assert plan1.name == "FooBar #1" plan2 = Service(client).update(created_plan, "FooBar #2") assert plan2.name == "FooBar #2" created_plan.name = "FooBar #3" plan3 = Service(client).update(created_plan) assert plan3.name == "FooBar #3"
def testUpdate(self): data = sample.copy() created_plan = self.service.create(Plan(**data)) plan1 = self.service.update(created_plan.plan_id, "FooBar #1", created_plan.description) self.assertEqual("FooBar #1", plan1.name) plan2 = self.service.update(created_plan, "FooBar #2") self.assertEqual("FooBar #2", plan2.name) created_plan.name = "FooBar #3" plan3 = self.service.update(created_plan) self.assertEqual("FooBar #3", plan3.name)
def testPeriodConversion(self): plan = Plan(**sample) self.assertIsInstance(plan.period, Period)
def testCreate(self): data = sample.copy() plan = self.service.create(Plan(**data)) self.assertIsInstance(plan, Plan) self.assertIsNotNone(plan.plan_id)
def test_create(client, plan_sample): plan = Service(client).create(Plan(**plan_sample)) assert isinstance(plan, Plan) assert plan.plan_id is not None
def test_update_status(client, plan_sample): created_plan = Service(client).create(Plan(**plan_sample)) assert created_plan.is_active is True plan = Service(client).update_status(created_plan.plan_id, False) assert plan.is_active is False
def test_period_conversion(plan_sample): plan = Plan(**plan_sample) assert isinstance(plan.period, Period)
def test_invalid_product_type(plan_sample): with pytest.raises(AttributeError): plan_sample["product_type"] = "invalid" Plan(**plan_sample)
def test_product_type_as_str(plan_sample): plan_sample["product_type"] = "service" plan = Plan(**plan_sample) assert isinstance(plan.product_type, ProductType) assert plan.product_type == ProductType.SERVICE