Skip to content

Commit

Permalink
fixed tests failing
Browse files Browse the repository at this point in the history
  • Loading branch information
feyruzb committed Sep 2, 2024
1 parent f9057be commit 38ee1a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
22 changes: 12 additions & 10 deletions web/server/codechecker_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,24 +921,26 @@ def get_if_database_in_use(self, product_connection_string):
"""
# get the database name from the product connection string
to_add = product_connection_string.database
LOG.info("The database string that will be added: %s", to_add)

if str(product_connection_string.engine) == "sqlite":
to_add = str(to_add).rsplit('/', maxsplit=1)[-1]
if to_add.endswith('.sqlite'):
to_add = to_add[:-7]
# if str(product_connection_string.engine) == "sqlite":
# to_add = str(to_add).rsplit('/', maxsplit=1)[-1]
# if to_add.endswith('.sqlite'):
# to_add = to_add[:-7]
LOG.info("to add: %s", to_add)

# get the current state of connected databases from products
dynamic_list = [
a.connection.split("/")[-1].split('?')[0]
a.connection
for a in self.cfg_sess_private.query(ORMProduct).all()
]

# log dynamic list
LOG.info("dynamic list: %s", dynamic_list)
dynamic_list = [
d[:-7] if d.endswith('.sqlite') else d
for d in dynamic_list
]
# LOG.info("dynamic list: %s", dynamic_list)
# dynamic_list = [
# d[:-7] if d.endswith('.sqlite') else d
# for d in dynamic_list
# ]
LOG.info("dynamic list: %s", dynamic_list)

return to_add in dynamic_list # True if found, False otherwise
Expand Down
10 changes: 5 additions & 5 deletions web/tests/functional/products/test_config_db_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def create_test_product(product_name, product_endpoint):
username_b64='',
password_b64='',
database=os.path.join(self.test_workspace_secondary,
'data_test.sqlite')))
'data.sqlite')))

product_cfg = create_test_product('producttest_second',
'producttest_second')
Expand All @@ -171,8 +171,8 @@ def create_test_product(product_name, product_endpoint):
product_cfg = create_test_product('producttest_second 2',
'producttest_second_2')

with self.assertRaises(RequestFailed):
self._pr_client_2.addProduct(product_cfg)
self.assertTrue(self._pr_client_2.addProduct(product_cfg),
"Cannot create product on secondary server.")

# Product name full string match.
products = self._pr_client_2.getProducts('producttest_second', None)
Expand All @@ -184,10 +184,10 @@ def create_test_product(product_name, product_endpoint):

# Product name substring match.
products = self._pr_client_2.getProducts('producttest_second*', None)
self.assertEqual(len(products), 1)
self.assertEqual(len(products), 2)

products = self._pr_client_2.getProducts(None, 'producttest_second*')
self.assertEqual(len(products), 1)
self.assertEqual(len(products), 2)

# Use the same CodeChecker config that was used on the main server,
# but store into the secondary one.
Expand Down

0 comments on commit 38ee1a1

Please sign in to comment.