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_should_not_create_a_plan_when_a_name_already_exists(self): with given('defined plan'): name = plan.cmd.PlanName("Very cool plan for 10 bucks") succeeded(self.handle(DefineMonthlyPlanFactory(name=name))) with when('defining plan with same name'): result = self.handle(DefineMonthlyPlanFactory(name=name)) with expect('failure'): failed(result, plan.exce.AlreadyExists)
def test_plan_is_created_with_correct_values(self): command = DefineMonthlyPlanFactory() succeeded(self.handle(command)) entry = self.repository.find(command.name) self.assertIsNotNone(entry) self.assertEqual(entry.name, command.name) self.assertEqual(entry.max_no_of_pauses, command.pauses) self.assertEqual(entry.renewal, Renewal.Month)
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_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 _define_and_activate_random_plan(self) -> Result: define = DefineMonthlyPlanFactory() succeeded(self.handle(define)) return self.handle(ActivateFactory(name=define.name))
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()))