Skip to content

Commit

Permalink
Fix ordering of parts
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Aug 11, 2016
1 parent ea2a16a commit 4c22df9
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions tests/test_core/test_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import setup_malcolm_paths

import unittest
from mock import MagicMock, patch
from mock import MagicMock, patch, call
from collections import OrderedDict

from malcolm.core.hook import Hook

Expand Down Expand Up @@ -58,22 +59,18 @@ def test_run_makes_correct_calls(self, task_mock):
self.c.process = process_mock
part1 = DummyPart1()
part2 = DummyPart2()
self.c.parts = dict(part1=part1, part2=part2)
self.c.parts = OrderedDict([("part1", part1), ("part2", part2)])

response = part1.do_thing.Hook.run(self.c)

task_calls = [call[0][0] for call in task_mock.call_args_list]
self.assertEqual(task_calls, ["Configuring.part1", "Configuring.part2"])
task_calls = [call[0][1] for call in task_mock.call_args_list]
self.assertEqual(task_calls, [self.c.process]*2)
spawn_calls = [call[0] for call in spawn_mock.call_args_list]
self.assertEqual(spawn_calls[0],
(Hook._run_func, queue_mock, part1.do_thing,
task_mock.return_value))
self.assertEqual(spawn_calls[1],
(Hook._run_func, queue_mock, part2.do_all_the_things,
task_mock.return_value))

task_mock.assert_has_calls([
call("Configuring.part1", self.c.process),
call("Configuring.part2", self.c.process)])
spawn_mock.assert_has_calls([
call(Hook._run_func, queue_mock, part1.do_thing,
task_mock.return_value),
call(Hook._run_func, queue_mock, part2.do_all_the_things,
task_mock.return_value)])
self.assertEqual(2, queue_mock.get.call_count)

self.assertIsNone(response)
Expand Down

0 comments on commit 4c22df9

Please sign in to comment.