test: refer to test data path via variable (#1964)
This commit is contained in:
parent
ed12cc1186
commit
6a1d716ba1
2 changed files with 9 additions and 7 deletions
|
@ -4,16 +4,17 @@ import os
|
||||||
import pytest
|
import pytest
|
||||||
from Site import SiteManager
|
from Site import SiteManager
|
||||||
|
|
||||||
|
TEST_DATA_PATH = "src/Test/testdata"
|
||||||
|
|
||||||
@pytest.mark.usefixtures("resetSettings")
|
@pytest.mark.usefixtures("resetSettings")
|
||||||
class TestSite:
|
class TestSite:
|
||||||
def testClone(self, site):
|
def testClone(self, site):
|
||||||
assert site.storage.directory == "src/Test/testdata/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT"
|
assert site.storage.directory == TEST_DATA_PATH + "/1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT"
|
||||||
|
|
||||||
# Remove old files
|
# Remove old files
|
||||||
if os.path.isdir("src/Test/testdata/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL"):
|
if os.path.isdir(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL"):
|
||||||
shutil.rmtree("src/Test/testdata/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL")
|
shutil.rmtree(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL")
|
||||||
assert not os.path.isfile("src/Test/testdata/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL/content.json")
|
assert not os.path.isfile(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL/content.json")
|
||||||
|
|
||||||
# Clone 1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT to 15E5rhcAUD69WbiYsYARh4YHJ4sLm2JEyc
|
# Clone 1TeSTvb4w2PWE81S2rEELgmX2GCCExQGT to 15E5rhcAUD69WbiYsYARh4YHJ4sLm2JEyc
|
||||||
new_site = site.clone(
|
new_site = site.clone(
|
||||||
|
@ -61,7 +62,7 @@ class TestSite:
|
||||||
|
|
||||||
# Delete created files
|
# Delete created files
|
||||||
new_site.storage.deleteFiles()
|
new_site.storage.deleteFiles()
|
||||||
assert not os.path.isdir("src/Test/testdata/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL")
|
assert not os.path.isdir(TEST_DATA_PATH + "/159EGD5srUsMP97UpcLy8AtKQbQLK2AbbL")
|
||||||
|
|
||||||
# Delete from site registry
|
# Delete from site registry
|
||||||
assert new_site.address in SiteManager.site_manager.sites
|
assert new_site.address in SiteManager.site_manager.sites
|
||||||
|
|
|
@ -72,7 +72,8 @@ fmt = logging.Formatter(fmt='+%(relative)ss %(levelname)-8s %(name)s %(message)s
|
||||||
# Load plugins
|
# Load plugins
|
||||||
from Plugin import PluginManager
|
from Plugin import PluginManager
|
||||||
|
|
||||||
config.data_dir = "src/Test/testdata" # Use test data for unittests
|
TEST_DATA_PATH = 'src/Test/testdata'
|
||||||
|
config.data_dir = TEST_DATA_PATH # Use test data for unittests
|
||||||
|
|
||||||
os.chdir(os.path.abspath(os.path.dirname(__file__) + "/../..")) # Set working dir
|
os.chdir(os.path.abspath(os.path.dirname(__file__) + "/../..")) # Set working dir
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ config.debug_socket = True # Use test data for unittests
|
||||||
config.verbose = True # Use test data for unittests
|
config.verbose = True # Use test data for unittests
|
||||||
config.tor = "disable" # Don't start Tor client
|
config.tor = "disable" # Don't start Tor client
|
||||||
config.trackers = []
|
config.trackers = []
|
||||||
config.data_dir = "src/Test/testdata" # Use test data for unittests
|
config.data_dir = TEST_DATA_PATH # Use test data for unittests
|
||||||
config.initLogging()
|
config.initLogging()
|
||||||
|
|
||||||
from Site import Site
|
from Site import Site
|
||||||
|
|
Loading…
Reference in a new issue