Skip to content

Commit

Permalink
#929: fix .NET tests, fix Bingo tests that require importing targets …
Browse files Browse the repository at this point in the history
…data
  • Loading branch information
mkviatkovskii authored and Mikalai Sukhikh committed Jan 17, 2023
1 parent 3a39fe8 commit 65d7654
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
5 changes: 4 additions & 1 deletion api/tests/integration/common/thread_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ def cpu_count():
import java

return java.lang.Runtime.getRuntime().availableProcessors()
elif sys.platform == "cli":
elif sys.platform == "cli" or (
"implementation" in dir(sys)
and sys.implementation.name == "ironpython"
):
import System.Environment

return System.Environment.ProcessorCount
Expand Down
5 changes: 4 additions & 1 deletion api/tests/integration/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def overridePlatform(platform):


def isIronPython():
return sys.platform == "cli" or ('implementation' in dir(sys) and sys.implementation.name == "ironpython")
return sys.platform == "cli" or (
"implementation" in dir(sys)
and sys.implementation.name == "ironpython"
)


def isJython():
Expand Down
14 changes: 9 additions & 5 deletions bingo/tests/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from enum import Enum
from os.path import abspath

from indigo import Indigo

TEST_CASES_DATA = {
"mass": "data/molecules/mass/std.json",
"gross": "data/molecules/gross/std.json",
Expand Down Expand Up @@ -118,12 +120,14 @@

MOL_FILES_EXTENSIONS = ["sdf", "smi", ".sma", "smiles", "rdf"]


indigo = Indigo()
IMPORT_FUNCTION_MAP = {
".sdf": "importSDF",
".smi": "importSMILES",
".smiles": "importSMILES",
".sma": "importSMILES",
".rdf": "importRDF",
".sdf": indigo.iterateSDFile,
".smi": indigo.iterateSmilesFile,
".smiles": indigo.iterateSmilesFile,
".sma": indigo.iterateSmilesFile,
".rdf": indigo.iterateRDFile,
}

DB_POSTGRES = "postgres"
Expand Down
21 changes: 10 additions & 11 deletions bingo/tests/dbc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,19 @@ def import_data(self, import_meta: Dict[str, str], other_columns=""):
logger.debug(
f"Importing data to table {table} from src: {import_path}"
)
import_path = import_path.replace("\\", "/")
dml_query = (
"SELECT {bingo}.{function}('{test_schema}.{table}', "
"'data', '{other_columns}', '{file}')"
)
dml_query = dml_query.format(
bingo=self.bingo_schema,
function=function,
# We have to avoid using bingo.import functions because we might
# work with remote server and cannot use local files
query = "INSERT INTO {test_schema}.{table}(data) VALUES {items}"
items_str = ",".join((
"('{}')".format(item.rawData())
for item in function(import_path)
))
query = query.format(
test_schema=self.test_schema,
table=table,
other_columns=other_columns,
file=import_path,
items=items_str
)
self._execute_dml_query(dml_query)
self._execute_dml_query(query)

def create_indices(self, tables: List[str]):
"""
Expand Down

0 comments on commit 65d7654

Please sign in to comment.