def test_monthly_restore(self): """Monthly restore""" ent = OrganizationEntitlementFactory() organization = OrganizationFactory( entitlement=ent, date_update=date(2019, 2, 21), requests_per_month=50, monthly_requests=33, ) organization.update_data({ "name": organization.name, "slug": organization.slug, "individual": False, "private": False, "entitlements": [ent_json(ent, date(2019, 3, 21))], "max_users": 5, "card": "", }) organization.refresh_from_db() eq_(organization.requests_per_month, 50) eq_(organization.monthly_requests, 50)
def test_downgrade_subscription(self): """Downgrade a subscription""" # Downgrades only happen at monthly restore ent = OrganizationEntitlementFactory() plus = EntitlementFactory(name="Plus", resources=dict(minimum_users=5, base_requests=100)) organization = OrganizationFactory( entitlement=plus, date_update=date(2019, 2, 21), requests_per_month=100, monthly_requests=83, ) organization.update_data({ "name": organization.name, "slug": organization.slug, "individual": False, "private": False, "entitlements": [ent_json(ent, date(2019, 3, 21))], "max_users": 5, "card": "", }) organization.refresh_from_db() eq_(organization.requests_per_month, 50) eq_(organization.monthly_requests, 50)
def test_decrease_max_users(self): """Decrease max users""" ent = OrganizationEntitlementFactory() organization = OrganizationFactory( entitlement=ent, date_update=date(2019, 2, 21), requests_per_month=75, monthly_requests=33, ) organization.update_data({ "name": organization.name, "slug": organization.slug, "individual": False, "private": False, "entitlements": [ent_json(ent, date(2019, 2, 21))], "max_users": 7, "card": "", }) organization.refresh_from_db() eq_(organization.requests_per_month, 60) eq_(organization.monthly_requests, 33)
def test_downgrade_subscription(self): """Downgrade a subscription""" # Downgrades only happen at monthly restore OrganizationPlanFactory() plus = PlanFactory( name='Plus', minimum_users=5, base_requests=100, ) organization = OrganizationFactory( plan=plus, date_update=date(2019, 2, 21), max_users=5, requests_per_month=100, monthly_requests=83, ) organization.update_data({ 'name': organization.name, 'slug': organization.slug, 'individual': False, 'private': False, 'plan': 'organization', 'date_update': date(2019, 3, 21), 'max_users': 5, 'card': '', }) organization.refresh_from_db() eq_(organization.requests_per_month, 50) eq_(organization.monthly_requests, 50)
def test_upgrade_subscription(self): """Upgrade a subscription""" PlanFactory( name='Plus', minimum_users=5, base_requests=100, ) organization = OrganizationFactory( plan=OrganizationPlanFactory(), date_update=date(2019, 2, 21), max_users=5, requests_per_month=50, monthly_requests=33, ) organization.update_data({ 'name': organization.name, 'slug': organization.slug, 'individual': False, 'private': False, 'plan': 'plus', 'date_update': date(2019, 2, 21), 'max_users': 5, 'card': '', }) organization.refresh_from_db() eq_(organization.requests_per_month, 100) eq_(organization.monthly_requests, 83)
def test_create_subscription(self): """Create a new subscription""" OrganizationPlanFactory() organization = OrganizationFactory() organization.update_data({ 'name': organization.name, 'slug': organization.slug, 'individual': False, 'private': False, 'plan': 'organization', 'date_update': date(2019, 2, 21), 'max_users': 5, 'card': '', }) organization.refresh_from_db() eq_(organization.requests_per_month, 50) eq_(organization.monthly_requests, 50)
def test_cancel_subscription(self): """Cancel a subscription""" ent = FreeEntitlementFactory() organization = OrganizationFactory( entitlement=OrganizationEntitlementFactory(), date_update=date(2019, 2, 21), requests_per_month=50, monthly_requests=33, ) organization.update_data({ "name": organization.name, "slug": organization.slug, "individual": False, "private": False, "entitlements": [ent_json(ent, None)], "max_users": 5, "card": "", }) organization.refresh_from_db() eq_(organization.requests_per_month, 0) eq_(organization.monthly_requests, 0)
def test_create_subscription(self): """Create a new subscription""" ent = OrganizationEntitlementFactory() organization = OrganizationFactory() organization.update_data({ "name": organization.name, "slug": organization.slug, "individual": False, "private": False, "entitlements": [ent_json(ent, date(2019, 2, 21))], "max_users": 5, "card": "", }) organization.refresh_from_db() eq_(organization.requests_per_month, 50) eq_(organization.monthly_requests, 50)
def test_monthly_restore(self): """Monthly restore""" organization = OrganizationFactory( plan=OrganizationPlanFactory(), date_update=date(2019, 2, 21), max_users=5, requests_per_month=50, monthly_requests=33, ) organization.update_data({ 'name': organization.name, 'slug': organization.slug, 'individual': False, 'private': False, 'plan': 'organization', 'date_update': date(2019, 3, 21), 'max_users': 5, 'card': '', }) organization.refresh_from_db() eq_(organization.requests_per_month, 50) eq_(organization.monthly_requests, 50)
def test_decrease_max_users(self): """Decrease max users""" organization = OrganizationFactory( plan=OrganizationPlanFactory(), date_update=date(2019, 2, 21), max_users=10, requests_per_month=75, monthly_requests=33, ) organization.update_data({ 'name': organization.name, 'slug': organization.slug, 'individual': False, 'private': False, 'plan': 'organization', 'date_update': date(2019, 2, 21), 'max_users': 7, 'card': '', }) organization.refresh_from_db() eq_(organization.requests_per_month, 60) eq_(organization.monthly_requests, 33)
def test_cancel_subscription(self): """Cancel a subscription""" FreePlanFactory() organization = OrganizationFactory( plan=OrganizationPlanFactory(), date_update=date(2019, 2, 21), max_users=5, requests_per_month=50, monthly_requests=33, ) organization.update_data({ 'name': organization.name, 'slug': organization.slug, 'individual': False, 'private': False, 'plan': 'free', 'date_update': None, 'max_users': 5, 'card': '', }) organization.refresh_from_db() eq_(organization.requests_per_month, 0) eq_(organization.monthly_requests, 0)