mirror of
https://github.com/quay/quay.git
synced 2025-07-28 20:22:05 +03:00
marketplace: add support for quantity from subscriptions api (PROJQUAY-6551) (#2633)
* Adds handling for when a subscription returned from the subscription watch api has a quantity greater than 1. Number of private repos should be correctly calculated using the quantity. * Updates ui so that subscriptions can only be added to an org as a group, i.e. a subscription with quantity = 2 cannot be split across organizations.
This commit is contained in:
@ -42,6 +42,7 @@ from endpoints.api.billing import (
|
||||
UserCard,
|
||||
UserPlan,
|
||||
UserSkuList,
|
||||
check_internal_api_for_subscription,
|
||||
)
|
||||
from endpoints.api.build import (
|
||||
RepositoryBuildList,
|
||||
@ -5078,7 +5079,7 @@ class TestOrganizationRhSku(ApiTestCase):
|
||||
self.postResponse(
|
||||
resource_name=OrganizationRhSku,
|
||||
params=dict(orgname=SUBSCRIPTION_ORG),
|
||||
data={"subscriptions": [{"subscription_id": 12345678}]},
|
||||
data={"subscriptions": [{"subscription_id": 12345678, "quantity": 2}]},
|
||||
expected_code=201,
|
||||
)
|
||||
json = self.getJsonResponse(
|
||||
@ -5164,6 +5165,19 @@ class TestOrganizationRhSku(ApiTestCase):
|
||||
)
|
||||
self.assertEqual(len(json), 0)
|
||||
|
||||
def test_none_quantity(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(12345678, org.id, user.id, None)
|
||||
json = self.getJsonResponse(
|
||||
resource_name=OrganizationRhSku, params=dict(orgname=SUBSCRIPTION_ORG)
|
||||
)
|
||||
self.assertEqual(json[0]["quantity"], 1)
|
||||
|
||||
plans = check_internal_api_for_subscription(org)
|
||||
assert len(plans) == 1
|
||||
|
||||
|
||||
class TestUserSku(ApiTestCase):
|
||||
def test_get_user_skus(self):
|
||||
@ -5171,6 +5185,12 @@ class TestUserSku(ApiTestCase):
|
||||
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
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user