Skip to content

Commit

Permalink
fixing test_provider.py
Browse files Browse the repository at this point in the history
  • Loading branch information
XaverStiensmeier committed Nov 14, 2023
1 parent 4442c1b commit f5532e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 5 additions & 3 deletions tests/provider/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import os
import unittest
import logging

import bibigrid.core.utility.handler.configuration_handler as configurationHandler
import bibigrid.core.utility.handler.provider_handler as providerHandler
Expand Down Expand Up @@ -61,9 +62,9 @@
"MFbUTTukAiDf4jAgvJkg7ayE0MPapGpI/OhSK2gyN45VAzs2m7uykun87B491JagZ57qr16vt8vxGYpFCEe8QqAcrUszUPqyPrb0auA8bz" \
"jO8S41Kx8FfG+7eTu4dQ0= user"

CONFIGURATIONS = configurationHandler.read_configuration(
CONFIGURATIONS = configurationHandler.read_configuration(logging,
os.path.join(bP.ROOT_PATH, "tests/resources/infrastructure_cloud.yml"))
PROVIDERS = providerHandler.get_providers(CONFIGURATIONS)
PROVIDERS = providerHandler.get_providers(CONFIGURATIONS, logging)


class ProviderServer:
Expand Down Expand Up @@ -95,6 +96,7 @@ def test_get_free_resources(self):
with self.subTest(provider.NAME):
free_dict = provider.get_free_resources()
self.assertEqual(FREE_RESOURCES_KEYS, set(free_dict.keys()))
print(free_dict)
for value in free_dict.values():
self.assertLessEqual(0, value)

Expand Down Expand Up @@ -209,7 +211,7 @@ def test_get_image_mismatch(self):
with self.subTest(provider.NAME):
self.assertIsNone(provider.get_image_by_id_or_name("NONE"))

if os.environ.get("OS_SNAPSHOT"):
if CONFIGURATIONS[0].get("snapshot_image"):
def test_get_snapshot(self):
for provider, configuration in zip(PROVIDERS, CONFIGURATIONS):
with self.subTest(provider.NAME):
Expand Down
13 changes: 6 additions & 7 deletions tests/startup_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ def suppress_stdout():
logging.basicConfig(level=logging.ERROR)
if __name__ == '__main__':
# Unittests
suite = unittest.TestLoader().discover("./", pattern='test_*.py')
with suppress_stdout():
unittest.TextTestRunner(verbosity=2).run(suite)
#suite = unittest.TestLoader().discover("./", pattern='test_*.py')
#with suppress_stdout():
# unittest.TextTestRunner(verbosity=2).run(suite)

# Provider-Test
# Configuration needs to contain providers and infrastructures
if os.environ.get("OS_KEY_NAME"):
suite = unittest.TestLoader().discover("./provider", pattern='test_*.py')
with suppress_stdout():
unittest.TextTestRunner(verbosity=2).run(suite)
suite = unittest.TestLoader().discover("./provider", pattern='test_*.py')
with suppress_stdout():
unittest.TextTestRunner(verbosity=2).run(suite)

0 comments on commit f5532e7

Please sign in to comment.