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

Fix test_verify_tally_hourly_and_daily

XMLWordPrintable

    • 5
    • False
    • Hide

      None

      Show
      None
    • False

      Test:

      application = <iqe.base.application.Application object at 0x7f68ce352a50>
      product_id = 'rosa', billing_provider = 'aws'
      
          @pytest.mark.ephemeral
          @pytest.mark.ephemeral_only
          @pytest.mark.parametrize("product_id", ["rosa"])
          @pytest.mark.parametrize("billing_provider", ["aws"])
          def test_verify_tally_hourly_and_daily(application, product_id, billing_provider):
              """
              Test to verify tally hourly and daily.
              metadata:
                  assignee: dmaranha
                  negative: false
                  importance: high
                  requirements: payg_tally
                  test_steps:
                      1. Reset account
                      2. Generate new fractional data
                      3. Sync
                      4. Verify the tally result with different granularity (daily and hourly).
                  expected_results:
                      1. Daily granularity should be equal the sum of the hourly
                      for both metrics.
              """
              application.rhsm_subscriptions.reset_account()
              billing_account_id = "testhourly123"
              yesterday_day = (datetime.now() - timedelta(days=1)).day
      >       start_hour_list = create_date_time_list(
                  start_times_list=[
                      {"prev_month": 0, "day": yesterday_day, "hour": 7},
                      {"prev_month": 0, "day": yesterday_day, "hour": 10},
                  ]
              )
      
      /iqe_venv/lib/python3.12/site-packages/iqe_rhsm_subscriptions/tests/integration/swatch_tally/test_tally_granularity.py:44: 
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      
      start_times_list = [{'day': 31, 'hour': 7, 'prev_month': 0}, {'day': 31, 'hour': 10, 'prev_month': 0}]
      string_format = None
      
          def create_date_time_list(start_times_list, string_format=None):
              """Returns a list of datetime objects to be used for testing.
              Takes a list of dictionaries (one per time), to define the times.
              Ex: times = [
                  {'prev_month': 1, "day": 1, "hour": 7, "minute": 0, "second": 0, "microsecond":0},
                  {'prev_month': 2, "day": 6, "minute": 7},
              ]
          
              `prev_month` defines the number of months back to go (ex: today is November, prev_month: 1
               will set month to October)
          
              The other options set the datetime to that value (just like a normal datetime object)
              Returns: A list of start time datetime objects, or formatted strings.
              """
              time_replace_options = ["year", "month", "day", "hour", "minute", "second", "microsecond"]
              start_times = []
              for start_time_data in start_times_list:
                  today_datetime = today()
                  start_time = today_datetime.replace(
                      hour=0, minute=0, second=0, microsecond=0
                  )  # Default to start of today
                  if "prev_month" in start_time_data.keys():
                      start_time -= datedelta.datedelta(months=start_time_data["prev_month"])
          
                  replace_pairs = {
                      key: value for (key, value) in start_time_data.items() if key in time_replace_options
                  }
      >           start_time = start_time.replace(**replace_pairs)
      E           ValueError: day is out of range for month
      
      /iqe_venv/lib/python3.12/site-packages/iqe_rhsm_subscriptions/utils/utils.py:230: ValueError
      

      This test started failing on 1 April which might be related.

              rhn-support-aunayak Aurobinda Nayak
              jcarvaja@redhat.com Jose Carvajal Hilario
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: