Skip to content
Permalink
Browse files

Apply tox to everything that is used. Stops ignoring tests and a bunc…

…h of other stuff.
  • Loading branch information...
Ebag333 committed May 15, 2017
1 parent 265e20e commit 5fa6af9cb4c4e085271b84bad30d3e079ab1f3e0
@@ -3,93 +3,13 @@

import os
import sys
import threading

from sqlalchemy import MetaData, create_engine
from sqlalchemy.orm import sessionmaker

script_dir = os.path.dirname(os.path.abspath(__file__))
# Add root folder to python paths
sys.path.append(os.path.realpath(os.path.join(script_dir, u'..', u'..')))
sys._called_from_test = True


# noinspection PyUnresolvedReferences,PyUnusedLocal
@pytest.fixture
def DBInMemory_test():
def rollback():
with sd_lock:
saveddata_session.rollback()

print("Creating database in memory")
from os.path import realpath, join, dirname, abspath

debug = False
gamedataCache = True
saveddataCache = True
gamedata_version = ""
gamedata_connectionstring = 'sqlite:///' + realpath(join(dirname(abspath(unicode(__file__))), "..", "eve.db"))
saveddata_connectionstring = 'sqlite:///:memory:'

class ReadOnlyException(Exception):
pass

if callable(gamedata_connectionstring):
gamedata_engine = create_engine("sqlite://", creator=gamedata_connectionstring, echo=debug)
else:
gamedata_engine = create_engine(gamedata_connectionstring, echo=debug)

gamedata_meta = MetaData()
gamedata_meta.bind = gamedata_engine
gamedata_session = sessionmaker(bind=gamedata_engine, autoflush=False, expire_on_commit=False)()

# This should be moved elsewhere, maybe as an actual query. Current, without try-except, it breaks when making a new
# game db because we haven't reached gamedata_meta.create_all()
try:
gamedata_version = gamedata_session.execute(
"SELECT `field_value` FROM `metadata` WHERE `field_name` LIKE 'client_build'"
).fetchone()[0]
except Exception as e:
print("Missing gamedata version.")
gamedata_version = None

if saveddata_connectionstring is not None:
if callable(saveddata_connectionstring):
saveddata_engine = create_engine(creator=saveddata_connectionstring, echo=debug)
else:
saveddata_engine = create_engine(saveddata_connectionstring, echo=debug)

saveddata_meta = MetaData()
saveddata_meta.bind = saveddata_engine
saveddata_session = sessionmaker(bind=saveddata_engine, autoflush=False, expire_on_commit=False)()
else:
saveddata_meta = None

# Lock controlling any changes introduced to session
sd_lock = threading.Lock()

# Import all the definitions for all our database stuff
# noinspection PyPep8
# from eos.db.gamedata import alphaClones, attribute, category, effect, group, icon, item, marketGroup, metaData, metaGroup, queries, traits, unit
# noinspection PyPep8
# from eos.db.saveddata import booster, cargo, character, crest, damagePattern, databaseRepair, drone, fighter, fit, implant, implantSet, loadDefaultDatabaseValues, miscData, module, override, price, queries, skill, targetResists, user

# If using in memory saveddata, you'll want to reflect it so the data structure is good.
if saveddata_connectionstring == "sqlite:///:memory:":
saveddata_meta.create_all()

# Output debug info to help us troubleshoot Travis
print(saveddata_engine)
print(gamedata_engine)

helper = {
# 'config': eos.config,
'gamedata_session' : gamedata_session,
'saveddata_session': saveddata_session,
}
return helper


# noinspection PyUnresolvedReferences,PyUnusedLocal
@pytest.fixture
def DBInMemory():
@@ -1,11 +1,11 @@
import pytest

# noinspection PyPackageRequirements
from _development.helpers import DBInMemory as DB, Gamedata, Saveddata
from _development.helpers import DBInMemory as DB, Gamedata, Saveddata # noqa: F401


