class TestEPLaunch_Run(object): """tests for eplaunch_run""" def setup(self): runfolder = "runfolder" self.runpath = os.path.join(THIS_DIR, runfolder) if os.path.exists(self.runpath): shutil.rmtree(self.runpath) os.mkdir(self.runpath) runidffile = os.path.join(self.runpath, TEST_IDF_NAME) shutil.copy(fname1, runidffile) self.idf = modeleditor.IDF(runidffile, TEST_EPW) expected_files = [ "{}.audit", "{}.eso", "{}.shd", "{}.bnd", "{}.idf", "{}Sqlite.err", "{}.eio", "{}.mdd", "{}Table.htm", "{}.end", "{}.mtd", "{}.err", "{}.rdd", ] idf_noext = TEST_IDF_NAME.split(".")[0] self.expected_files = [ expected_file.format(idf_noext) for expected_file in expected_files ] @pytest.mark.skipif(not do_integration_tests(), reason="$EPPY_INTEGRATION env var not set") def test_eplaunch_run(self): """py.test for eplaunch_run""" eplaunch_run(self.idf) files = os.listdir(self.runpath) assert set(files) == set(self.expected_files) def teardown(self): shutil.rmtree(self.runpath)
def test_cleanupversion(): """py.test for cleanupversion""" data = ( ('8.8.0', '8.8.0'), # ver, expected ('8.8.1', '8.8.0'), # ver, expected ('8.8', '8.8.0'), # ver, expected ('8', '8.0.0'), # ver, expected ('', '.0.0'), # ver, expected ) for ver, expected in data: result = easyopen.cleanupversion(ver) assert result == expected @pytest.mark.skipif( not do_integration_tests(), reason="$EPPY_INTEGRATION env var not set") def test_easyopen(): """py.test for easyopen""" ver = latestidd() txt, result = (" Version,{};".format(ver), '{}'.format(ver)) fhandle = StringIO(txt) reload(modeleditor) reload(easyopen) idf = easyopen.easyopen(fhandle) versions = idf.idfobjects['version'.upper()] version = versions[0] ver = version.Version_Identifier assert result == ver # test with epw=weatherfile fhandle = StringIO(txt) epwname = 'weatherfile.epw'
# We need to reload modeleditor since the IDF class may have had an IDD # which causes problems. # https://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module reload(modeleditor) iddfile = os.path.join(IDD_FILES, TEST_IDD) fname1 = os.path.join(IDF_FILES, TEST_IDF) modeleditor.IDF.setiddname(iddfile, testing=True) idf = modeleditor.IDF(fname1, TEST_EPW) ep_version = idf.idd_version assert ep_version == versiontuple(VERSION) ep_version = modeleditor.IDF.idd_version assert ep_version == versiontuple(VERSION) # reload(modeleditor) @pytest.mark.skipif(not do_integration_tests(), reason="$EPPY_INTEGRATION env var not set") class TestEnvironment(object): """ Test that the environment has been correctly set up with EnergyPlus in the default location. """ def test_thisdir_exists(self): """Make sure we are starting from the correct path.""" assert os.path.isdir(THIS_DIR) def test_iddfiles_exists(self): """Test the IDD files are where we expect them.""" assert os.path.isdir(IDD_FILES)
def getversion(idf): """return the version number""" versions = idf.idfobjects['VERSION'] return versions[0].Version_Identifier def setversion(idf, newversion): """set the version number""" versions = idf.idfobjects['VERSION'] versions[0].Version_Identifier = newversion @pytest.mark.skipif( not do_integration_tests(), reason="$EPPY_INTEGRATION env var not set") class TestModeleditorIntegration(): def setup(self): """Set the IDD and file paths, and make a copy of the original file. """ iddfile = os.path.join(IDD_FILES, "Energy+V7_2_0.idd") IDF.setiddname(iddfile, testing=True) self.origfile = os.path.join(INTEGRATION_FILES, "origfile.idf") #set tempfile names self.startfile = os.path.join(INTEGRATION_FILES, "startfile.idf") self.saveasfile = os.path.join(INTEGRATION_FILES, "saveas.idf") self.copyfile = os.path.join(INTEGRATION_FILES, "savecopy.idf")