1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
import pytest
from unittest.mock import patch, MagicMock
from UM.Job import Job
def test_getSetError():
job = Job()
exception = Exception("Some Error :(")
job.setError(exception)
assert job.getError() == exception
assert job.hasError()
def test_getSetResult():
job = Job()
job.setResult("blarg")
assert job.getResult() == "blarg"
def test_run():
job = Job()
with pytest.raises(NotImplementedError):
job.run()
def test_start():
job = Job()
job_queue = MagicMock()
with patch("UM.JobQueue.JobQueue.getInstance", MagicMock(return_value = job_queue)):
job.start()
job_queue.add.called_once_with(job)
def test_cancel():
job = Job()
job_queue = MagicMock()
with patch("UM.JobQueue.JobQueue.getInstance", MagicMock(return_value=job_queue)):
job.cancel()
job_queue.remove.called_once_with(job)
def test_isRunning():
job = Job()
assert not job.isRunning()
|