Example #1
0
    def splice_check_report(typeinstance, days_start=None, days_end=None, past_hours=None, state=[], current=0, invalid=0, insufficient=0, satellite_name=None):
        """
        Create splice report and check it

        @param days_start: Number of past days for report start_date (e.g. 7 means 7 days ago)
        @type days_start: int

        @param days_end: Number of past days for report end_date (e.g. 1 means 1 day ago)
        @type days_end: int

        @param past_hours: Create report for past N hours
        @type past_hours: int

        @param state: states ['Active', 'Inactive', 'Deleted']
        @type state: list

        @param current: expected number of current subscriptions
        @type current: int

        @param invalid: expected number of invalid subscriptions
        @type invalid: int

        @param insufficient: expected number of insufficient subscriptions
        @type insufficient: int

        @param satellite_name: satellite name
        @type insufficient: str
        """
        if satellite_name is None:
            satellite_name = typeinstance.ss.Instances["FAKE_SPACEWALK"][0].hostname

        if days_start is not None and days_end is not None:
            start_date, end_date = report.date_ago(days_start), report.date_ago(days_end)
            filter_name = report.dates_filter_name(start_date, end_date, state)

            id_rep = typeinstance.katello.create_report(filter_name, start_date=start_date, end_date=end_date, state=state, satellite_name=satellite_name)

        elif past_hours is not None:
            filter_name = report.hours_filter_name(past_hours, state)
            id_rep = typeinstance.katello.create_report(filter_name, time='choose_hour', hours=past_hours, state=state, satellite_name=satellite_name)
        else:
            # Wrong usage
            assert False
            return
        csv, metadata, expjson = typeinstance.katello.run_report(id_rep)
        res_rep = parse_report_json(expjson)
        nose.tools.assert_equal(res_rep['number_of_current'], current)
        nose.tools.assert_equal(res_rep['number_of_invalid'], invalid)
        nose.tools.assert_equal(res_rep['number_of_insufficient'], insufficient)
        typeinstance.katello.delete_report(id_rep)
 def splice_check_report(typeinstance, days_start=None, days_end=None, past_hours=None, state=[u'Active', u'Inactive', u'Deleted'], current=0, invalid=0, insufficient=0, organizations=[u'Testing Org']):
     report_page = None
     KATELLO = typeinstance.KATELLO
     SE.reset(url=KATELLO.url)
     if days_start is not None and days_end is not None:
         # date-range mode
         start_date, end_date = report.date_ago(days_start), report.date_ago(days_end)
         filter_name = report.dates_filter_name(start_date, end_date, state)
         with typeinstance._env_ctx(KATELLO.url, KATELLO.user, KATELLO.password, organizations[0]):
             with filter_date_range_ctx(
                     name=filter_name,
                     start_date=start_date,
                     end_date=end_date,
                     organizations=organizations,
                     lifecycle_states=state
                 ) as (filters_page, report_filter):
                 report_page = report_filter.run_report()
                 # assert the values
                 nose.tools.assert_equal(report_page.current_subscriptions.count.text, unicode(current))
                 nose.tools.assert_equal(report_page.insufficient_subscriptions.count.text, unicode(insufficient))
                 nose.tools.assert_equal(report_page.invalid_subscriptions.count.text, unicode(invalid))
                             
     elif past_hours is not None:
         # hours-based operation
         filter_name = report.hours_filter_name(past_hours, state)
         with typeinstance._env_ctx(KATELLO.url, KATELLO.user, KATELLO.password, organizations[0]):
             with filter_hours_ctx(
                     name=filter_name,
                     hours=past_hours,
                     organizations=organizations,
                     lifecycle_states=state
                 ) as (filters_page, report_filter):
                 report_page = report_filter.run_report()
                 # assert the values
                 nose.tools.assert_equal(report_page.current_subscriptions.count.text, unicode(current))
                 nose.tools.assert_equal(report_page.insufficient_subscriptions.count.text, unicode(insufficient))
                 nose.tools.assert_equal(report_page.invalid_subscriptions.count.text, unicode(invalid))
     else:
         # Wrong usage
         assert False, "Wrong usage"
         return # not reached
    def splice_check_report(typeinstance,
                            days_start=None,
                            days_end=None,
                            past_hours=None,
                            state=[u'Active', u'Inactive', u'Deleted'],
                            current=0,
                            invalid=0,
                            insufficient=0,
                            organizations=[u'Testing Org']):
        report_page = None
        KATELLO = typeinstance.KATELLO
        SE.reset(url=KATELLO.url)
        if days_start is not None and days_end is not None:
            # date-range mode
            start_date, end_date = report.date_ago(
                days_start), report.date_ago(days_end)
            filter_name = report.dates_filter_name(start_date, end_date, state)
            with typeinstance._env_ctx(KATELLO.url, KATELLO.user,
                                       KATELLO.password, organizations[0]):
                with filter_date_range_ctx(
                        name=filter_name,
                        start_date=start_date,
                        end_date=end_date,
                        organizations=organizations,
                        lifecycle_states=state) as (filters_page,
                                                    report_filter):
                    report_page = report_filter.run_report()
                    # assert the values
                    nose.tools.assert_equal(
                        report_page.current_subscriptions.count.text,
                        unicode(current))
                    nose.tools.assert_equal(
                        report_page.insufficient_subscriptions.count.text,
                        unicode(insufficient))
                    nose.tools.assert_equal(
                        report_page.invalid_subscriptions.count.text,
                        unicode(invalid))

        elif past_hours is not None:
            # hours-based operation
            filter_name = report.hours_filter_name(past_hours, state)
            with typeinstance._env_ctx(KATELLO.url, KATELLO.user,
                                       KATELLO.password, organizations[0]):
                with filter_hours_ctx(
                        name=filter_name,
                        hours=past_hours,
                        organizations=organizations,
                        lifecycle_states=state) as (filters_page,
                                                    report_filter):
                    report_page = report_filter.run_report()
                    # assert the values
                    nose.tools.assert_equal(
                        report_page.current_subscriptions.count.text,
                        unicode(current))
                    nose.tools.assert_equal(
                        report_page.insufficient_subscriptions.count.text,
                        unicode(insufficient))
                    nose.tools.assert_equal(
                        report_page.invalid_subscriptions.count.text,
                        unicode(invalid))
        else:
            # Wrong usage
            assert False, "Wrong usage"
            return  # not reached