Exemple #1
0
 def test_no_recipes(self):
     # no recipes, nothing to do
     test_utils.create_git_server()
     with test_utils.RecipeDir() as recipes_dir:
         self.set_counts()
         self.check_load_recipes(recipes_dir)
         self.compare_counts(sha_changed=True)
Exemple #2
0
    def test_removed(self):
        test_utils.create_git_server()
        with test_utils.RecipeDir() as recipes_dir:
            self.create_valid_with_check(recipes_dir)
            self.remove_recipe_from_repo(recipes_dir, "alt.cfg")
            self.set_counts()
            self.check_load_recipes(recipes_dir, removed=1)
            self.compare_counts(
                sha_changed=True,
                recipes=-1,
                deps=-1,
                current=-1,
                num_pr_alt_recipes=-1,
                num_steps=-1,
                num_step_envs=-4,
                num_recipe_envs=-1,
                num_prestep=-2,
            )

            # change a recipe but now the old ones have jobs attached.
            # so 1 new recipe should be added
            build_user = models.GitUser.objects.get(name="moosebuild")
            for r in models.Recipe.objects.all():
                test_utils.create_job(recipe=r, user=build_user)

            self.remove_recipe_from_repo(recipes_dir, "all.cfg")
            self.set_counts()
            self.check_load_recipes(recipes_dir, removed=1)
            self.compare_counts(sha_changed=True, current=-4)
Exemple #3
0
 def test_private(self):
     test_utils.create_git_server()
     with test_utils.RecipeDir() as recipes_dir:
         self.create_recipe_in_repo(recipes_dir, "recipe_private.cfg",
                                    "private.cfg")
         self.set_counts()
         self.check_load_recipes(recipes_dir, new=1)
         self.compare_counts(sha_changed=True,
                             recipes=1,
                             num_pr_recipes=1,
                             num_steps=1,
                             num_step_envs=1,
                             current=1,
                             users=2,
                             repos=1,
                             viewable_teams=2)
Exemple #4
0
 def setUp(self):
     self.client = Client()
     self.factory = RequestFactory()
     self.server = utils.create_git_server(
         host_type=settings.GITSERVER_BITBUCKET)
     self.user = utils.create_user_with_token(server=self.server)
     utils.simulate_login(self.client.session, self.user)
     self.gapi = self.server.api()
Exemple #5
0
 def test_no_user(self):
     # moosebuild user doesn't exist
     test_utils.create_git_server()
     with test_utils.RecipeDir() as recipes_dir:
         self.set_counts()
         self.create_recipe_in_repo(recipes_dir, "push_dep.cfg",
                                    "push_dep.cfg")
         self.check_load_recipes(recipes_dir, new=1)
         self.compare_counts(recipes=2,
                             current=2,
                             sha_changed=True,
                             users=2,
                             repos=1,
                             branches=1,
                             num_push_recipes=1,
                             num_pr_alt_recipes=1,
                             num_steps=4,
                             num_step_envs=16,
                             num_recipe_envs=4,
                             num_prestep=4)
Exemple #6
0
    def create_default_recipes(self, recipes_dir, server_type=settings.GITSERVER_GITHUB):
        hostname = "github.com"
        if server_type == settings.GITSERVER_GITLAB:
            hostname = "gitlab.com"

        self.recipe_file = self.create_recipe_in_repo("recipe_all.cfg", "recipe.cfg", hostname=hostname)
        self.recipe_pr_file = self.create_recipe_in_repo("pr_dep.cfg", "pr_dep.cfg", hostname=hostname)
        self.recipe_push_file = self.create_recipe_in_repo("push_dep.cfg", "push_dep.cfg", hostname=hostname)
        self.server = test_utils.create_git_server(host_type=server_type)
        self.build_user = test_utils.create_user_with_token(name="moosebuild", server=self.server)
        self.owner = test_utils.create_user(name="idaholab", server=self.server)
        self.repo = test_utils.create_repo(name="civet", user=self.owner)
        self.branch = test_utils.create_branch(name="devel", repo=self.repo)
        return self.load_recipes(recipes_dir)
