from scoring_engine.engine.execute_command import execute_command
from scoring_engine.engine.job import Job


class TestWorker(object):

    def test_basic_run(self):
        job = Job(environment_id="12345", command="echo 'HELLO'")
        task = execute_command.run(job)
        assert task['errored_out'] is False
        assert task['output'] == 'HELLO\n'

    def test_timed_out(self):
        # this is a weak unit test, but I couldn't figure out
        # how to run the job without a worker and still
        # honor the soft timeout
        assert execute_command.soft_time_limit == 30

@@ -1,28 +1,138 @@
+import mock%0A%0Afrom billiard.exceptions import SoftTimeLimitExceeded%0A%0Afrom scoring_engine.engine.job import Job%0A
 from scoring_engine.engine.e
@@ -173,50 +173,8 @@
 and%0A
-from scoring_engine.engine.job import Job%0A
 %0A%0Acl
@@ -464,150 +464,162 @@
     
-# this is a weak unit test, but I couldn't figure out%0A        # how to run the job without a worker and still%0A        # honor the soft timeout
+import subprocess%0A        subprocess.run = mock.Mock(side_effect=SoftTimeLimitExceeded)%0A%0A        job = Job(environment_id=%2212345%22, command=%22echo 'HELLO'%22)
 %0A   
@@ -623,22 +623,22 @@
         
+t
 as
-sert
+k =
  execute
@@ -650,26 +650,56 @@
 and.
-soft_time_limit == 30
+run(job)%0A        assert task%5B'errored_out'%5D is True
 %0A

Add test for soft time limit reached