Baby's first (real) Eos test.
(cherry picked from commit df51f9f)
This commit is contained in:
53
tests/test_smoketests/helpers.py
Normal file
53
tests/test_smoketests/helpers.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import pytest
|
||||
|
||||
|
||||
# noinspection PyUnresolvedReferences,PyUnusedLocal
|
||||
@pytest.fixture
|
||||
def DBInMemory():
|
||||
import eos.config
|
||||
from os.path import realpath, join, dirname, abspath
|
||||
|
||||
debug = False
|
||||
gamedataCache = True
|
||||
saveddataCache = True
|
||||
gamedata_version = ""
|
||||
eos.config.gamedata_connectionstring = 'sqlite:///' + realpath(join(dirname(abspath(unicode(__file__))), "..", "..", "eve.db"))
|
||||
# saveddata_connectionstring = 'sqlite:///' + unicode(realpath(join(dirname(abspath(__file__)), "..", "saveddata", "saveddata.db")), sys.getfilesystemencoding())
|
||||
eos.config.saveddata_connectionstring = 'sqlite:///:memory:'
|
||||
|
||||
import eos
|
||||
import eos.db
|
||||
|
||||
helper = {
|
||||
'config': eos.config,
|
||||
'db' : eos.db,
|
||||
}
|
||||
return helper
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def Gamedata():
|
||||
from eos.gamedata import Item
|
||||
|
||||
helper = {
|
||||
'Item': Item,
|
||||
}
|
||||
return helper
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def Saveddata():
|
||||
from eos.saveddata.ship import Ship
|
||||
from eos.saveddata.fit import Fit
|
||||
from eos.saveddata.character import Character
|
||||
from eos.saveddata.module import Module, State
|
||||
|
||||
helper = {
|
||||
'Ship' : Ship,
|
||||
'Fit' : Fit,
|
||||
'Character': Character,
|
||||
'Module' : Module,
|
||||
'State' : State,
|
||||
}
|
||||
return helper
|
||||
49
tests/test_smoketests/test_rifter.py
Normal file
49
tests/test_smoketests/test_rifter.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# noinspection PyPackageRequirements
|
||||
import pytest
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from helpers import DBInMemory as DB
|
||||
# noinspection PyUnresolvedReferences
|
||||
from helpers import Gamedata
|
||||
# noinspection PyUnresolvedReferences
|
||||
from helpers import Saveddata
|
||||
|
||||
|
||||
# noinspection PyShadowingNames
|
||||
@pytest.fixture
|
||||
def Rifter(DB, Gamedata, Saveddata):
|
||||
item = DB['db'].gamedata_session.query(Gamedata['Item']).filter(Gamedata['Item'].name == "Rifter").first()
|
||||
ship = Saveddata['Ship'](item)
|
||||
# setup fit
|
||||
fit = Saveddata['Fit'](ship, "My Rifter Fit")
|
||||
|
||||
return fit
|
||||
|
||||
|
||||
# noinspection PyShadowingNames
|
||||
def test_rifter_cpu_output(DB, Saveddata, Rifter):
|
||||
char5 = Saveddata['Character'].getAll5()
|
||||
char0 = Saveddata['Character'].getAll0()
|
||||
|
||||
Rifter.character = char0
|
||||
mod = Saveddata['Module'](DB['db'].getItem("Co-Processor II"))
|
||||
mod.state = Saveddata['State'].OFFLINE
|
||||
Rifter.modules.append(mod)
|
||||
|
||||
assert Rifter.ship.getModifiedItemAttr("cpuOutput") == 130
|
||||
|
||||
Rifter.calculateModifiedAttributes()
|
||||
assert Rifter.ship.getModifiedItemAttr("cpuOutput") == 130
|
||||
|
||||
mod.state = Saveddata['State'].ONLINE
|
||||
Rifter.clear()
|
||||
Rifter.calculateModifiedAttributes()
|
||||
assert Rifter.ship.getModifiedItemAttr("cpuOutput") == 143
|
||||
|
||||
Rifter.character = char5
|
||||
Rifter.clear()
|
||||
Rifter.calculateModifiedAttributes()
|
||||
assert Rifter.ship.getModifiedItemAttr("cpuOutput") == 178.75
|
||||
|
||||
# No reason to save it, but as an example how
|
||||
# DB['db'].save(Rifter) # tada, it's now in database and can be accessed in pyfa
|
||||
Reference in New Issue
Block a user