示例#1
0
    def test_start_stop(self):
        device = 'device 1234'
        preset = 'preset9'

        daemon = Daemon()

        start_history = []
        stop_history = []
        stop_all_history = []
        daemon.start_injecting = lambda *args: start_history.append(args)
        daemon.stop_injecting = lambda *args: stop_history.append(args)
        daemon.stop_all = lambda *args: stop_all_history.append(args)

        control(options('start', None, preset, device, False, False, False),
                daemon)
        self.assertEqual(len(start_history), 1)
        self.assertEqual(start_history[0], (device, preset))

        control(options('stop', None, None, device, False, False, False),
                daemon)
        self.assertEqual(len(stop_history), 1)
        self.assertEqual(stop_history[0], (device, ))

        control(options('stop-all', None, None, None, False, False, False),
                daemon)
        self.assertEqual(len(stop_all_history), 1)
        self.assertEqual(stop_all_history[0], ())
示例#2
0
    def test_start_stop(self):
        group = groups.find(key='Foo Device 2')
        preset = 'preset9'

        daemon = Daemon()

        start_history = []
        stop_history = []
        stop_all_history = []
        daemon.start_injecting = lambda *args: start_history.append(args)
        daemon.stop_injecting = lambda *args: stop_history.append(args)
        daemon.stop_all = lambda *args: stop_all_history.append(args)

        communicate(
            options('start', None, preset, group.paths[0], False, False,
                    False), daemon)
        self.assertEqual(len(start_history), 1)
        self.assertEqual(start_history[0], (group.key, preset))

        communicate(
            options('stop', None, None, group.paths[1], False, False, False),
            daemon)
        self.assertEqual(len(stop_history), 1)
        # provided any of the groups paths as --device argument, figures out
        # the correct group.key to use here
        self.assertEqual(stop_history[0], (group.key, ))

        communicate(options('stop-all', None, None, None, False, False, False),
                    daemon)
        self.assertEqual(len(stop_all_history), 1)
        self.assertEqual(stop_all_history[0], ())