本文整理汇总了Python中jenkins.tests.factories.BuildFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python BuildFactory.create方法的具体用法?Python BuildFactory.create怎么用?Python BuildFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jenkins.tests.factories.BuildFactory
的用法示例。
在下文中一共展示了BuildFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_auto_track_dependency_triggers_project_build_creation
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_auto_track_dependency_triggers_project_build_creation(self):
"""
If we record a build of a project dependency that is auto-tracked,
then this should trigger the creation of a new ProjectBuild for that
project.
"""
dependency1 = DependencyFactory.create()
ProjectDependency.objects.create(project=self.project, dependency=dependency1)
dependency2 = DependencyFactory.create()
existing_build = BuildFactory.create(job=dependency2.job, phase="FINISHED")
ProjectDependency.objects.create(project=self.project, dependency=dependency2, current_build=existing_build)
self.assertEqual(0, ProjectBuild.objects.filter(project=self.project).count())
build = BuildFactory.create(job=dependency1.job, phase="FINISHED")
process_build_dependencies(build.pk)
self.assertEqual(1, ProjectBuild.objects.filter(project=self.project).count())
projectbuild = ProjectBuild.objects.get(project=self.project)
self.assertEqual(2, ProjectBuildDependency.objects.filter(projectbuild=projectbuild).count())
build_dependency1 = ProjectBuildDependency.objects.get(projectbuild=projectbuild, dependency=dependency1)
self.assertEqual(build, build_dependency1.build)
build_dependency2 = ProjectBuildDependency.objects.get(projectbuild=projectbuild, dependency=dependency2)
self.assertEqual(existing_build, build_dependency2.build)
示例2: test_project_build_detail_view
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_project_build_detail_view(self):
"""
Project build detail should show the build.
"""
dependency = DependencyFactory.create()
ProjectDependency.objects.create(
project=self.project, dependency=dependency)
projectbuild = build_project(self.project, queue_build=False)
BuildFactory.create(
job=dependency.job, build_id=projectbuild.build_key)
url = reverse(
"project_projectbuild_detail",
kwargs={"project_pk": self.project.pk,
"build_pk": projectbuild.pk})
response = self.app.get(url, user="testing")
dependencies = ProjectBuildDependency.objects.filter(
projectbuild=projectbuild)
self.assertEqual(projectbuild, response.context["projectbuild"])
self.assertEqual(
list(dependencies), list(response.context["dependencies"]))
self.assertTrue(
"archived_items" not in response.context,
"Project Build has archive items.")
示例3: test_archive_build_projectbuild
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_archive_build_projectbuild(self):
"""
The archiver can handle archiving a build from a projectbuild.
"""
project, dependency1, dependency2 = self.create_dependencies(2)
ProjectDependency.objects.create(
project=project, dependency=dependency2)
projectbuild = build_project(project, queue_build=False)
archive = ArchiveFactory.create(policy="cdimage")
build1 = BuildFactory.create(
job=dependency1.job, build_id=projectbuild.build_key)
artifact1 = ArtifactFactory.create(
build=build1, filename="artifact1.gz")
update_projectbuilds(build1)
build1_items = archive.add_build(build1)
self.assertEqual(2, len(build1_items[artifact1]))
build2 = BuildFactory.create(
job=dependency2.job, build_id=projectbuild.build_key)
artifact2 = ArtifactFactory.create(build=build2, filename="artifact2.gz")
update_projectbuilds(build2)
build2_items = archive.add_build(build2)
self.assertEqual(2, len(build2_items[artifact2]))
self.assertEqual(4, archive.items.count())
self.assertEqual(
2,
ArchiveArtifact.objects.filter(
projectbuild_dependency__projectbuild=projectbuild).count())
示例4: test_build_project_automated_autotracked_dependencies
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_build_project_automated_autotracked_dependencies(self):
"""
For autotracked dependencies, we should use the most recent
projectbuild to find the builds for associating with the new
projectbuild.
"""
project = ProjectFactory.create()
dependency1 = DependencyFactory.create()
project_dep1 = ProjectDependency.objects.create(
project=project, dependency=dependency1,
current_build=BuildFactory.create())
dependency2 = DependencyFactory.create()
project_dep2 = ProjectDependency.objects.create(
project=project, dependency=dependency2,
current_build=BuildFactory.create())
build1 = build_project(project, automated=True)
# We store the current built dependency for dependency2 because we're
# going to build dependency1.
built_dependency1 = ProjectBuildDependency.objects.get(
projectbuild=build1, dependency=dependency2)
build2 = build_project(project, dependencies=[dependency1], automated=True)
built_dependency2 = ProjectBuildDependency.objects.get(
projectbuild=build2, dependency=dependency2)
self.assertEqual(built_dependency2.build, built_dependency1.build)
示例5: test_archive_projectbuild_with_prearchived_artifact
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_archive_projectbuild_with_prearchived_artifact(self):
"""
If we archive a project build with several artifacts, it should return
only the newly added artifacts.
"""
project = ProjectFactory.create()
dependency1 = DependencyFactory.create()
ProjectDependency.objects.create(
project=project, dependency=dependency1)
dependency2 = DependencyFactory.create()
ProjectDependency.objects.create(
project=project, dependency=dependency2)
projectbuild = build_project(project, queue_build=False)
build1 = BuildFactory.create(
job=dependency1.job, build_id=projectbuild.build_key)
build2 = BuildFactory.create(
job=dependency2.job, build_id=projectbuild.build_key)
ArtifactFactory.create(build=build1, filename="artifact1.gz")
artifact = ArtifactFactory.create(
build=build2, filename="artifact2.gz")
archive = ArchiveFactory.create()
archive.add_artifact(artifact, projectbuild=projectbuild)
result = archive.archive_projectbuild(projectbuild)
self.assertEqual(2, archive.items.count())
self.assertEqual(1, len(result))
示例6: test_build_project_automated_non_autotracked
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_build_project_automated_non_autotracked(self):
"""
For automated, non-autotracked builds, each of the projectbuild
dependencies created should use the current build of the dependency.
"""
project = ProjectFactory.create()
dependency1 = DependencyFactory.create()
project_dep1 = ProjectDependency.objects.create(
project=project, dependency=dependency1,
current_build=BuildFactory.create())
dependency2 = DependencyFactory.create()
project_dep2 = ProjectDependency.objects.create(
project=project, dependency=dependency2,
current_build=BuildFactory.create())
new_build = build_project(project, automated=True)
build_dependencies = ProjectBuildDependency.objects.filter(
projectbuild=new_build)
self.assertEqual(2, build_dependencies.count())
self.assertEqual(
[dependency1, dependency2],
[x.dependency for x in build_dependencies])
self.assertEqual(
[project_dep1.current_build, project_dep2.current_build],
[x.build for x in build_dependencies])
示例7: test_archive_projectbuild
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_archive_projectbuild(self):
"""
The archiver can handle archiving an entire project build.
"""
project = ProjectFactory.create()
dependency1 = DependencyFactory.create()
ProjectDependency.objects.create(
project=project, dependency=dependency1)
dependency2 = DependencyFactory.create()
ProjectDependency.objects.create(
project=project, dependency=dependency2)
projectbuild = build_project(project, queue_build=False)
build1 = BuildFactory.create(
job=dependency1.job, build_id=projectbuild.build_key)
build2 = BuildFactory.create(
job=dependency2.job, build_id=projectbuild.build_key)
ArtifactFactory.create(build=build1, filename="artifact1.gz")
ArtifactFactory.create(build=build2, filename="artifact2.gz")
archive = ArchiveFactory.create()
result = archive.archive_projectbuild(projectbuild)
self.assertEqual(2, archive.items.count())
self.assertEqual(2, len(result))
示例8: test_project_build_sends_finished_signal
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_project_build_sends_finished_signal(self):
"""
When we set the projectbuild status to finished, we should signal this.
"""
@receiver(projectbuild_finished, sender=ProjectBuild)
def handle_signal(sender, projectbuild, **kwargs):
self.projectbuild = projectbuild
project = ProjectFactory.create()
dependency1 = DependencyFactory.create()
ProjectDependency.objects.create(
project=project, dependency=dependency1)
dependency2 = DependencyFactory.create()
ProjectDependency.objects.create(
project=project, dependency=dependency2)
from projects.helpers import build_project
projectbuild = build_project(project, queue_build=False)
for job in [dependency1.job, dependency2.job]:
BuildFactory.create(
job=job, build_id=projectbuild.build_id, phase="FINISHED")
self.assertEqual(projectbuild, self.projectbuild)
示例9: test_project_build_status_when_all_dependencies_have_builds
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_project_build_status_when_all_dependencies_have_builds(self):
"""
When we have FINISHED builds for all the dependencies, the projectbuild
state should be FINISHED.
"""
project = ProjectFactory.create()
dependency1 = DependencyFactory.create()
ProjectDependency.objects.create(
project=project, dependency=dependency1)
dependency2 = DependencyFactory.create()
ProjectDependency.objects.create(
project=project, dependency=dependency2)
from projects.helpers import build_project
projectbuild = build_project(project, queue_build=False)
for job in [dependency1.job, dependency2.job]:
BuildFactory.create(
job=job, build_id=projectbuild.build_id, phase="FINISHED")
projectbuild = ProjectBuild.objects.get(pk=projectbuild.pk)
self.assertEqual("SUCCESS", projectbuild.status)
self.assertEqual("FINISHED", projectbuild.phase)
self.assertIsNotNone(projectbuild.ended_at)
示例10: test_get_current_build
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_get_current_build(self):
"""
Dependency.get_current_build should return the most recent build that
has completed and was SUCCESSful.
"""
build1 = BuildFactory.create()
build2 = BuildFactory.create(
phase=Build.FINALIZED, status="SUCCESS", job=build1.job)
dependency = DependencyFactory.create(job=build1.job)
self.assertEqual(build2, dependency.get_current_build())
示例11: test_is_dependency_building
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_is_dependency_building(self):
"""
is_building should return True if we have an active build for
this dependency in the works.
"""
dependency = DependencyFactory.create()
self.assertFalse(dependency.is_building)
BuildFactory.create(job=dependency.job)
self.assertTrue(dependency.is_building)
示例12: test_dependency_detail_with_currently_building
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_dependency_detail_with_currently_building(self):
"""
If the Dependency is currently building, we should get an info message
with this in the page.
"""
dependency = DependencyFactory.create()
BuildFactory.create(job=dependency.job, status="STARTED")
url = reverse("dependency_detail", kwargs={"pk": dependency.pk})
response = self.app.get(url, user="testing")
self.assertContains(response, "Dependency currently building")
示例13: test_build_dependency_already_building
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_build_dependency_already_building(self):
"""
If the Dependency appears to be already building, then we should
"""
self.client.force_authenticate(user=self.user)
dependency = DependencyFactory.create()
BuildFactory.create(job=dependency.job)
url = reverse("dependency-build-dependency", kwargs={"pk": dependency.pk})
with mock.patch("projects.helpers.build_job") as build_job_mock:
response = self.client.post(url)
self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code)
self.assertFalse(build_job_mock.delay.called)
示例14: test_generate_checksums
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_generate_checksums(self):
"""
generate_checksums should send commands to the ssh client
to generate an sha256sum for the passed in archived artifact.
"""
# a project with a build and an archived artifact
project = ProjectFactory.create()
dependency = DependencyFactory.create()
ProjectDependency.objects.create(
project=project, dependency=dependency)
projectbuild = build_project(project, queue_build=False)
build = BuildFactory.create(
job=dependency.job, build_id=projectbuild.build_key)
projectbuild_dependency = ProjectBuildDependency.objects.create(
build=build, projectbuild=projectbuild, dependency=dependency)
artifact = ArtifactFactory.create(
build=build, filename="artifact_filename")
archived_artifact = ArchiveArtifact.objects.create(
build=build, archive=self.archive, artifact=artifact,
archived_path="/srv/builds/200101.01/artifact_filename",
projectbuild_dependency=projectbuild_dependency)
transport = SshTransport(self.archive)
with mock.patch.object(transport, "_run_command") as mock_run:
transport.generate_checksums(archived_artifact)
mock_run.assert_called_once_with(
"cd `dirname /var/tmp/srv/builds/200101.01/artifact_filename` "
"&& sha256sum artifact_filename >> SHA256SUMS")
示例15: test_get_build_table_with_current_build_outside_recent
# 需要导入模块: from jenkins.tests.factories import BuildFactory [as 别名]
# 或者: from jenkins.tests.factories.BuildFactory import create [as 别名]
def test_get_build_table_with_current_build_outside_recent(self):
"""
If we have a current build outside the most recent 5, then we should
extend the dependencies list for that row to illustrate the current
build.
"""
project = ProjectFactory.create()
dependency = DependencyFactory.create()
build = BuildFactory.create(job=dependency.job)
[build1, build2, build3, build4, build5] = BuildFactory.create_batch(
5, job=dependency.job)
ProjectDependency.objects.create(
project=project, dependency=dependency, auto_track=False,
current_build=build)
header, table = get_build_table_for_project(project)
self.assertEqual([dependency], header)
self.assertEqual([
[{"build": build5, "current": False}],
[{"build": build4, "current": False}],
[{"build": build3, "current": False}],
[{"build": build2, "current": False}],
[{"build": build1, "current": False}],
[{"build": build, "current": True}]], table)