Exemple #1
0
    def test_work(self):
        mocked_peasant = MagicMock()
        mocked_fetch = MagicMock(side_effect=ValueError)
        mocked_fetch_event = MagicMock()

        with patch.multiple('gitfs.worker.fetch', Peasant=mocked_peasant,
                            fetch=mocked_fetch_event):
            worker = FetchWorker()
            worker.fetch = mocked_fetch
            worker.timeout = 5

            with pytest.raises(ValueError):
                worker.work()

            assert mocked_fetch.call_count == 1
            mocked_fetch_event.wait.assert_called_once_with(5)
Exemple #2
0
    def test_work(self):
        mocked_peasant = MagicMock()
        mocked_fetch = MagicMock(side_effect=ValueError)
        mocked_fetch_event = MagicMock()

        with patch.multiple('gitfs.worker.fetch', Peasant=mocked_peasant,
                            fetch=mocked_fetch_event):
            worker = FetchWorker()
            worker.fetch = mocked_fetch
            worker.timeout = 5

            with pytest.raises(ValueError):
                worker.work()

            assert mocked_fetch.call_count == 1
            mocked_fetch_event.wait.assert_called_once_with(5)
Exemple #3
0
    def test_fetch_in_idle_mode(self):
        mocked_peasant = MagicMock()
        mocked_fetch = MagicMock(side_effect=ValueError)
        mocked_fetch_event = MagicMock()
        mocked_idle = MagicMock()

        mocked_idle.is_set.return_value = True

        with patch.multiple('gitfs.worker.fetch', Peasant=mocked_peasant,
                            fetch=mocked_fetch_event, idle=mocked_idle):
            worker = FetchWorker()
            worker.fetch = mocked_fetch
            worker.timeout = 5
            worker.idle_timeout = 20

            with pytest.raises(ValueError):
                worker.work()

            assert mocked_fetch.call_count == 1
            mocked_fetch_event.wait.assert_called_once_with(20)
Exemple #4
0
    def test_fetch_in_idle_mode(self):
        mocked_peasant = MagicMock()
        mocked_fetch = MagicMock(side_effect=ValueError)
        mocked_fetch_event = MagicMock()
        mocked_idle = MagicMock()

        mocked_idle.is_set.return_value = True

        with patch.multiple('gitfs.worker.fetch',
                            Peasant=mocked_peasant,
                            fetch=mocked_fetch_event,
                            idle=mocked_idle):
            worker = FetchWorker()
            worker.fetch = mocked_fetch
            worker.timeout = 5
            worker.idle_timeout = 20

            with pytest.raises(ValueError):
                worker.work()

            assert mocked_fetch.call_count == 1
            mocked_fetch_event.wait.assert_called_once_with(20)