def test_get_path_for_artifact(self): """ The default archive policy should return the path from the artifact url. """ artifact = ArtifactFactory.create(filename="testing.img") policy = DefaultPolicy() self.assertEqual( "testing.img", policy.get_path_for_artifact(artifact))
def test_get_path_for_artifact(self): """ The default archive policy should return the path from the artifact url. """ dependency = DependencyFactory.create(name="My Dependency") build = BuildFactory.create(job=dependency.job) artifact = ArtifactFactory.create(filename="testing.img", build=build) policy = DefaultPolicy() timestamp = "%s-%s" % (build.created_at.strftime("%Y-%m-%d"), time.mktime(build.created_at.timetuple())) self.assertEqual( "my-dependency/%s/testing.img" % timestamp, policy.get_path_for_artifact(artifact, dependency=dependency, build=build))
def test_get_path_for_artifact(self): """ The default archive policy should return the path from the artifact url. """ dependency = DependencyFactory.create(name="My Dependency") build = BuildFactory.create(job=dependency.job) artifact = ArtifactFactory.create( filename="testing.img", build=build) policy = DefaultPolicy() timestamp = "%s-%s" % ( build.created_at.strftime("%Y-%m-%d"), time.mktime(build.created_at.timetuple())) self.assertEqual( "my-dependency/%s/testing.img" % timestamp, policy.get_path_for_artifact( artifact, dependency=dependency, build=build))
def test_cdimage_archiver_policy_with_only_dependency_build(self): """ If we only build a dependency with no project builds, then the cdimage archiver should delegate to the default policy for the name when generating the archive name for the dependency's artifacts. """ dependency = DependencyFactory.create() build = BuildFactory.create(job=dependency.job) artifact = ArtifactFactory.create(build=build, filename="testing.gz") update_projectbuilds(build) archive = ArchiveFactory.create(policy="cdimage") archive.add_build(build) archived = archive.get_archived_artifacts_for_build(build).order_by( "archived_path") name = DefaultPolicy().get_path_for_artifact(artifact, build=build, dependency=dependency) self.assertEqual( name, "\n".join(archived.values_list("archived_path", flat=True))) self.assertEqual([None], list(archived.values_list("archived_at", flat=True)))