# noinspection PyShadowingNames
@pytest.fixture
@pytest.fixture # noqa: F811
def RifterFit(DB, Gamedata, Saveddata):
print("Creating Rifter")
item = DB['gamedata_session'].query(Gamedata['Item']).filter(Gamedata['Item'].name == "Rifter").first()
@@ -17,7 +17,7 @@ def RifterFit(DB, Gamedata, Saveddata):


# noinspection PyShadowingNames
@pytest.fixture
@pytest.fixture # noqa: F811
def KeepstarFit(DB, Gamedata, Saveddata):
print("Creating Keepstar")
item = DB['gamedata_session'].query(Gamedata['Item']).filter(Gamedata['Item'].name == "Keepstar").first()
@@ -29,7 +29,7 @@ def KeepstarFit(DB, Gamedata, Saveddata):


# noinspection PyShadowingNames
@pytest.fixture
@pytest.fixture # noqa: F811
def CurseFit(DB, Gamedata, Saveddata):
print("Creating Curse - With Neuts")
item = DB['gamedata_session'].query(Gamedata['Item']).filter(Gamedata['Item'].name == "Curse").first()
@@ -48,7 +48,7 @@ def CurseFit(DB, Gamedata, Saveddata):


# noinspection PyShadowingNames
@pytest.fixture
@pytest.fixture # noqa: F811
def HeronFit(DB, Gamedata, Saveddata):
print("Creating Heron - RemoteSebo")
item = DB['gamedata_session'].query(Gamedata['Item']).filter(Gamedata['Item'].name == "Heron").first()
@@ -1,11 +1,11 @@
import pytest

# noinspection PyPackageRequirements
from _development.helpers import DBInMemory as DB, Gamedata, Saveddata
from _development.helpers import DBInMemory as DB, Gamedata, Saveddata # noqa: F401


# noinspection PyShadowingNames
@pytest.fixture
@pytest.fixture # noqa: F811
def StrongBluePillBooster(DB, Gamedata, Saveddata):
print("Creating Strong Blue Pill Booster")
item = DB['gamedata_session'].query(Gamedata['Item']).filter(Gamedata['Item'].name == "Strong Blue Pill Booster").first()
@@ -22,7 +22,7 @@
from sqlalchemy import MetaData

from eos.db.sqlAlchemyHandler import session_engine_factory
import migration
import migration # noqa: F401
from eos import config
from logbook import Logger

@@ -66,16 +66,48 @@ class ReadOnlyException(Exception):

# Import all the definitions for all our database stuff
# noinspection PyPep8
from eos.db.gamedata import alphaClones, attribute, category, effect, group, icon, item, marketGroup, metaData, metaGroup, traits, unit
from eos.db.gamedata import ( # noqa: E402,F401
alphaClones,
attribute,
category,
effect,
group,
icon,
item,
marketGroup,
metaData,
metaGroup,
traits,
unit,
)
# noinspection PyPep8
from eos.db.saveddata import booster, cargo, character, crest, damagePattern, databaseRepair, drone, fighter, fit, implant, implantSet, loadDefaultDatabaseValues, \
miscData, module, override, price, skill, targetResists, user
from eos.db.saveddata import ( # noqa: E402,F401
booster,
cargo,
character,
crest,
damagePattern,
databaseRepair,
drone,
fighter,
fit,
implant,
implantSet,
loadDefaultDatabaseValues,
miscData,
module,
override,
price,
skill,
targetResists,
user,
)

# Import queries
# noinspection PyPep8
from eos.db.gamedata.queries import *
from eos.db.gamedata.queries import * # noqa: F401, F402, F403
# noinspection PyPep8
from eos.db.saveddata.queries import *
from eos.db.saveddata.queries import * # noqa: F401, F402, F403

# If using in memory saveddata, you'll want to reflect it so the data structure is good.
if config.saveddata_connectionstring == "sqlite:///:memory:":

0 comments on commit 5fa6af9

Please sign in to comment.
You can’t perform that action at this time.