def setUp(self): TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(self.__here))) if not os.path.exists(self.__testout): os.makedirs(self.__testout) mockTopPath = os.path.join(TOPDIR, "wwpdb", "mock-data") self.__crw = CreateRWTree(mockTopPath, self.__testout)
def testWriteLocationConfig(self): """Test writing config file""" subtestdir = os.path.join(TESTOUTPUT, "testconfig") testout = os.path.join(subtestdir, "site-config", "rcsb-east", "wwpdb_deploy_test", "ConfigInfoFileCache.json") if os.path.exists(testout): os.remove(testout) cr = CreateRWTree(mockTopPath, subtestdir) cr.createtree(["site-config"]) saveconf = os.environ["TOP_WWPDB_SITE_CONFIG_DIR"] try: os.environ["TOP_WWPDB_SITE_CONFIG_DIR"] = os.path.join(subtestdir, "site-config") cif = ConfigInfoFileExec(mockTopPath=subtestdir) cif.writeLocationConfigCache(siteLoc="rcsb-east") except Exception as e: # pragma: no cover self.fail("Error testing writing config %s" % str(e)) os.environ["TOP_WWPDB_SITE_CONFIG_DIR"] = saveconf self.assertTrue(os.path.exists(testout))
import unittest HERE = os.path.abspath(os.path.dirname(__file__)) TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(HERE))) TESTOUTPUT = os.path.join(HERE, "test-output", platform.python_version()) if not os.path.exists(TESTOUTPUT): os.makedirs(TESTOUTPUT) # pragma: no cover mockTopPath = os.path.join(TOPDIR, "wwpdb", "mock-data") rwMockTopPath = os.path.join(TESTOUTPUT) # Must create config file before importing ConfigInfo from wwpdb.utils.testing.SiteConfigSetup import SiteConfigSetup # noqa: E402 from wwpdb.utils.testing.CreateRWTree import CreateRWTree # noqa: E402 # Copy site-config and selected items crw = CreateRWTree(mockTopPath, TESTOUTPUT) crw.createtree(["site-config", "depuiresources", "webapps"]) # Use populate r/w site-config using top mock site-config SiteConfigSetup().setupEnvironment(rwMockTopPath, rwMockTopPath) from wwpdb.utils.config.ConfigInfoFileExec import ConfigInfoFileExec # noqa: E402 HERE = os.path.abspath(os.path.dirname(__file__)) TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(HERE))) class ConfigInfoFileExecTests(unittest.TestCase): def setUp(self): pass def tearDown(self):
class CreateRWTreeTest(unittest.TestCase): @classmethod def setUpClass(cls): cls.__here = os.path.abspath(os.path.dirname(__file__)) TESTOUTPUT = os.path.join(cls.__here, "test-output", platform.python_version(), "copytest") cls.__testout = TESTOUTPUT if os.path.exists(cls.__testout): shutil.rmtree(cls.__testout) def setUp(self): TOPDIR = os.path.dirname(os.path.dirname(os.path.dirname(self.__here))) if not os.path.exists(self.__testout): os.makedirs(self.__testout) mockTopPath = os.path.join(TOPDIR, "wwpdb", "mock-data") self.__crw = CreateRWTree(mockTopPath, self.__testout) def testCopySiteConfig(self): """Tests creation site-config""" self.__crw.createtree(["site-config"]) self.assertTrue( os.path.exists(os.path.join(self.__testout, "site-config"))) def testCopyActionData(self): """Test creation of actiondata.xml""" self.__crw.createtree(["actiondata"]) self.assertTrue( os.path.exists( os.path.join(self.__testout, "da_top", "resources_ro", "actionData.xml"))) def testCopyMultiData(self): """Test creation of multiple items""" dstdir = os.path.join(self.__testout, "da_top", "webapps") if os.path.exists(dstdir): shutil.rmtree(dstdir) self.__crw.createtree([ "depuiresources", "emdresources", "wsresources", ["webapps", "msgmodule"] ]) self.assertTrue( os.path.exists( os.path.join(self.__testout, "da_top", "resources_ro", "depui"))) self.assertTrue( os.path.exists( os.path.join(self.__testout, "da_top", "resources_ro", "emd"))) self.assertTrue( os.path.exists( os.path.join(self.__testout, "da_top", "resources_ro", "content_ws"))) self.assertTrue( os.path.exists( os.path.join(self.__testout, "da_top", "webapps", "htdocs", "msgmodule"))) self.assertTrue( os.path.exists( os.path.join(self.__testout, "da_top", "webapps", "version.json"))) def testCopyVersionOnly(self): """Test creation of version.json webapps""" dstdir = os.path.join(self.__testout, "da_top", "webapps") if os.path.exists(dstdir): shutil.rmtree(dstdir) self.__crw.createtree(["webapps"]) self.assertFalse( os.path.exists(os.path.join(dstdir, "htdocs", "msgmodule"))) self.assertTrue(os.path.exists(os.path.join(dstdir, "version.json"))) def testCopyArchiveData(self): """Test creation of archive data""" self.__crw.createtree([["archive", "D_000001"]]) self.assertTrue( os.path.exists( os.path.join(self.__testout, "da_top", "data", "archive", "D_000001"))) def testCopyUnknown(self): """Test creation to log error""" self.__crw.createtree(["nothing"])