예제 #1
0
def planrepos(db):
    repo = RepositoryFactory()
    plan1 = PlanFactory(role="scratch")
    plan2 = PlanFactory(role="qa")
    planrepo1 = PlanRepositoryFactory(repo=repo, plan=plan1)
    planrepo2 = PlanRepositoryFactory(repo=repo, plan=plan2)
    return planrepo1, planrepo2
예제 #2
0
 def setUpTestData(cls):
     cls.client = Client()
     cls.superuser = StaffSuperuserFactory()
     cls.user = UserFactory()
     cls.repo = RepositoryFactory()
     cls.plan1 = PlanFactory()
     cls.plan1.role = "scratch"
     cls.plan1.save()
     cls.plan2 = PlanFactory()
     cls.plan2.role = "qa"
     cls.plan2.save()
     cls.planrepo1 = PlanRepositoryFactory(repo=cls.repo, plan=cls.plan1)
     cls.planrepo2 = PlanRepositoryFactory(repo=cls.repo, plan=cls.plan2)
     super(TestCreateOrgViews, cls).setUpTestData()
예제 #3
0
    def test_planrepo_find_on_build_init(self):
        repo = RepositoryFactory()
        plan = PlanFactory()
        planrepo = PlanRepositoryFactory(plan=plan, repo=repo)

        build = Build(repo=repo, plan=plan)
        assert build.planrepo == planrepo
예제 #4
0
 def setUpClass(cls):
     super().setUpClass()
     p1 = PlanFactory(name="Plan1")
     p2 = PlanFactory(name="Plan2")
     r1 = RepositoryFactory(name="PublicRepo")
     r2 = RepositoryFactory(name="PrivateRepo")
     public_pr = PlanRepositoryFactory(plan=p1, repo=r1)
     assign_perm("plan.view_builds", Group.objects.get(name="Public"),
                 public_pr)
     pr2 = PlanRepositoryFactory(plan=p2, repo=r2)
     BranchFactory(name="Branch1", repo=r1)
     BranchFactory(name="Branch2", repo=r2)
     private_build = BuildFactory(repo=r2, plan=p2, planrepo=pr2)
     private_bff = BuildFlowFactory(build=private_build)
     public_build = BuildFactory(repo=r2, plan=p2, planrepo=pr2)
     public_bff = BuildFlowFactory(build=public_build)
     BuildFlowFactory(flow="Flow2")
     TestResultFactory(build_flow=private_bff, method__name="Private1")
     TestResultFactory(build_flow=private_bff, method__name="Private2")
     TestResultFactory(build_flow=public_bff, method__name="Public1")
     TestResultFactory(build_flow=public_bff, method__name="Public2")
예제 #5
0
 def test_lock_set(self, run, lock_org, scratch_org_limits,
                   reset_database_connection):
     build_timeout = 100
     repo = RepositoryFactory(name="myrepo")
     OrgFactory(name="myorg", repo=repo, scratch=False)
     plan = PlanFactory(name="myplan",
                        org="myorg",
                        build_timeout=build_timeout)
     build = BuildFactory(repo=repo, plan=plan)
     PlanRepositoryFactory(repo=repo, plan=plan)
     check_queued_build(build.id)
     print(lock_org.mock_calls)
     assert lock_org.mock_calls
     assert lock_org.mock_calls[0][1][2] == build_timeout
예제 #6
0
 def setUpTestData(cls):
     cls.client = Client()
     cls.superuser = StaffSuperuserFactory()
     cls.user = UserFactory()
     cls.plan = PlanFactory(name="Plan1")
     cls.plan.dashboard = "last"
     cls.plan.trigger = "tag"
     cls.plan.regex = "beta"
     cls.plan.save()
     cls.repo = RepositoryFactory(name="PublicRepo")
     cls.planrepo = PlanRepositoryFactory(plan=cls.plan, repo=cls.repo)
     cls.branch = BranchFactory(name="test-branch", repo=cls.repo)
     cls.build = BuildFactory(
         branch=cls.branch, repo=cls.repo, plan=cls.plan, planrepo=cls.planrepo
     )
     super(TestRepositoryViews, cls).setUpTestData()
예제 #7
0
    def test_scheduled_build_init(self):
        repo = RepositoryFactory()
        branch = BranchFactory(name="branch", repo=repo)
        schedule = PlanScheduleFactory(branch=branch)
        plan = PlanFactory()

        planrepo = PlanRepositoryFactory(plan=plan, repo=repo)

        build = Build(
            repo=branch.repo,
            plan=plan,
            branch=branch,
            commit="shashasha",
            schedule=schedule,
            build_type="scheduled",
        )
        assert build.planrepo == planrepo
예제 #8
0
    def _testrun_build(self, run_build, scratch_org_limits, org_is_scratch,
                       no_lock):
        repo = RepositoryFactory(name="myrepo")
        branch = BranchFactory(name="mybranch", repo=repo)
        plan = PlanFactory(name="myplan",
                           org="myorg",
                           build_timeout=BUILD_TIMEOUT)
        PlanRepositoryFactory(repo=repo, plan=plan)
        user = UserFactory(username="******")
        org = OrgFactory(name="myorg", repo=repo, scratch=org_is_scratch)
        os.environ["DYNO"] = "worker.42"
        build_pk = None

        def side_effect(build_id):
            nonlocal build_pk
            build_pk = build_id

        run_build.side_effect = side_effect
        scratch_org_limits.return_value = mock.Mock()
        scratch_org_limits.return_value.remaining = settings.SCRATCH_ORG_RESERVE + 5
        c = Command()
        c.handle("myrepo",
                 "mybranch",
                 "commit",
                 "myplan",
                 "username",
                 no_lock=no_lock)
        assert build_pk
        build = Build.objects.get(pk=build_pk)
        assert not build.task_id_check  # wasn't queued
        assert build.build_type == "manual-command"
        assert build.user == user
        assert build.repo == repo
        assert build.branch == branch
        assert build.plan == plan
        assert build.org == org