-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Ju4tCode <[email protected]>
- Loading branch information
Showing
10 changed files
with
587 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Code Coverage | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Test Coverage | ||
runs-on: ${{ matrix.os }} | ||
concurrency: | ||
group: test-coverage-${{ github.ref }}-${{ matrix.os }}-${{ matrix.python-version }} | ||
cancel-in-progress: true | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
env: | ||
OS: ${{ matrix.os }} | ||
PYTHON_VERSION: ${{ matrix.python-version }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Python environment | ||
uses: ./.github/actions/setup-python | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Run Pytest | ||
run: | | ||
poetry run pytest -n auto --cov-append --cov-report xml | ||
- name: Upload coverage report | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
env_vars: OS,PYTHON_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
import nonebot | ||
from nonebug import NONEBOT_INIT_KWARGS | ||
|
||
|
||
def pytest_configure(config: pytest.Config) -> None: | ||
config.stash[NONEBOT_INIT_KWARGS] = {"driver": "~none"} | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def tmp_path(tmp_path_factory: pytest.TempPathFactory) -> Path: | ||
return tmp_path_factory.mktemp("nonebot_plugin_localstore") | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def _load_plugin(nonebug_init: None, tmp_path: Path): | ||
nonebot.load_plugin("nonebot_plugin_localstore") | ||
|
||
with pytest.MonkeyPatch.context() as m: | ||
m.setattr("nonebot_plugin_localstore.BASE_DATA_DIR", tmp_path / "data") | ||
m.setattr("nonebot_plugin_localstore.BASE_CACHE_DIR", tmp_path / "cache") | ||
m.setattr("nonebot_plugin_localstore.BASE_CONFIG_DIR", tmp_path / "config") | ||
|
||
nonebot.load_plugin("tests.plugin") | ||
yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from pathlib import Path | ||
|
||
import nonebot | ||
|
||
from nonebot_plugin_localstore import ( | ||
get_plugin_data_dir, | ||
get_plugin_cache_dir, | ||
get_plugin_data_file, | ||
get_plugin_cache_file, | ||
get_plugin_config_dir, | ||
get_plugin_config_file, | ||
) | ||
|
||
data_dir = get_plugin_data_dir() | ||
cache_dir = get_plugin_cache_dir() | ||
config_dir = get_plugin_config_dir() | ||
|
||
data_file = get_plugin_data_file("data_file") | ||
cache_file = get_plugin_cache_file("cache_file") | ||
config_file = get_plugin_config_file("config_file") | ||
|
||
_sub_plugins = set() | ||
_sub_plugins |= nonebot.load_plugins(str((Path(__file__).parent / "plugins").resolve())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from nonebot_plugin_localstore import ( | ||
get_plugin_data_dir, | ||
get_plugin_cache_dir, | ||
get_plugin_data_file, | ||
get_plugin_cache_file, | ||
get_plugin_config_dir, | ||
get_plugin_config_file, | ||
) | ||
|
||
data_dir = get_plugin_data_dir() | ||
cache_dir = get_plugin_cache_dir() | ||
config_dir = get_plugin_config_dir() | ||
|
||
data_file = get_plugin_data_file("data_file") | ||
cache_file = get_plugin_cache_file("cache_file") | ||
config_file = get_plugin_config_file("config_file") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from pathlib import Path | ||
|
||
|
||
def test_plugin_dir(tmp_path: Path): | ||
from tests.plugin import data_dir, cache_dir, config_dir | ||
|
||
assert data_dir == tmp_path / "data" / "plugin" | ||
assert data_dir.is_dir() | ||
assert cache_dir == tmp_path / "cache" / "plugin" | ||
assert cache_dir.is_dir() | ||
assert config_dir == tmp_path / "config" / "plugin" | ||
assert config_dir.is_dir() | ||
|
||
|
||
def test_sub_plugin_dir(tmp_path: Path): | ||
from tests.plugin.plugins.sub_plugin import data_dir, cache_dir, config_dir | ||
|
||
assert data_dir == tmp_path / "data" / "plugin" / "sub_plugin" | ||
assert data_dir.is_dir() | ||
assert cache_dir == tmp_path / "cache" / "plugin" / "sub_plugin" | ||
assert cache_dir.is_dir() | ||
assert config_dir == tmp_path / "config" / "plugin" / "sub_plugin" | ||
assert config_dir.is_dir() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from pathlib import Path | ||
|
||
|
||
def test_plugin_file(tmp_path: Path): | ||
from tests.plugin import data_file, cache_file, config_file | ||
|
||
assert data_file == tmp_path / "data" / "plugin" / "data_file" | ||
assert cache_file == tmp_path / "cache" / "plugin" / "cache_file" | ||
assert config_file == tmp_path / "config" / "plugin" / "config_file" | ||
|
||
|
||
def test_sub_plugin_file(tmp_path: Path): | ||
from tests.plugin.plugins.sub_plugin import data_file, cache_file, config_file | ||
|
||
assert data_file == tmp_path / "data" / "plugin" / "sub_plugin" / "data_file" | ||
assert cache_file == tmp_path / "cache" / "plugin" / "sub_plugin" / "cache_file" | ||
assert config_file == tmp_path / "config" / "plugin" / "sub_plugin" / "config_file" |