def test_plan(self): plan = self.plan json_data = plan_adapter(plan, self.dummy_request) expected = dict( guid=plan.guid, plan_type='debit', frequency='weekly', amount=plan.amount, interval=plan.interval, created_at=plan.created_at.isoformat(), updated_at=plan.updated_at.isoformat(), company_guid=plan.company_guid, deleted=plan.deleted, ) self.assertEqual(json_data, expected) def assert_type(plan_type, expected_type): plan.plan_type = plan_type json_data = plan_adapter(plan, self.dummy_request) self.assertEqual(json_data['plan_type'], expected_type) assert_type(self.plan_model.types.DEBIT, 'debit') assert_type(self.plan_model.types.CREDIT, 'credit') def assert_frequency(frequency, expected_frequency): plan.frequency = frequency json_data = plan_adapter(plan, self.dummy_request) self.assertEqual(json_data['frequency'], expected_frequency) assert_frequency(self.plan_model.frequencies.DAILY, 'daily') assert_frequency(self.plan_model.frequencies.WEEKLY, 'weekly') assert_frequency(self.plan_model.frequencies.MONTHLY, 'monthly') assert_frequency(self.plan_model.frequencies.YEARLY, 'yearly')
def test_plan(self): plan = self.plan json_data = plan_adapter(plan, self.dummy_request) expected = dict( guid=plan.guid, plan_type='charge', frequency='weekly', amount=plan.amount, interval=plan.interval, created_at=plan.created_at.isoformat(), updated_at=plan.updated_at.isoformat(), company_guid=plan.company_guid, deleted=plan.deleted, ) self.assertEqual(json_data, expected) def assert_type(plan_type, expected_type): plan.plan_type = plan_type json_data = plan_adapter(plan, self.dummy_request) self.assertEqual(json_data['plan_type'], expected_type) assert_type(self.plan_model.TYPE_CHARGE, 'charge') assert_type(self.plan_model.TYPE_PAYOUT, 'payout') def assert_frequency(frequency, expected_frequency): plan.frequency = frequency json_data = plan_adapter(plan, self.dummy_request) self.assertEqual(json_data['frequency'], expected_frequency) assert_frequency(self.plan_model.FREQ_DAILY, 'daily') assert_frequency(self.plan_model.FREQ_WEEKLY, 'weekly') assert_frequency(self.plan_model.FREQ_MONTHLY, 'monthly') assert_frequency(self.plan_model.FREQ_YEARLY, 'yearly')
def assert_frequency(frequency, expected_frequency): plan.frequency = frequency json_data = plan_adapter(plan, self.dummy_request) self.assertEqual(json_data['frequency'], expected_frequency)
def assert_type(plan_type, expected_type): plan.plan_type = plan_type json_data = plan_adapter(plan, self.dummy_request) self.assertEqual(json_data['plan_type'], expected_type)