def test_03_hours_ctx(self):
     with current_url(KATELLO.url):
         with login_ctx(KATELLO.username, KATELLO.password):
             with organisation_ctx("ACME_Corporation"):
                 with filters.filter_hours_ctx() as (filters_page, filter_menu):
                     filters_page._navigate()
                     self.filter_menu = filter_menu
                     self.assertNonTimeFields()
                     self.assertHoursField()
                     self.filter_menu = None
 def test_03_hours_ctx(self):
     with current_url(KATELLO.url):
         with login_ctx(KATELLO.username, KATELLO.password):
             with organisation_ctx("ACME_Corporation"):
                 with filters.filter_hours_ctx() as (filters_page,
                                                     filter_menu):
                     filters_page._navigate()
                     self.filter_menu = filter_menu
                     self.assertNonTimeFields()
                     self.assertHoursField()
                     self.filter_menu = None
 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