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
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()
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
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")
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
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()
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
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