mirror of
https://github.com/arcan1s/ffxivbis.git
synced 2025-07-12 21:35:50 +00:00
initial commit
This commit is contained in:
128
test/conftest.py
Normal file
128
test/conftest.py
Normal file
@ -0,0 +1,128 @@
|
||||
import os
|
||||
import pytest
|
||||
import tempfile
|
||||
|
||||
from typing import Any, List
|
||||
|
||||
from service.api.web import setup_service
|
||||
from service.core.ariyala_parser import AriyalaParser
|
||||
from service.core.config import Configuration
|
||||
from service.core.database import Database
|
||||
from service.core.loot_selector import LootSelector
|
||||
from service.core.party import Party
|
||||
from service.core.sqlite import SQLiteDatabase
|
||||
from service.models.bis import BiS
|
||||
from service.models.job import Job
|
||||
from service.models.piece import Head, Piece, Weapon
|
||||
from service.models.player import Player
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def parser(config: Configuration) -> AriyalaParser:
|
||||
return AriyalaParser(config)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bis() -> BiS:
|
||||
return BiS()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bis2() -> BiS:
|
||||
return BiS()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bis_link() -> str:
|
||||
return 'https://ffxiv.ariyala.com/19V5R'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def bis_set() -> List[Piece]:
|
||||
items: List[Piece] = []
|
||||
items.append(Piece.get({'piece': 'weapon', 'is_tome': False}))
|
||||
items.append(Piece.get({'piece': 'head', 'is_tome': False}))
|
||||
items.append(Piece.get({'piece': 'body', 'is_tome': False}))
|
||||
items.append(Piece.get({'piece': 'hands', 'is_tome': True}))
|
||||
items.append(Piece.get({'piece': 'waist', 'is_tome': True}))
|
||||
items.append(Piece.get({'piece': 'legs', 'is_tome': True}))
|
||||
items.append(Piece.get({'piece': 'feet', 'is_tome': False}))
|
||||
items.append(Piece.get({'piece': 'ears', 'is_tome': False}))
|
||||
items.append(Piece.get({'piece': 'neck', 'is_tome': True}))
|
||||
items.append(Piece.get({'piece': 'wrist', 'is_tome': False}))
|
||||
items.append(Piece.get({'piece': 'left_ring', 'is_tome': True}))
|
||||
items.append(Piece.get({'piece': 'right_ring', 'is_tome': True}))
|
||||
|
||||
return items
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config() -> Configuration:
|
||||
config = Configuration()
|
||||
config.load('/dev/null', {
|
||||
'ariyala': {
|
||||
'ariyala_url': 'https://ffxiv.ariyala.com',
|
||||
'request_timeout': 1,
|
||||
'xivapi_url': 'https://xivapi.com'
|
||||
},
|
||||
'settings': {
|
||||
'include': '/dev/null'
|
||||
}
|
||||
})
|
||||
return config
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def database() -> SQLiteDatabase:
|
||||
db = SQLiteDatabase(
|
||||
tempfile.mktemp('-ffxivbis.db'),
|
||||
os.path.join(os.path.dirname(os.path.dirname(__file__)), 'migrations'))
|
||||
db.migration()
|
||||
return db
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def head_with_upgrade() -> Piece:
|
||||
return Head(is_tome=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def party(database: Database) -> Party:
|
||||
return Party(database)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def player(bis: BiS) -> Player:
|
||||
return Player(Job.WHM, 'A nick', bis, [])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def player2(bis2: BiS) -> Player:
|
||||
return Player(Job.AST, 'Another nick', bis2, [], priority=0)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def selector(party: Party, player: Player, player2: Player,
|
||||
head_with_upgrade: Piece, weapon: Piece) -> LootSelector:
|
||||
obj = LootSelector(party)
|
||||
|
||||
obj.party.set_player(player)
|
||||
player.bis.set_item(weapon)
|
||||
|
||||
obj.party.set_player(player2)
|
||||
player2.bis.set_item(head_with_upgrade)
|
||||
player2.bis.set_item(weapon)
|
||||
|
||||
return LootSelector(party)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def server(loop: Any, aiohttp_client: Any,
|
||||
config: Configuration, database: Database, selector: LootSelector, party: Party) -> Any:
|
||||
app = setup_service(config, database, selector, party)
|
||||
return loop.run_until_complete(aiohttp_client(app))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def weapon() -> Piece:
|
||||
return Weapon(is_tome=False)
|
Reference in New Issue
Block a user