Red-DiscordBot/tests/core/test_cog_manager.py
Will de912a3cfb [Config] Asynchronous getters (#907)
* Make config get async

* Asyncify alias

* Asyncify bank

* Asyncify cog manager

* IT BOOTS

* Asyncify core commands

* Asyncify repo manager

* Asyncify downloader

* Asyncify economy

* Asyncify alias TESTS

* Asyncify economy TESTS

* Asyncify downloader TESTS

* Asyncify config TESTS

* A bank thing

* Asyncify Bank cog

* Warning message in docs

* Update docs with await syntax

* Update docs with await syntax
2017-08-11 21:43:21 -04:00

59 lines
1.3 KiB
Python

from pathlib import Path
import pytest
from core import cog_manager
@pytest.fixture()
def cog_mgr(red):
return red.cog_mgr
@pytest.fixture()
def default_dir(red):
return red.main_dir
@pytest.mark.asyncio
async def test_ensure_cogs_in_paths(cog_mgr, default_dir):
cogs_dir = default_dir / 'cogs'
assert cogs_dir in await cog_mgr.paths()
@pytest.mark.asyncio
async def test_install_path_set(cog_mgr: cog_manager.CogManager, tmpdir):
path = Path(str(tmpdir))
await cog_mgr.set_install_path(path)
assert await cog_mgr.install_path() == path
@pytest.mark.asyncio
async def test_install_path_set_bad(cog_mgr):
path = Path('something')
with pytest.raises(ValueError):
await cog_mgr.set_install_path(path)
@pytest.mark.asyncio
async def test_add_path(cog_mgr, tmpdir):
path = Path(str(tmpdir))
await cog_mgr.add_path(path)
assert path in await cog_mgr.paths()
@pytest.mark.asyncio
async def test_add_path_already_install_path(cog_mgr, tmpdir):
path = Path(str(tmpdir))
await cog_mgr.set_install_path(path)
with pytest.raises(ValueError):
await cog_mgr.add_path(path)
@pytest.mark.asyncio
async def test_remove_path(cog_mgr, tmpdir):
path = Path(str(tmpdir))
await cog_mgr.add_path(path)
await cog_mgr.remove_path(path)
assert path not in await cog_mgr.paths()