Exemplo n.º 1
0
    def test_restart_run(self, auditor_record):
        run = restart_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.kind == self.run.kind
        assert run.user == self.run.user
        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.readme == self.run.readme
        assert run.tags == self.run.tags
        assert run.cloning_kind == V1CloningKind.RESTART
        assert run.original == self.run

        run = restart_run(
            run=self.run,
            user_id=self.user.id,
            name="new-name",
            description="new-description",
            content={"trigger": "all_done"},
            readme="new-readme",
        )
        assert run.user == self.user
        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.cloning_kind == V1CloningKind.RESTART
        assert run.original == self.run
Exemplo n.º 2
0
 def clone(self, obj, content, **kwargs):
     return restart_run(
         run=obj,
         user_id=self.request.user.id,
         content=content,
         name=kwargs.get("name"),
         description=kwargs.get("description"),
         tags=kwargs.get("tags"),
     )
Exemplo n.º 3
0
 def clone(self, obj, content):
     return restart_run(run=obj,
                        user_id=self.request.user.id,
                        content=content)
Exemplo n.º 4
0
    def test_restart_run(self, auditor_record):
        run = restart_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.kind == self.run.kind
        assert run.user == self.run.user
        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 == {}
        assert run.readme == self.run.readme
        assert run.tags == self.run.tags
        assert run.cloning_kind == V1CloningKind.RESTART
        assert run.original == self.run

        run = restart_run(
            run=self.run,
            user_id=self.user.id,
            name="new-name",
            description="new-description",
            content={"trigger": "all_done"},
            readme="new-readme",
        )
        assert run.user == self.user
        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.cloning_kind == V1CloningKind.RESTART
        assert run.original == self.run
        assert run.meta_info == {}

        # Restart with upload
        self.run.meta_info[META_UPLOAD_ARTIFACTS] = "foo"
        self.run.save()
        run = restart_run(
            run=self.run,
            user_id=self.user.id,
            name="new-name",
            description="new-description",
            content={"trigger": "all_done"},
            readme="new-readme",
        )
        assert run.user == self.user
        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.cloning_kind == V1CloningKind.RESTART
        assert run.original == self.run
        assert run.meta_info == {
            META_UPLOAD_ARTIFACTS: "foo",
            META_COPY_ARTIFACTS: {"dirs": ["{}/foo".format(self.run.uuid.hex)]},
        }