Fix tests after refactoring Common

This commit is contained in:
Micah Lee 2018-03-13 02:22:26 -07:00
parent 50409167d4
commit c2fecf8aa4
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
7 changed files with 73 additions and 79 deletions

View file

@ -26,19 +26,16 @@ import pytest
from onionshare import common, settings, strings
@pytest.fixture
def custom_version(monkeypatch):
monkeypatch.setattr(common, 'version', 'DUMMY_VERSION_1.2.3')
@pytest.fixture
def os_path_expanduser(monkeypatch):
monkeypatch.setattr('os.path.expanduser', lambda path: path)
@pytest.fixture
def settings_obj(custom_version, sys_onionshare_dev_mode, platform_linux):
return settings.Settings()
def settings_obj(sys_onionshare_dev_mode, platform_linux):
_common = common.Common()
_common.version = 'DUMMY_VERSION_1.2.3'
return settings.Settings(_common)
class TestSettings:
@ -154,30 +151,27 @@ class TestSettings:
def test_filename_darwin(
self,
custom_version,
monkeypatch,
os_path_expanduser,
platform_darwin):
obj = settings.Settings()
obj = settings.Settings(common.Common())
assert (obj.filename ==
'~/Library/Application Support/OnionShare/onionshare.json')
def test_filename_linux(
self,
custom_version,
monkeypatch,
os_path_expanduser,
platform_linux):
obj = settings.Settings()
obj = settings.Settings(common.Common())
assert obj.filename == '~/.config/onionshare/onionshare.json'
def test_filename_windows(
self,
custom_version,
monkeypatch,
platform_windows):
monkeypatch.setenv('APPDATA', 'C:')
obj = settings.Settings()
obj = settings.Settings(common.Common())
assert obj.filename == 'C:\\OnionShare\\onionshare.json'
def test_set_custom_bridge(self, settings_obj):