Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def test_resolve_wowi_pkgs(manager):
results = await manager.resolve(
[Defn('wowi', '13188-molinari'), Defn('wowi', '13188', Strategies.latest)]
)
either, invalid = results.values()
assert isinstance(either, Pkg)
assert (
isinstance(invalid, E.PkgStrategyUnsupported)
and invalid.message == "'latest' strategy is not valid for source"
)
async def test_resolve_curse_deps(manager):
if manager.config.is_classic:
pytest.skip('no classic equivalent')
defns = [Defn('curse', 'mechagon-rare-share', Strategies.default)]
with_deps = await manager.resolve(defns, with_deps=True)
assert ['mechagon-rare-share', 'rare-share'] == [d.slug for d in with_deps.values()]
async def test_resolve_curse_simple_pkgs(manager, request, strategy):
results = await manager.resolve(
[
Defn('curse', 'tomcats', strategy),
Defn('curse', 'mythic-dungeon-tools', strategy),
Defn('curse', 'classiccastbars', strategy),
Defn('curse', 'elkbuffbars', strategy),
]
)
separate, retail_only, classic_only, flavour_explosion = results.values()
assert isinstance(separate, Pkg)
if manager.config.is_classic:
if strategy is Strategies.any_flavour:
assert 'classic' not in separate.version
assert isinstance(retail_only, Pkg)
else:
assert 'classic' in separate.version
assert (
isinstance(retail_only, E.PkgFileUnavailable)
and retail_only.message
== f"no files compatible with classic using '{strategy.name}' strategy"
async def test_multiple_defns_per_addon_contained_in_results(manager, molinari, test_func):
((_, matches),) = await test_func(manager, get_folders(manager))
assert {Defn('curse', '20338'), Defn('wowi', '13188')} == set(matches)
async def test_search_with_extra_spice(manager):
results = await manager.search('AtlasLootClassic', limit=5)
if manager.config.is_classic:
assert Defn('curse', 'atlaslootclassic') in results
else:
assert Defn('curse', 'atlaslootclassic') not in results
def test_invalid_any_dir_raises(full_config, dir_):
with pytest.raises(ValueError): # type: ignore
Config(**{**full_config, dir_: '~foo'})
def test_default_config_dir_is_platform_and_xdg_appropriate(partial_config, monkeypatch):
with monkeypatch.context() as patcher:
patcher.setattr(sys, 'platform', 'linux')
config_dir = Config(**partial_config).config_dir
assert config_dir == Path.home() / '.config/instawow'
patcher.setenv('XDG_CONFIG_HOME', '/foo')
config_dir = Config(**partial_config).config_dir
assert config_dir == Path('/foo/instawow')
with monkeypatch.context() as patcher:
patcher.setattr(sys, 'platform', 'darwin')
config_dir = Config(**partial_config).config_dir
assert config_dir == Path.home() / 'Library/Application Support/instawow'
def test_config_dir_is_populated(full_config):
config = Config(**full_config).write()
assert {i.name for i in config.config_dir.iterdir()} == {'config.json', 'logs', 'plugins'}
def config(tmp_path_factory):
config = Config(config_dir=tmp_path_factory.mktemp(f'{__name__}_config'),
addon_dir=tmp_path_factory.mktemp(f'{__name__}_addons'))
config.write()
yield config
def test_default_config_dir_on_win32(partial_config, monkeypatch):
assert Config(**partial_config).config_dir == Path.home() / 'AppData/Roaming/instawow'
monkeypatch.delenv('APPDATA')
assert Config(**partial_config).config_dir == Path.home() / 'instawow'