Ejemplo n.º 1
0
 def test_post_single(self, rest_api, repo_name):
     """Tests single non-existent repo using POST."""
     if repo_name:
         request_body = tools.gen_repos_body([repo_name])
         repos = rest_api.get_repos(body=request_body).response_check()
         assert not repos
     else:
         request_body = tools.gen_repos_body([])
         rest_api.get_repos(body=request_body).response_check(400)
Ejemplo n.º 2
0
    def test_pagination(self, rest_api):
        """Tests repos pagination using POST."""
        old_repos = []
        name, num = REPOS_PAGE
        pages = ceil(num / PAGE_SIZE)
        for i in range(1, pages + 1):
            request_body = tools.gen_repos_body(repos=[name],
                                                page=i,
                                                page_size=PAGE_SIZE)
            repos = rest_api.get_repos(body=request_body).response_check()
            if i < pages:
                assert len(repos) == PAGE_SIZE
            else:
                # last page
                assert len(repos) == num % PAGE_SIZE

            schemas.repos_schema.validate(repos.raw.body)
            # Check if page/page_size/pages values are correct
            assert i == repos.raw.body['page']
            assert PAGE_SIZE == repos.raw.body['page_size']
            assert pages == repos.raw.body['pages']
            # erratum from old pages are not present on actual page
            for erratum in old_repos:
                assert erratum not in repos
            old_repos += repos
Ejemplo n.º 3
0
 def test_post_multi(self, rest_api):
     """Tests multiple repos using POST."""
     request_body = tools.gen_repos_body([p[0] for p in REPOS])
     repos = rest_api.get_repos(body=request_body).response_check()
     schemas.repos_schema.validate(repos.raw.body)
     assert len(repos) == len(REPOS)
     for repo_name, min_expected in REPOS:
         assert len(repos[repo_name]) >= min_expected
Ejemplo n.º 4
0
 def test_post_single(self, rest_api, repo):
     """Tests single repo using POST."""
     repo_name, min_expected = repo
     request_body = tools.gen_repos_body([repo_name])
     repos = rest_api.get_repos(body=request_body).response_check()
     schemas.repos_schema.validate(repos.raw.body)
     assert len(repos) == 1
     repo, = repos
     assert len(repo) >= min_expected
Ejemplo n.º 5
0
    def test_pagination_neg(self, rest_api, page_info):
        """Negative testing of repos pagination with page/page_size <= 0"""
        name, _ = REPOS_PAGE
        _, page, page_size = page_info
        request_body = tools.gen_repos_body(repos=[name],
                                            page=page,
                                            page_size=page_size)
        if isinstance(page, str) or isinstance(page_size, str):
            rest_api.get_repos(body=request_body).response_check(400)
            return
        else:
            repos = rest_api.get_repos(body=request_body).response_check()

        assert DEFAULT_PAGE_SIZE == repos.raw.body['page_size']
        if page > DEFAULT_PAGE:
            assert page == repos.raw.body['page']
            assert not repos.raw.body['repository_list']
        else:
            assert DEFAULT_PAGE == repos.raw.body['page']
            assert repos
Ejemplo n.º 6
0
 def test_post_multi(self, rest_api):
     """Tests multiple non-existent repos using POST."""
     request_body = tools.gen_repos_body(REPOS_NONEXISTENT)
     repos = rest_api.get_repos(body=request_body).response_check()
     assert not repos