示例#1
0
    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)
示例#2
0
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)
示例#3
0
    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))
示例#4
0
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
示例#5
0
    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)
示例#6
0
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"
示例#7
0
    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)
示例#8
0
 def testPeriodConversion(self):
     plan = Plan(**sample)
     self.assertIsInstance(plan.period, Period)
示例#9
0
    def testCreate(self):
        data = sample.copy()

        plan = self.service.create(Plan(**data))
        self.assertIsInstance(plan, Plan)
        self.assertIsNotNone(plan.plan_id)
示例#10
0
def test_create(client, plan_sample):
    plan = Service(client).create(Plan(**plan_sample))
    assert isinstance(plan, Plan)
    assert plan.plan_id is not None
示例#11
0
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
示例#12
0
def test_period_conversion(plan_sample):
    plan = Plan(**plan_sample)
    assert isinstance(plan.period, Period)
示例#13
0
def test_invalid_product_type(plan_sample):
    with pytest.raises(AttributeError):
        plan_sample["product_type"] = "invalid"
        Plan(**plan_sample)
示例#14
0
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