Skip to content

Commit

Permalink
add test for submitting jobs to print spooler
Browse files Browse the repository at this point in the history
  • Loading branch information
bwhmather committed Dec 20, 2014
1 parent 579a311 commit c2b8844
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions linemode/tests/test_spooler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,43 @@ class DummyPrinter(Printer):
pass
spooler = PrintSpooler(DummyPrinter())
spooler.shutdown()

def test_submit_job(self):
testcase = self
dummy_commands = object()
compiled = False

dummy_program = object()
executed = False

class DummyPrinter(Printer):
def compile(self, commands):
nonlocal testcase
nonlocal dummy_commands
nonlocal compiled
nonlocal dummy_program

testcase.assertIs(commands, dummy_commands)
testcase.assertFalse(compiled)

compiled = True

return dummy_program

def execute(self, program):
nonlocal testcase
nonlocal dummy_program
nonlocal executed

testcase.assertIs(program, dummy_program)
testcase.assertFalse(executed)

executed = True

spooler = PrintSpooler(DummyPrinter())
spooler.submit(dummy_commands)

spooler.shutdown()

self.assertTrue(compiled)
self.assertTrue(executed)

0 comments on commit c2b8844

Please sign in to comment.