From bc7e6566563d95c04de4542fe6470dc3e925f962 Mon Sep 17 00:00:00 2001 From: shachar2000 <158807303+shachar2000@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:19:54 +0300 Subject: [PATCH] Provide Unit Test For Displaying Statistics Feature (#28) --- test_statistic.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test_statistic.py diff --git a/test_statistic.py b/test_statistic.py new file mode 100644 index 00000000..d4359c59 --- /dev/null +++ b/test_statistic.py @@ -0,0 +1,24 @@ +# ------------------------------------------ Test intro ------------------------------------------ # +# The test verifies that the calculate_percentages method correctly calculates and returns the +# percentage distribution of images in a Kubernetes cluster (kind-cluster1). It ensures the output +# consists of strings, integers, and floats in the expected format. +# ------------------------------------------ Test intro ------------------------------------------ # + +from src.disko.image_collector import * + +# Create db from cluster +create_db = ImageCollector().collect_images("kind-cluster1") + +# Import image_controller.py to use any function on my db file +ctl1 = ImageController("image_data.db") + + +# Testing the calculation of the percentages of the images +def test_calculate_percentages(): + output = ctl1.calculate_percentages("kind-cluster1") + print(output) + for item in output: + if not isinstance(item[0], str): assert False + if not isinstance(item[1], int): assert False + if not isinstance(item[2], float): assert False + assert True \ No newline at end of file