예제 #1
0
    def test_simple(self, get_implementation):
        implementation = mock.Mock()
        get_implementation.return_value = implementation

        sync_artifact(artifact_id=self.artifact.id.hex)

        implementation.fetch_artifact.assert_called_once_with(
            artifact=self.artifact, )
    def test_file_doesnt_exist(self, get_implementation):
        implementation = mock.Mock()
        get_implementation.return_value = implementation

        with mock.patch.object(sync_artifact, 'allow_absent_from_db', True):
            sync_artifact(artifact_id=self.artifact.id.hex)

        implementation.fetch_artifact.assert_called_once_with(
            artifact=self.artifact, )
예제 #3
0
    def test_simple(self, get_implementation):
        implementation = mock.Mock()
        get_implementation.return_value = implementation

        sync_artifact(artifact_id=self.artifact.id.hex)

        implementation.fetch_artifact.assert_called_once_with(
            artifact=self.artifact,
        )
예제 #4
0
    def test_file_doesnt_exist(self, get_implementation):
        implementation = mock.Mock()
        get_implementation.return_value = implementation

        with mock.patch.object(sync_artifact, 'allow_absent_from_db', True):
            sync_artifact(artifact_id=self.artifact.id.hex)

        implementation.fetch_artifact.assert_called_once_with(
            artifact=self.artifact,
        )
예제 #5
0
    def test_legacy(self, get_implementation):
        implementation = mock.Mock()
        get_implementation.return_value = implementation

        sync_artifact(step_id=self.jobstep.id.hex, artifact=self.artifact.data)

        implementation.fetch_artifact.assert_called_once_with(
            step=self.jobstep,
            artifact=self.artifact.data,
        )
예제 #6
0
    def test_file_exists(self, get_implementation):
        implementation = mock.Mock()
        get_implementation.return_value = implementation
        manager = mock.Mock()
        implementation.get_artifact_manager.return_value = manager

        self.artifact.file.save(StringIO(), 'foo')
        db.session.add(self.artifact)
        db.session.commit()

        with mock.patch.object(sync_artifact, 'allow_absent_from_db', True):
            sync_artifact(artifact_id=self.artifact.id.hex)

        implementation.get_artifact_manager.assert_called_once_with(self.jobstep)
        manager.process.assert_called_once_with(self.artifact)
    def test_file_exists(self, get_implementation):
        implementation = mock.Mock()
        get_implementation.return_value = implementation
        manager = mock.Mock()
        implementation.get_artifact_manager.return_value = manager

        self.artifact.file.save(StringIO(), 'foo')
        db.session.add(self.artifact)
        db.session.commit()

        with mock.patch.object(sync_artifact, 'allow_absent_from_db', True):
            sync_artifact(artifact_id=self.artifact.id.hex)

        implementation.get_artifact_manager.assert_called_once_with(
            self.jobstep)
        manager.process.assert_called_once_with(self.artifact)