From bd4b28abe23aafb100992ec02b0d4a84f4762f50 Mon Sep 17 00:00:00 2001 From: Ghazi Sarwat Syed Date: Fri, 28 Jun 2024 07:07:22 +0000 Subject: [PATCH] modified unit tests, readme --- .github/workflows/unittests.yml | 2 +- README.md | 2 +- fmperf/tests/test_import.py | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 fmperf/tests/test_import.py diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 267699b..d897137 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -24,4 +24,4 @@ jobs: - name: Run tests run: | - pytest fmperf/tests/test_imports.py \ No newline at end of file + pytest fmperf/tests/ \ No newline at end of file diff --git a/README.md b/README.md index e6988f1..82a2f09 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Firstly, one can generate a set of requests assuming simple uniform distribution ```bash docker run --env-file .env -it --rm -v $(pwd)/requests:/requests fmperf python -m fmperf.loadgen.generate-input ``` -Alternatively, one can generate a set of requests using models that have been trained on requests sent to the internal production deployment of BAM: +Alternatively, one can generate a set of requests using models that have been trained on requests sent to a production deployment: ```bash docker run --env-file .env -it --rm -v $(pwd)/requests:/requests fmperf python -m fmperf.loadgen.generate-input --from-model ``` diff --git a/fmperf/tests/test_import.py b/fmperf/tests/test_import.py new file mode 100644 index 0000000..11fed94 --- /dev/null +++ b/fmperf/tests/test_import.py @@ -0,0 +1,32 @@ +import unittest +import logging + + +# Configure logging +logging.basicConfig(filename='test_logs.log', level=logging.DEBUG, + format='%(asctime)s %(levelname)s:%(message)s', filemode='w') +logging.debug('Logging configured successfully') + +# Test class to check if the imports are working for the files in the examples folder +class TestImports(unittest.TestCase): + def setUp(self): + # Setup code goes here + logging.info("Running a test case.") + + def tearDown(self): + # Teardown code can go here, if we needed to clean up after tests + pass + + def test_fmperf_import(self): + """Test if fmperf import works correctly.""" + try: + import fmperf + self.assertIsNotNone(fmperf) + logging.info("test_fmperf_import passed.") + except Exception as e: + logging.error(f"test_fmperf_import failed: {e}") + raise + +if __name__ == '__main__': + unittest.main() + logging.getLogger().handlers[0].flush()