Exemple #7
0
    def create_default_recipes(self, server_type=settings.GITSERVER_GITHUB):
        self.set_counts()
        self.server = utils.create_git_server(host_type=server_type)
        self.build_user = utils.create_user_with_token(name="moosebuild",
                                                       server=self.server)
        self.owner = utils.create_user(name="owner", server=self.server)
        self.repo = utils.create_repo(name="repo", user=self.owner)
        self.branch = utils.create_branch(name="devel", repo=self.repo)
        pr = utils.create_recipe(name="PR Base",
                                 user=self.build_user,
                                 repo=self.repo)
        pr1 = utils.create_recipe(name="PR With Dep",
                                  user=self.build_user,
                                  repo=self.repo)
        pr1.depends_on.add(pr)
        push = utils.create_recipe(name="Push Base",
                                   user=self.build_user,
                                   repo=self.repo,
                                   branch=self.branch,
                                   cause=models.Recipe.CAUSE_PUSH)
        push1 = utils.create_recipe(name="Push With Dep",
                                    user=self.build_user,
                                    repo=self.repo,
                                    branch=self.branch,
                                    cause=models.Recipe.CAUSE_PUSH)
        push1.depends_on.add(push)
        alt_pr = utils.create_recipe(
            name="Alt PR with dep",
            user=self.build_user,
            repo=self.repo,
            cause=models.Recipe.CAUSE_PULL_REQUEST_ALT)
        alt_pr.depends_on.add(pr)

        utils.create_recipe(name="Manual",
                            user=self.build_user,
                            repo=self.repo,
                            branch=self.branch,
                            cause=models.Recipe.CAUSE_MANUAL)
        self.compare_counts(
            recipes=6,
            deps=3,
            current=6,
            num_push_recipes=2,
            num_pr_recipes=2,
            num_manual_recipes=1,
            num_pr_alt_recipes=1,
            users=2,
            repos=1,
            branches=1,
        )
Exemple #8
0
    def test_view_profile(self):
        # invalid git server
        response = self.client.get(reverse('ci:view_profile', args=[1000, "no_exist"]))
        self.assertEqual(response.status_code, 404)

        # not signed in should redirect to sign in
        server = utils.create_git_server()
        response = self.client.get(reverse('ci:view_profile', args=[server.host_type, server.name]))
        self.assertEqual(response.status_code, 302) # redirect

        user = utils.get_test_user()
        repo1 = utils.create_repo(name='repo1', user=user)
        repo2 = utils.create_repo(name='repo2', user=user)
        repo3 = utils.create_repo(name='repo3', user=user)
        utils.create_recipe(name='r1', user=user, repo=repo1)
        utils.create_recipe(name='r2', user=user, repo=repo2)
        utils.create_recipe(name='r3', user=user, repo=repo3)
        # signed in
        utils.simulate_login(self.client.session, user)
        response = self.client.get(reverse('ci:view_profile', args=[user.server.host_type, user.server.name]))
        self.assertEqual(response.status_code, 200)
Exemple #9
0
 def setUp(self):
     super(Tests, self).setUp()
     self.server = utils.create_git_server()
     self.api = self.server.api()
Exemple #10
0
 def setUp(self):
     self.client = Client()
     self.factory = RequestFactory()
     self.server = utils.create_git_server()
     self.oauth = self.server.auth()
Exemple #11
0
 def setUp(self):
     self.client = Client()
     self.factory = RequestFactory()
     self.server = utils.create_git_server(
         host_type=settings.GITSERVER_BITBUCKET)
 def test_nothing(self):
     utils.create_git_server()
     self.get()
     self.assertEqual(self.selenium.title, "Civet Home")
     self.check_repos()
     self.check_events()