def test_moving_data(self, files):
        files.old_data.ensure()
        files.old_cache.ensure()

        standarddir._move_webengine_data()

        assert not files.old_data.exists()
        assert not files.old_cache.exists()
        assert files.new_data.exists()
        assert files.new_cache.exists()
Beispiel #2
0
    def test_moving_data(self, files):
        files.old_data.ensure()
        files.old_cache.ensure()

        standarddir._move_webengine_data()

        assert not files.old_data.exists()
        assert not files.old_cache.exists()
        assert files.new_data.exists()
        assert files.new_cache.exists()
Beispiel #3
0
    def test_deleting_error(self, files, monkeypatch, mocker, caplog):
        """When there was an error it should be logged."""
        mock = mocker.Mock(side_effect=OSError('error'))
        monkeypatch.setattr(standarddir.shutil, 'move', mock)
        files.old_data.ensure()
        files.old_cache.ensure()

        with caplog.at_level(logging.ERROR):
            standarddir._move_webengine_data()

        record = caplog.records[-1]
        expected = "Failed to move old QtWebEngine data/cache: error"
        assert record.message == expected
    def test_deleting_error(self, files, monkeypatch, mocker, caplog):
        """When there was an error it should be logged."""
        mock = mocker.Mock(side_effect=OSError('error'))
        monkeypatch.setattr(standarddir.shutil, 'move', mock)
        files.old_data.ensure()
        files.old_cache.ensure()

        with caplog.at_level(logging.ERROR):
            standarddir._move_webengine_data()

        record = caplog.records[-1]
        expected = "Failed to move old QtWebEngine data/cache: error"
        assert record.message == expected
Beispiel #5
0
    def test_already_existing(self, files, caplog, what):
        files.old_data.ensure()
        files.old_cache.ensure()

        if what == 'data':
            files.new_data.ensure()
        else:
            files.new_cache.ensure()

        with caplog.at_level(logging.WARNING):
            standarddir._move_webengine_data()

        record = caplog.records[-1]
        expected = "Failed to move old QtWebEngine {}".format(what)
        assert record.message.startswith(expected)
    def test_already_existing(self, files, caplog, what):
        files.old_data.ensure()
        files.old_cache.ensure()

        if what == 'data':
            files.new_data.ensure()
        else:
            files.new_cache.ensure()

        with caplog.at_level(logging.WARNING):
            standarddir._move_webengine_data()

        record = caplog.records[-1]
        expected = "Failed to move old QtWebEngine {}".format(what)
        assert record.message.startswith(expected)
Beispiel #7
0
    def test_deleting_empty_dirs(self, monkeypatch, tmpdir):
        """When we have a qutebrowser/qutebrowser subfolder, clean it up."""
        old_data = tmpdir / 'data' / 'qutebrowser' / 'qutebrowser'
        old_cache = tmpdir / 'cache' / 'qutebrowser' / 'qutebrowser'
        locations = {
            QStandardPaths.DataLocation: str(old_data),
            QStandardPaths.CacheLocation: str(old_cache),
        }
        monkeypatch.setattr(standarddir.QStandardPaths, 'writableLocation',
                            locations.get)

        old_data_file = old_data / 'QtWebEngine' / 'Default' / 'datafile'
        old_cache_file = old_cache / 'QtWebEngine' / 'Default' / 'cachefile'
        old_data_file.ensure()
        old_cache_file.ensure()

        standarddir._move_webengine_data()

        assert not (tmpdir / 'data' / 'qutebrowser' / 'qutebrowser').exists()
        assert not (tmpdir / 'cache' / 'qutebrowser' / 'qutebrowser').exists()
    def test_deleting_empty_dirs(self, monkeypatch, tmpdir):
        """When we have a qutebrowser/qutebrowser subfolder, clean it up."""
        old_data = tmpdir / 'data' / 'qutebrowser' / 'qutebrowser'
        old_cache = tmpdir / 'cache' / 'qutebrowser' / 'qutebrowser'
        locations = {
            QStandardPaths.DataLocation: str(old_data),
            QStandardPaths.CacheLocation: str(old_cache),
        }
        monkeypatch.setattr(standarddir.QStandardPaths, 'writableLocation',
                            locations.get)

        old_data_file = old_data / 'QtWebEngine' / 'Default' / 'datafile'
        old_cache_file = old_cache / 'QtWebEngine' / 'Default' / 'cachefile'
        old_data_file.ensure()
        old_cache_file.ensure()

        standarddir._move_webengine_data()

        assert not (tmpdir / 'data' / 'qutebrowser' / 'qutebrowser').exists()
        assert not (tmpdir / 'cache' / 'qutebrowser' / 'qutebrowser').exists()
Beispiel #9
0
 def test_no_webengine_dir(self, caplog):
     """Nothing should happen without any QtWebEngine directory."""
     standarddir._move_webengine_data()
     assert not any(
         rec.message.startswith('Moving QtWebEngine')
         for rec in caplog.records)
 def test_no_webengine_dir(self, caplog):
     """Nothing should happen without any QtWebEngine directory."""
     standarddir._move_webengine_data()
     assert not any(rec.message.startswith('Moving QtWebEngine')
                    for rec in caplog.records)