Пример #1
0
    def test_hash_task_terminates(self):
        """ Ensure furtive.hasher.hash_task terminates when terminating is set """

        terminating = MagicMock()
        terminating.is_set.return_value = True
        initializer(terminating)

        result = hash_task('tests/fixtures/test-data/documents/Important Document 1.odt')
        self.assertEqual(result, None, msg=result)
Пример #2
0
    def test_hash_task(self):
        """ Ensure furtive.hasher.hash_task works as expected """

        terminating = MagicMock()
        terminating.is_set.return_value = False
        initializer(terminating)

        result = hash_task('tests/fixtures/test-data/documents/Important Document 1.odt')
        self.assertEqual(result['tests/fixtures/test-data/documents/Important Document 1.odt'], 'd460a36805fb460c038d96723f206b20', msg=result)
Пример #3
0
    def test_hash_task_keyboard_interupt(self):
        """ Ensure furtive.hasher.hash_task sets terminating to true during KeyboardInterrupt """

        terminating = MagicMock(spec=multiprocessing.Event())
        terminating.is_set.side_effect = KeyboardInterrupt
        initializer(terminating)

        result = hash_task('tests/fixtures/test-data/documents/Important Document 1.odt')

        self.assertEqual(result, None)
        terminating.set.assert_called_once_with()