def test_find_dbprops(): # Returns an absolute path with open('foo.properties', 'w') as f: f.write('bar') expected_abs_path = os.path.join(os.getcwd(), 'foo.properties') assert find_dbprops('foo.properties') == expected_abs_path os.remove('foo.properties') # Exception raised on missing file with pytest.raises(FileNotFoundError): find_dbprops('foo.properties')
def test_find_dbprops(): # Returns an absolute path expected_abs_path = Path.cwd() / 'foo.properties' # u'' here is for python2 compatibility expected_abs_path.write_text(u'bar') assert find_dbprops('foo.properties') == Path(expected_abs_path) expected_abs_path.unlink() # Exception raised on missing file with pytest.raises(FileNotFoundError): find_dbprops('foo.properties')
def __init__(self, dbprops=None, dbtype=None, jvmargs=None): start_jvm(jvmargs) self.dbtype = dbtype try: # if no dbtype is specified, launch Platform with properties file if dbtype is None: dbprops = default_dbprops_file() if dbprops is None \ else find_dbprops(dbprops) logger().info( "launching ixmp.Platform using config file at '{}'".format( dbprops)) self._jobj = java.ixmp.Platform("Python", dbprops) # if dbtype is specified, launch Platform with local database elif dbtype == 'HSQLDB': dbprops = dbprops or DEFAULT_LOCAL_DB_PATH logger().info( "launching ixmp.Platform with local {} database at '{}'". format(dbtype, dbprops)) self._jobj = java.ixmp.Platform("Python", dbprops, dbtype) else: raise ValueError('Unknown dbtype: {}'.format(dbtype)) except TypeError: msg = ("Could not launch the JVM for the ixmp.Platform." "Make sure that all dependencies of ixmp.jar" "are included in the 'ixmp/lib' folder.") logger().info(msg) raise