mirror of
https://github.com/quay/quay.git
synced 2025-07-30 07:43:13 +03:00
marketplace: splittable sku for MW02702 (PROJQUAY-8151) (#3389)
* marketplace: splittable sku for MW02702 (PROJQUAY-8151) * Alembic migration to drop unique constraint on the orgrhsubscriptions table * Can split sub quantities of MW02702 across multiple orgs * Can specify quantity for the MW02702 SKU across orgs on react UI * Update angular UI to allow user to specify quantities for MW02702
This commit is contained in:
@ -5185,6 +5185,38 @@ class TestSuperUserManagement(ApiTestCase):
|
||||
self.assertEqual(len(json["messages"]), 1)
|
||||
|
||||
|
||||
class TestUserSku(ApiTestCase):
|
||||
def test_get_user_skus(self):
|
||||
self.login(SUBSCRIPTION_USER)
|
||||
json = self.getJsonResponse(UserSkuList)
|
||||
self.assertEqual(len(json), 3)
|
||||
|
||||
def test_quantity(self):
|
||||
self.login(SUBSCRIPTION_USER)
|
||||
subscription_user = model.user.get_user(SUBSCRIPTION_USER)
|
||||
plans = check_internal_api_for_subscription(subscription_user)
|
||||
assert len(plans) == 13
|
||||
|
||||
def test_split_sku(self):
|
||||
self.login(SUBSCRIPTION_USER)
|
||||
user = model.user.get_user(SUBSCRIPTION_USER)
|
||||
org = model.organization.get_organization(SUBSCRIPTION_ORG)
|
||||
model.organization_skus.bind_subscription_to_org(80808080, org.id, user.id, 3)
|
||||
|
||||
user_subs = self.getJsonResponse(resource_name=UserSkuList)
|
||||
|
||||
unassigned_sub = None
|
||||
assigned_sub = None
|
||||
for sub in user_subs:
|
||||
if sub["id"] == 80808080 and sub["assigned_to_org"] is None:
|
||||
unassigned_sub = sub
|
||||
elif sub["id"] == 80808080 and sub["assigned_to_org"] is not None:
|
||||
assigned_sub = sub
|
||||
self.assertIsNotNone(unassigned_sub, "Could not find unassigned remaining subscription")
|
||||
self.assertIsNotNone(assigned_sub, "Could not find assigned subscription")
|
||||
self.assertEqual(7, unassigned_sub["quantity"])
|
||||
|
||||
|
||||
class TestOrganizationRhSku(ApiTestCase):
|
||||
def test_bind_sku_to_org(self):
|
||||
self.login(SUBSCRIPTION_USER)
|
||||
@ -5209,7 +5241,7 @@ class TestOrganizationRhSku(ApiTestCase):
|
||||
resource_name=OrganizationRhSku,
|
||||
params=dict(orgname=SUBSCRIPTION_ORG),
|
||||
data={"subscriptions": [{"subscription_id": 12345678}]},
|
||||
expected_code=400,
|
||||
expected_code=401,
|
||||
)
|
||||
|
||||
def test_bind_sku_unauthorized(self):
|
||||
@ -5320,18 +5352,28 @@ class TestOrganizationRhSku(ApiTestCase):
|
||||
json = self.getJsonResponse(OrgPrivateRepositories, params=dict(orgname=SUBSCRIPTION_ORG))
|
||||
self.assertEqual(json["privateAllowed"], False)
|
||||
|
||||
|
||||
class TestUserSku(ApiTestCase):
|
||||
def test_get_user_skus(self):
|
||||
def test_splittable_sku(self):
|
||||
self.login(SUBSCRIPTION_USER)
|
||||
json = self.getJsonResponse(UserSkuList)
|
||||
self.assertEqual(len(json), 2)
|
||||
|
||||
def test_quantity(self):
|
||||
self.login(SUBSCRIPTION_USER)
|
||||
subscription_user = model.user.get_user(SUBSCRIPTION_USER)
|
||||
plans = check_internal_api_for_subscription(subscription_user)
|
||||
assert len(plans) == 3
|
||||
self.postResponse(
|
||||
resource_name=OrganizationRhSku,
|
||||
params=dict(orgname=SUBSCRIPTION_ORG),
|
||||
data={"subscriptions": [{"subscription_id": 80808080, "quantity": 3}]},
|
||||
expected_code=201,
|
||||
)
|
||||
|
||||
self.postResponse(
|
||||
resource_name=OrganizationRhSku,
|
||||
params=dict(orgname=SUBSCRIPTION_ORG),
|
||||
data={"subscriptions": [{"subscription_id": 80808080, "quantity": 10}]},
|
||||
expected_code=400,
|
||||
)
|
||||
|
||||
org_subs = self.getJsonResponse(
|
||||
resource_name=OrganizationRhSku,
|
||||
params=dict(orgname=SUBSCRIPTION_ORG),
|
||||
)
|
||||
self.assertEqual(org_subs[0]["quantity"], 3)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user