def test_can_activate_a_plan(self): with given('defined not active plan'): command = DefineMonthlyPlanFactory() succeeded(self.handle(command)) name = command.name with then('plan can be activated'): succeeded(self.handle(ActivateFactory(name=name)))
def test_can_deactivate_an_existing_plan(self): with given('activate monthly plan'): define = DefineMonthlyPlanFactory() succeeded(self.handle(define)) succeeded(self.handle(ActivateFactory(name=define.name))) name = define.name with then('plan can be deactivated'): succeeded(self.handle(DeactivateFactory(name=name)))
def test_can_count_active_plans(self): with given('2 inactive plans'): for _ in range(2): plan = IndividualPlanFactory(status=Status.Deactivated) self.repository.save(plan) with given('3 active plans'): for _ in range(3): plan = IndividualPlanFactory(status=Status.Activated) self.repository.save(plan) with when('count active plans'): active = self.repository.active_plans_count() with then('result is 3 plans'): self.assertEqual(active, 3)
def test_plan_is_created_with_correct_values(self): command = DefineMonthlyPlanFactory() with when('defining new plan'): succeeded(self.handle(command)) with when('find a plan'): entry = self.repository.find(command.name) with then('plan is present'): self.assertIsNotNone(entry) with expect('correct values'): self.assertEqual(entry.name, command.name) self.assertEqual(entry.max_no_of_pauses, command.pauses) self.assertEqual(entry.fee_amount, command.monthlyFee.amount) self.assertEqual(entry.fee_currency, command.monthlyFee.currency) self.assertEqual(entry.renewal, Renewal.Month)
def test_can_save_a_plan(self): with given('plan'): plan = IndividualPlanFactory() with when('saves in repository'): self.repository.save(plan) self.session.close() with then('plan can be found by name'): entry = self.repository.find(plan.name) self.assertIsNotNone(entry) with expect('same values in entry'): self.assertEqual(plan.name, entry.name) self.assertEqual(plan.status, entry.status) self.assertEqual(plan.fee_amount, entry.fee_amount) self.assertEqual(plan.fee_currency, entry.fee_currency) self.assertEqual(plan.max_no_of_pauses, entry.max_no_of_pauses) self.assertEqual(plan.renewal, entry.renewal)
def test_should_create_a_plan_when_there_is_no_plan_with_such_a_name(self): with given('defined plan'): succeeded(self.handle(DefineMonthlyPlanFactory())) with then('defining yet another plan should succeed'): succeeded(self.handle(DefineMonthlyPlanFactory()))