def test_copy_run(self, auditor_record):
        run = copy_run(run=self.run)
        assert auditor_record.call_count == 1
        call_args, call_kwargs = auditor_record.call_args
        assert call_kwargs["event_type"] == run_events.RUN_CREATED
        assert run.user == self.run.user
        assert run.kind == self.run.kind
        assert run.project == self.run.project
        assert run.name == self.run.name
        assert run.description == self.run.description
        assert run.content != self.run.content
        config = CompiledOperationSpecification.read(run.content)
        original_config = CompiledOperationSpecification.read(self.run.content)
        assert len(config.run.init
                   or []) == len(original_config.run.init or []) + 1
        assert run.raw_content == self.run.raw_content
        assert run.readme == self.run.readme
        assert run.tags == self.run.tags
        assert run.cloning_kind == V1CloningKind.COPY
        assert run.original == self.run
        assert run.inputs == {"image": "foo/bar"}

        run = copy_run(
            run=self.run,
            user_id=self.user2.id,
            name="new-name",
            description="new-description",
            content={"trigger": "all_done"},
            readme="new-readme",
            tags=["tag1", "tag2"],
        )
        assert run.user != self.run.user
        assert run.user == self.user2
        assert run.project == self.project
        assert run.name == "new-name"
        assert run.description == "new-description"
        assert run.content != self.run.content
        assert run.raw_content == self.run.raw_content
        assert run.readme == "new-readme"
        assert set(run.tags) == {"tag1", "tag2"}
        assert run.inputs == {"image": "foo/bar"}
        assert run.cloning_kind == V1CloningKind.COPY
        assert run.original == self.run
Beispiel #2
0
 def clone(self, obj, content, **kwargs):
     return copy_run(
         run=obj,
         user_id=self.request.user.id,
         content=content,
         name=kwargs.get("name"),
         description=kwargs.get("description"),
         tags=kwargs.get("tags"),
         meta_info=kwargs.get("meta_info"),
     )
Beispiel #3
0
 def clone(self, obj, content):
     return copy_run(run=obj, user_id=self.request.user.id, content=content)
    def test_copy_run(self, auditor_record):
        run = copy_run(run=self.run)
        assert auditor_record.call_count == 1
        call_args, call_kwargs = auditor_record.call_args
        assert call_kwargs["event_type"] == run_events.RUN_CREATED
        assert run.user == self.run.user
        assert run.kind == self.run.kind
        assert run.project == self.run.project
        assert run.name == self.run.name
        assert run.description == self.run.description
        assert run.content == self.run.content
        assert run.meta_info == {META_COPY_ARTIFACTS: {"dirs": [self.run.uuid.hex]}}
        config = CompiledOperationSpecification.read(run.content)
        original_config = CompiledOperationSpecification.read(self.run.content)
        assert len(config.run.init or []) == len(original_config.run.init or [])
        assert run.raw_content == self.run.raw_content
        assert run.readme == self.run.readme
        assert run.tags == self.run.tags
        assert run.cloning_kind == V1CloningKind.COPY
        assert run.original == self.run
        assert run.inputs == {"image": "foo/bar"}

        run = copy_run(
            run=self.run,
            user_id=self.user2.id,
            name="new-name",
            description="new-description",
            content={"trigger": "all_done"},
            readme="new-readme",
            tags=["tag1", "tag2"],
        )
        assert run.user != self.run.user
        assert run.user == self.user2
        assert run.project == self.project
        assert run.name == "new-name"
        assert run.description == "new-description"
        assert run.content != self.run.content
        assert run.raw_content == self.run.raw_content
        assert run.meta_info == {META_COPY_ARTIFACTS: {"dirs": [self.run.uuid.hex]}}
        assert run.readme == "new-readme"
        assert set(run.tags) == {"tag1", "tag2"}
        assert run.inputs == {"image": "foo/bar"}
        assert run.cloning_kind == V1CloningKind.COPY
        assert run.original == self.run

        # Copy with uploads
        self.run.meta_info[META_UPLOAD_ARTIFACTS] = "foo"
        self.run.save()
        run = copy_run(
            run=self.run,
            user_id=self.user2.id,
            name="new-name",
            description="new-description",
            content={"trigger": "all_done"},
            readme="new-readme",
            tags=["tag1", "tag2"],
        )
        assert run.user != self.run.user
        assert run.user == self.user2
        assert run.project == self.project
        assert run.name == "new-name"
        assert run.description == "new-description"
        assert run.content != self.run.content
        assert run.raw_content == self.run.raw_content
        assert run.meta_info == {
            META_UPLOAD_ARTIFACTS: "foo",
            META_COPY_ARTIFACTS: {"dirs": [self.run.uuid.hex]},
        }
        assert run.readme == "new-readme"
        assert set(run.tags) == {"tag1", "tag2"}
        assert run.inputs == {"image": "foo/bar"}
        assert run.cloning_kind == V1CloningKind.COPY
        assert run.original == self.run

        # Copy with uploads and specific fields
        self.run.meta_info[META_UPLOAD_ARTIFACTS] = "foo"
        self.run.save()
        run = copy_run(
            run=self.run,
            user_id=self.user2.id,
            name="new-name",
            description="new-description",
            content={"trigger": "all_done"},
            readme="new-readme",
            tags=["tag1", "tag2"],
            meta_info={
                META_COPY_ARTIFACTS: {
                    "dirs": ["{}/resources".format(self.run.uuid.hex)]
                }
            },
        )
        assert run.user != self.run.user
        assert run.user == self.user2
        assert run.project == self.project
        assert run.name == "new-name"
        assert run.description == "new-description"
        assert run.content != self.run.content
        assert run.raw_content == self.run.raw_content
        assert run.meta_info == {
            META_UPLOAD_ARTIFACTS: "foo",
            META_COPY_ARTIFACTS: {"dirs": ["{}/resources".format(self.run.uuid.hex)]},
        }
        assert run.readme == "new-readme"
        assert set(run.tags) == {"tag1", "tag2"}
        assert run.inputs == {"image": "foo/bar"}
        assert run.cloning_kind == V1CloningKind.COPY
        assert run.original == self.run