コード例 #1
0
ファイル: test_fetch.py プロジェクト: HWL-RobAt/gitfs
    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)
コード例 #2
0
ファイル: test_fetch.py プロジェクト: calind/gitfs
    def test_fetch_remote_is_down(self):
        mocked_fetch_ok = MagicMock()
        mocked_fetch = MagicMock()
        mocked_repo = MagicMock()

        mocked_repo.fetch = MagicMock(side_effect=ValueError)
        mocked_fetch_ok.set.side_effect = ValueError

        with patch.multiple('gitfs.worker.fetch',
                            fetch_successful=mocked_fetch_ok,
                            fetch=mocked_fetch):
            worker = FetchWorker(repository=mocked_repo,
                                 upstream="origin",
                                 branch="master")
            worker.fetch()

            mocked_repo.fetch.assert_called_once_with("origin", "master")
            assert mocked_fetch_ok.clear.call_count == 1
            assert mocked_fetch.clear.call_count == 1
コード例 #3
0
ファイル: test_fetch.py プロジェクト: wlchou/gitfs
    def test_fetch_remote_is_down(self):
        mocked_fetch_ok = MagicMock()
        mocked_fetch = MagicMock()
        mocked_repo = MagicMock()

        mocked_repo.fetch = MagicMock(side_effect=ValueError)
        mocked_fetch_ok.set.side_effect = ValueError

        with patch.multiple('gitfs.worker.fetch',
                            fetch_successful=mocked_fetch_ok,
                            fetch=mocked_fetch):
            worker = FetchWorker(repository=mocked_repo,
                                 upstream="origin",
                                 branch="master")
            worker.fetch()

            mocked_repo.fetch.assert_called_once_with("origin", "master")
            assert mocked_fetch_ok.clear.call_count == 1
            assert mocked_fetch.clear.call_count == 1
コード例 #4
0
ファイル: test_fetch.py プロジェクト: shaded-enmity/gitfs
    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)
コード例 #5
0
ファイル: test_fetch.py プロジェクト: zaoqi-clone/gitfs
    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)
コード例 #6
0
ファイル: test_fetch.py プロジェクト: HWL-RobAt/gitfs
    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)