Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-3347

Fix test_rhel_unlimited_sku_capacity

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Critical Critical
    • 2025-04-16 - API
    • None
    • None
    • None
    • 5
    • False
    • Hide

      None

      Show
      None
    • False

      Test: tests.component.swatch_contracts.test_offering.test_rhel_unlimited_sku_capacity

      Output:

      application = <iqe.base.application.Application object at 0x7fd30cda83e0>
      
          @pytest.mark.ephemeral
          def test_rhel_unlimited_sku_capacity(application):
              """Test unlimited sku capacity
              metadata:
                  assignee: karshah
                  negative: true
                  bugzilla: SWATCH-2536
                  requirements: capacity
                  test_steps:
                      1. Create sku offering by using sync offering.
                      2. Create mock subscription for the sku
                      3. Get sku capacity for Rhel by metric_id
                  expected_results:
                      1. Response should be subscription with limited and/or unlimited capacity
              """
              application.rhsm_subscriptions.reset_account()
              sku = "RH02252"
              billing_provider = "aws"
              product_id = "RHEL for x86"
              metric_id = "Sockets"
              billing_account_id = "testRH02781MO"
          
              # Sync the offering for the sku to get sku_product_tag and offering populated
              application.rhsm_subscriptions.sync_offering(sku=sku)
          
              # Attach subscription for the sku
              sku_data = application.rhsm_subscriptions.create_mock_subscription(
                  sku=sku,
                  billing_provider=billing_provider,
                  billing_account_id=billing_account_id,
              )
              # Validate SKU existence in the subscription data
              assert sku_data, "No subscription data returned."
              assert sku_data[0]["subscriptionProducts"][0]["sku"] == sku, f"Expected SKU {sku} not found."
          
              # Check if SKU exists in any subscription product
              assert any(
                  any(product["sku"] == sku for product in sub.get("subscriptionProducts", []))
                  for sub in sku_data
              ), f"SKU {sku} not found in subscription data."
          
              # Fetch API response for SKU capacity report that pulls from subscription_capacity_view
              api_response = application.rhsm_subscriptions.rest_contracts_v2_client.subscriptions_api.get_sku_capacity_report(
                  product_id=product_id, metric_id=metric_id
              )
      >       assert api_response and api_response.data, "API response is empty."
      E       AssertionError: API response is empty.
      E       assert ({'data': [],\n 'meta': {'count': 0,\n          'measurements': ['Sockets'],\n          'product': 'RHEL for x86',\n          'subscription_type': 'Annual'}} and [])
      E        +  where [] = {'data': [],\n 'meta': {'count': 0,\n          'measurements': ['Sockets'],\n          'product': 'RHEL for x86',\n          'subscription_type': 'Annual'}}.data
      
      /iqe_venv/lib64/python3.12/site-packages/iqe_rhsm_subscriptions/tests/component/swatch_contracts/test_offering.py:114: AssertionError
      

      This test seems to be failing consistently in all the PR checks.

              rhn-sqe-tmcknigh Trayvon McKnight
              jcarvaja@redhat.com Jose Carvajal Hilario
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: