def test_create_membership_w_no_end_date(): """ starts from current month. No usage should be created as usages are in future """ member_id = test_data.membership_member_id tariff_id = test_data.plan_id starts_months, ends = months_data.non_ending2 starts = today + relativedelta.relativedelta(months=starts_months) usages_before = usagelib.usage_collection.find(member_ids=[member_id]) membershiplib.new(tariff_id, member_id, starts, ends) usages_after = usagelib.usage_collection.find(member_ids=[member_id]) env.context.pgcursor.connection.commit() no_of_new_usages = len(usages_after) - len(usages_before) assert no_of_new_usages == 0
def test_create_membership_non_ending(): """ must create usages till current month """ member_id = test_data.membership_member_id tariff_id = test_data.plan_id no_of_months, ends = months_data.non_ending starts = today + relativedelta.relativedelta(months=no_of_months) usages_before = usagelib.usage_collection.find(member_ids=[member_id]) membershiplib.new(tariff_id, member_id, starts, ends) usages_after = usagelib.usage_collection.find(member_ids=[member_id]) env.context.pgcursor.connection.commit() no_of_new_usages = len(usages_after) - len(usages_before) assert no_of_new_usages == (abs(no_of_months)+1)
def test_create_membership_w_future_end_date(): """ starts from current month with future ends date """ member_id = test_data.membership_member_id tariff_id = test_data.plan_id starts_months, ends_months = months_data.ends_in_future starts = today + relativedelta.relativedelta(months=starts_months) ends = today + relativedelta.relativedelta(months=ends_months) usages_before = usagelib.usage_collection.find(member_ids=[member_id]) membershiplib.new(tariff_id, member_id, starts, ends) usages_after = usagelib.usage_collection.find(member_ids=[member_id]) env.context.pgcursor.connection.commit() no_of_new_usages = len(usages_after) - len(usages_before) assert no_of_new_usages == (ends_months - starts_months + 1)