-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
108 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ __pycache__ | |
node_modules | ||
.venv | ||
.mypy_cache | ||
data |
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
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
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
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,48 @@ | ||
import asyncio | ||
import inspect | ||
from typing import List, Optional | ||
|
||
import pytest_asyncio | ||
from lnbits.db import Database | ||
from loguru import logger | ||
from pydantic import BaseModel | ||
|
||
from .. import migrations | ||
from ..relay.event import NostrEvent | ||
from .helpers import get_fixtures | ||
|
||
|
||
class EventFixture(BaseModel): | ||
name: str | ||
exception: Optional[str] | ||
data: NostrEvent | ||
|
||
|
||
@pytest_asyncio.fixture(scope="session") | ||
def event_loop(): | ||
loop = asyncio.get_event_loop() | ||
yield loop | ||
loop.close() | ||
|
||
|
||
@pytest_asyncio.fixture(scope="session", autouse=True) | ||
async def migrate_db(): | ||
print("#### 999") | ||
db = Database("ext_nostrrelay") | ||
for key, migrate in inspect.getmembers(migrations, inspect.isfunction): | ||
print("### 1000") | ||
logger.info(f"Running migration '{key}'.") | ||
await migrate(db) | ||
return migrations | ||
|
||
|
||
@pytest_asyncio.fixture(scope="session") | ||
def valid_events(migrate_db) -> List[EventFixture]: | ||
data = get_fixtures("events") | ||
return [EventFixture.parse_obj(e) for e in data["valid"]] | ||
|
||
|
||
@pytest_asyncio.fixture(scope="session") | ||
def invalid_events(migrate_db) -> List[EventFixture]: | ||
data = get_fixtures("events") | ||
return [EventFixture.parse_obj(e) for e in data["invalid"]] |
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
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