Determine the necessary changes to use db with test code,
I made necessary edits .travis.yml necessary to depend on wx mod indirectly when running test code eos\config.py copy from development branch, This change was necessary when using data base in test code. service\settings.py copy from development branch. and modified SettingsProvider.getSettings and Settings.save. After that, we made the same as master branch except for necessary code. This change was necessary when using data base in test code. and other improvement.
This commit is contained in:
@@ -1,232 +0,0 @@
|
||||
# Add root folder to python paths
|
||||
# This must be done on every test in order to pass in Travis
|
||||
import os
|
||||
import sys
|
||||
from time import time
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(os.path.realpath(os.path.join(script_dir, '..')))
|
||||
|
||||
#
|
||||
# noinspection PyPackageRequirements
|
||||
from _development.helpers import DBInMemory as DB, Gamedata, Saveddata
|
||||
# noinspection PyPackageRequirements
|
||||
from _development.helpers_fits import RifterFit, KeepstarFit, HeronFit, CurseFit
|
||||
from service.fit import Fit
|
||||
#
|
||||
# # Fake import wx
|
||||
# # todo: fix this
|
||||
# # from types import ModuleType
|
||||
# # wx = ModuleType("fake_module")
|
||||
# # sys.modules[wx.__name__] = wx
|
||||
#
|
||||
# def test_getAllFits(DB, RifterFit, KeepstarFit):
|
||||
# assert len(Fit.getAllFits()) == 0
|
||||
# DB['db'].save(RifterFit)
|
||||
# assert len(Fit.getAllFits()) == 1
|
||||
# DB['db'].save(KeepstarFit)
|
||||
# assert len(Fit.getAllFits()) == 2
|
||||
#
|
||||
# # Cleanup after ourselves
|
||||
# DB['db'].remove(RifterFit)
|
||||
# DB['db'].remove(KeepstarFit)
|
||||
#
|
||||
#
|
||||
# def test_getFitsWithShip_RifterFit(DB, RifterFit):
|
||||
# DB['db'].save(RifterFit)
|
||||
#
|
||||
# assert Fit.getFitsWithShip(587)[0][1] == 'My Rifter Fit'
|
||||
#
|
||||
# DB['db'].remove(RifterFit)
|
||||
|
||||
|
||||
def test_RifterSingleNew(DB, RifterFit, KeepstarFit, HeronFit, CurseFit):
|
||||
DB['db'].save(RifterFit)
|
||||
DB['db'].save(KeepstarFit)
|
||||
DB['db'].save(HeronFit)
|
||||
DB['db'].save(CurseFit)
|
||||
sFit = Fit.getInstance()
|
||||
sFit.serviceFittingOptions = {
|
||||
"useGlobalCharacter" : False,
|
||||
"useGlobalDamagePattern": False,
|
||||
"useGlobalForceReload" : False,
|
||||
"colorFitBySlot" : False,
|
||||
"rackSlots" : True,
|
||||
"rackLabels" : True,
|
||||
"compactSkills" : True,
|
||||
"showTooltip" : True,
|
||||
"showMarketShortcuts" : False,
|
||||
"enableGaugeAnimation" : True,
|
||||
"exportCharges" : True,
|
||||
"openFitInNew" : False,
|
||||
"priceSystem" : "Jita",
|
||||
"showShipBrowserTooltip": True,
|
||||
}
|
||||
|
||||
cached_fits = []
|
||||
fit = DB["db"].getFit(1)
|
||||
cached_fits.append(fit)
|
||||
fit = None
|
||||
|
||||
time_start = time()
|
||||
|
||||
for _ in xrange(1000000):
|
||||
|
||||
fit = next((x for x in cached_fits if x.ID == 1), None)
|
||||
|
||||
fit = None
|
||||
|
||||
print("1000000 of the Rifter fit (new): " + str(time()-time_start))
|
||||
|
||||
# fit = DB["db"].getFit(1)
|
||||
|
||||
# Cleanup after ourselves
|
||||
DB['db'].remove(RifterFit)
|
||||
DB['db'].remove(KeepstarFit)
|
||||
DB['db'].remove(HeronFit)
|
||||
DB['db'].remove(CurseFit)
|
||||
|
||||
def test_RifterSingleOld(DB, RifterFit, KeepstarFit, HeronFit, CurseFit):
|
||||
DB['db'].save(RifterFit)
|
||||
DB['db'].save(KeepstarFit)
|
||||
DB['db'].save(HeronFit)
|
||||
DB['db'].save(CurseFit)
|
||||
sFit = Fit.getInstance()
|
||||
sFit.serviceFittingOptions = {
|
||||
"useGlobalCharacter" : False,
|
||||
"useGlobalDamagePattern": False,
|
||||
"useGlobalForceReload" : False,
|
||||
"colorFitBySlot" : False,
|
||||
"rackSlots" : True,
|
||||
"rackLabels" : True,
|
||||
"compactSkills" : True,
|
||||
"showTooltip" : True,
|
||||
"showMarketShortcuts" : False,
|
||||
"enableGaugeAnimation" : True,
|
||||
"exportCharges" : True,
|
||||
"openFitInNew" : False,
|
||||
"priceSystem" : "Jita",
|
||||
"showShipBrowserTooltip": True,
|
||||
}
|
||||
|
||||
cached_fits = []
|
||||
fit = DB["db"].getFit(1)
|
||||
cached_fits.append(fit)
|
||||
fit = None
|
||||
|
||||
time_start = time()
|
||||
|
||||
for _ in xrange(1000000):
|
||||
|
||||
fit = DB["db"].getFit(1)
|
||||
|
||||
fit = None
|
||||
|
||||
print("1000000 of the Rifter fit (old): " + str(time()-time_start))
|
||||
|
||||
# Cleanup after ourselves
|
||||
DB['db'].remove(RifterFit)
|
||||
DB['db'].remove(KeepstarFit)
|
||||
DB['db'].remove(HeronFit)
|
||||
DB['db'].remove(CurseFit)
|
||||
|
||||
def test_FourNew(DB, RifterFit, KeepstarFit, HeronFit, CurseFit):
|
||||
DB['db'].save(RifterFit)
|
||||
DB['db'].save(KeepstarFit)
|
||||
DB['db'].save(HeronFit)
|
||||
DB['db'].save(CurseFit)
|
||||
sFit = Fit.getInstance()
|
||||
sFit.serviceFittingOptions = {
|
||||
"useGlobalCharacter" : False,
|
||||
"useGlobalDamagePattern": False,
|
||||
"useGlobalForceReload" : False,
|
||||
"colorFitBySlot" : False,
|
||||
"rackSlots" : True,
|
||||
"rackLabels" : True,
|
||||
"compactSkills" : True,
|
||||
"showTooltip" : True,
|
||||
"showMarketShortcuts" : False,
|
||||
"enableGaugeAnimation" : True,
|
||||
"exportCharges" : True,
|
||||
"openFitInNew" : False,
|
||||
"priceSystem" : "Jita",
|
||||
"showShipBrowserTooltip": True,
|
||||
}
|
||||
|
||||
cached_fits = []
|
||||
fit = DB["db"].getFit(1)
|
||||
cached_fits.append(fit)
|
||||
fit = None
|
||||
|
||||
time_start = time()
|
||||
|
||||
for _ in xrange(250000):
|
||||
|
||||
fit = next((x for x in cached_fits if x.ID == 1), None)
|
||||
fit = None
|
||||
fit = next((x for x in cached_fits if x.ID == 2), None)
|
||||
fit = None
|
||||
fit = next((x for x in cached_fits if x.ID == 3), None)
|
||||
fit = None
|
||||
fit = next((x for x in cached_fits if x.ID == 4), None)
|
||||
fit = None
|
||||
|
||||
|
||||
print("1000000 of the four fits (new): " + str(time()-time_start))
|
||||
|
||||
# fit = DB["db"].getFit(1)
|
||||
|
||||
# Cleanup after ourselves
|
||||
DB['db'].remove(RifterFit)
|
||||
DB['db'].remove(KeepstarFit)
|
||||
DB['db'].remove(HeronFit)
|
||||
DB['db'].remove(CurseFit)
|
||||
|
||||
def test_FourOld(DB, RifterFit, KeepstarFit, HeronFit, CurseFit):
|
||||
DB['db'].save(RifterFit)
|
||||
DB['db'].save(KeepstarFit)
|
||||
DB['db'].save(HeronFit)
|
||||
DB['db'].save(CurseFit)
|
||||
sFit = Fit.getInstance()
|
||||
sFit.serviceFittingOptions = {
|
||||
"useGlobalCharacter" : False,
|
||||
"useGlobalDamagePattern": False,
|
||||
"useGlobalForceReload" : False,
|
||||
"colorFitBySlot" : False,
|
||||
"rackSlots" : True,
|
||||
"rackLabels" : True,
|
||||
"compactSkills" : True,
|
||||
"showTooltip" : True,
|
||||
"showMarketShortcuts" : False,
|
||||
"enableGaugeAnimation" : True,
|
||||
"exportCharges" : True,
|
||||
"openFitInNew" : False,
|
||||
"priceSystem" : "Jita",
|
||||
"showShipBrowserTooltip": True,
|
||||
}
|
||||
|
||||
cached_fits = []
|
||||
fit = DB["db"].getFit(1)
|
||||
cached_fits.append(fit)
|
||||
fit = None
|
||||
|
||||
time_start = time()
|
||||
|
||||
for _ in xrange(250000):
|
||||
|
||||
fit = DB["db"].getFit(1)
|
||||
fit = None
|
||||
fit = DB["db"].getFit(2)
|
||||
fit = None
|
||||
fit = DB["db"].getFit(3)
|
||||
fit = None
|
||||
fit = DB["db"].getFit(4)
|
||||
fit = None
|
||||
|
||||
print("1000000 of the four fits (old): " + str(time()-time_start))
|
||||
|
||||
# Cleanup after ourselves
|
||||
DB['db'].remove(RifterFit)
|
||||
DB['db'].remove(KeepstarFit)
|
||||
DB['db'].remove(HeronFit)
|
||||
DB['db'].remove(CurseFit)
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
"""
|
||||
2017/04/05: unread description tests module.
|
||||
"""
|
||||
# noinspection PyPackageRequirements
|
||||
import pytest
|
||||
# Add root folder to python paths
|
||||
# This must be done on every test in order to pass in Travis
|
||||
import os
|
||||
import sys
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(os.path.realpath(os.path.join(script_dir, '..')))
|
||||
|
||||
# nopep8
|
||||
import re
|
||||
#
|
||||
# noinspection PyPackageRequirements
|
||||
from _development.helpers import DBInMemory as DB, Gamedata, Saveddata
|
||||
# noinspection PyPep8
|
||||
from service.port import Port, IPortUser
|
||||
|
||||
# from utils.strfunctions import sequential_rep, replace_ltgt
|
||||
from utils.stopwatch import Stopwatch
|
||||
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(os.path.realpath(os.path.join(script_dir, '..')))
|
||||
sys._called_from_test = True # need db open for tests. (see eos/config.py#17
|
||||
# noinspection PyPep8
|
||||
from service.port import Port, IPortUser
|
||||
#
|
||||
# noinspection PyPackageRequirements
|
||||
# from _development.helpers import DBInMemory as DB
|
||||
|
||||
"""
|
||||
NOTE:
|
||||
description character length is restricted 4hundred by EVE client.
|
||||
@@ -41,6 +44,9 @@ NOTE of @decorator:
|
||||
o Function to receive arguments of function to be decorated
|
||||
o A function that accepts the decorate target function itself as an argument
|
||||
o A function that accepts arguments of the decorator itself
|
||||
|
||||
for local coverage:
|
||||
py.test --cov=./ --cov-report=html
|
||||
"""
|
||||
|
||||
class PortUser(IPortUser):
|
||||
@@ -52,11 +58,24 @@ class PortUser(IPortUser):
|
||||
|
||||
stpw = Stopwatch('test measurementer')
|
||||
|
||||
def test_import_xml():
|
||||
@pytest.fixture()
|
||||
def print_db_info():
|
||||
# Output debug info
|
||||
import eos
|
||||
print
|
||||
print "------------ data base connection info ------------"
|
||||
print(eos.db.saveddata_engine)
|
||||
print(eos.db.gamedata_engine)
|
||||
print
|
||||
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
def test_import_xml(print_db_info):
|
||||
usr = PortUser()
|
||||
# for path in XML_FILES:
|
||||
xml_file = "jeffy_ja-en[99].xml"
|
||||
fit_count = int(re.search(r"\[(\d+)\]", xml_file).group(1))
|
||||
fits = None
|
||||
with open(os.path.join(script_dir, xml_file), "r") as file_:
|
||||
srcString = file_.read()
|
||||
srcString = unicode(srcString, "utf-8")
|
||||
|
||||
Reference in New Issue
Block a user