Beispiel #1
0
    def test_pagination(self, rest_api):
        """Tests errata pagination using POST."""
        old_errata = []
        name, num = ERRATA_PAGE
        pages = ceil(num / PAGE_SIZE)
        for i in range(1, pages + 1):
            request_body = tools.gen_errata_body(errata=[name],
                                                 page=i,
                                                 page_size=PAGE_SIZE)
            errata = rest_api.get_errata(body=request_body).response_check()
            if i < pages:
                assert len(errata) == PAGE_SIZE
            else:
                # last page
                assert len(errata) == num % PAGE_SIZE

            schemas.errata_schema.validate(errata.raw.body)
            # Check if page/page_size/pages values are correct
            assert i == errata.raw.body['page']
            assert PAGE_SIZE == errata.raw.body['page_size']
            assert pages == errata.raw.body['pages']
            # erratum from old pages are not present on actual page
            for erratum in old_errata:
                assert erratum not in errata
            old_errata += errata
Beispiel #2
0
 def test_post_single(self, rest_api, erratum_name):
     """Tests single erratum using POST."""
     request_body = tools.gen_errata_body([erratum_name])
     errata = rest_api.get_errata(body=request_body).response_check()
     schemas.errata_schema.validate(errata.raw.body)
     assert len(errata) == 1
     erratum, = errata
     assert erratum.name == erratum_name
Beispiel #3
0
 def test_post_multi(self, rest_api):
     """Tests multiple errata using POST."""
     request_body = tools.gen_errata_body(ERRATA)
     errata = rest_api.get_errata(body=request_body).response_check()
     schemas.errata_schema.validate(errata.raw.body)
     assert len(errata) == len(ERRATA)
     for erratum_name in ERRATA:
         assert erratum_name in errata
Beispiel #4
0
    def post_single(self, rest_api, erratum):
        """Tests single erratum using POST."""
        erratum_name, _ = erratum
        if erratum_name:
            request_body = tools.gen_errata_body([erratum_name])
            errata = rest_api.get_errata(body=request_body).response_check()
        else:
            request_body = tools.gen_errata_body([])
            rest_api.get_errata(body=request_body).response_check(400)
            return

        if erratum_name in [e[0] for e in ERRATA_NEG]:
            assert not errata
        else:
            schemas.errata_schema.validate(errata.raw.body)
            assert len(errata) == 1
            erratum, = errata
            assert erratum.name == erratum_name
Beispiel #5
0
 def post_multi(self, rest_api, errata):
     """Tests multiple errata using POST."""
     request_body = tools.gen_errata_body([e[0] for e in errata])
     errata_response = rest_api.get_errata(
         body=request_body).response_check()
     schemas.errata_schema.validate(errata_response.raw.body)
     exp_errata = [x for x in errata if x not in ERRATA_NEG]
     assert len(errata_response) == len(exp_errata)
     for erratum_name, __ in exp_errata:
         assert erratum_name in errata_response
Beispiel #6
0
 def post_multi(self, rest_api, errata):
     """Tests multiple errata using POST."""
     request_body = tools.gen_errata_body(
         [e[0] for e in errata], modified_since='2018-04-06T00:00:00+01:00')
     errata_response = rest_api.get_errata(
         body=request_body).response_check()
     schemas.errata_schema.validate(errata_response.raw.body)
     assert len(errata_response) == len([e[1] for e in errata if e[1]])
     for __, expected_name in errata:
         if expected_name:  # not None
             assert expected_name in errata_response
Beispiel #7
0
 def test_post_single(self, rest_api, erratum):
     """Tests single erratum using POST."""
     erratum_name, errata_num = erratum
     if erratum_name in ['RH.*'] and GH(310).blocks:
         pytest.skip("Blocked by GH#310")
     request_body = tools.gen_errata_body([erratum_name])
     if erratum_name == '*':
         errata = rest_api.get_errata(body=request_body).response_check(400)
     else:
         errata = rest_api.get_errata(body=request_body).response_check()
         assert len(errata) == errata_num
         if errata_num > 0:
             schemas.errata_schema.validate(errata.raw.body)
Beispiel #8
0
 def post_single(self, rest_api, erratum):
     """Tests single erratum using POST."""
     name, expected_name = erratum
     if not name and GH(326).blocks:
         pytest.skip('Blocked by GH#326')
     request_body = tools.gen_errata_body(
         [name], modified_since='2018-04-06T00:00:00+01:00')
     errata = rest_api.get_errata(body=request_body).response_check()
     # don't validate schema on empty response
     if expected_name:
         schemas.errata_schema.validate(errata.raw.body)
         assert len(errata) == 1
         erratum, = errata
         assert erratum.name == expected_name
     else:
         assert not errata
Beispiel #9
0
    def test_pagination_neg(self, rest_api, page_info):
        """Negative testing of errata pagination with page/page_size <= 0"""
        name, _ = ERRATA_PAGE
        _, page, page_size = page_info
        request_body = tools.gen_errata_body(errata=[name],
                                             page=page,
                                             page_size=page_size)
        if isinstance(page, str) or isinstance(page_size, str):
            rest_api.get_errata(body=request_body).response_check(400)
            return
        else:
            errata = rest_api.get_errata(body=request_body).response_check()

        assert DEFAULT_PAGE_SIZE == errata.raw.body['page_size']
        if page > DEFAULT_PAGE:
            assert page == errata.raw.body['page']
            assert not errata.raw.body['errata_list']
        else:
            assert DEFAULT_PAGE == errata.raw.body['page']
            assert errata
Beispiel #10
0
 def test_modified_no_tz(self, rest_api, erratum):
     """Tests modified since without timezone using POST."""
     request_body = tools.gen_errata_body(
         [erratum], modified_since='2018-04-06T00:00:00')
     errata = rest_api.get_errata(body=request_body).response_check(400)
     assert 'Wrong date format' in errata.raw.body