krkn-lib 5.1.13__py3-none-any.whl → 6.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. krkn_lib/aws_tests/__init__.py +1 -1
  2. krkn_lib/elastic/krkn_elastic.py +3 -1
  3. krkn_lib/k8s/krkn_kubernetes.py +72 -58
  4. krkn_lib/k8s/pod_monitor/__init__.py +1 -2
  5. krkn_lib/k8s/pod_monitor/pod_monitor.py +7 -5
  6. krkn_lib/k8s/templates/snapshot.j2 +1 -1
  7. krkn_lib/models/elastic/models.py +1 -1
  8. krkn_lib/models/k8s/models.py +1 -1
  9. krkn_lib/models/pod_monitor/models.py +2 -2
  10. krkn_lib/ocp/krkn_openshift.py +4 -4
  11. krkn_lib/prometheus/krkn_prometheus.py +1 -1
  12. krkn_lib/telemetry/k8s/krkn_telemetry_kubernetes.py +1 -1
  13. krkn_lib/telemetry/ocp/krkn_telemetry_openshift.py +1 -1
  14. krkn_lib/tests/base_test.py +4 -4
  15. krkn_lib/tests/test_krkn_elastic_models.py +2 -4
  16. krkn_lib/tests/test_krkn_kubernetes_check.py +3 -2
  17. krkn_lib/tests/test_krkn_kubernetes_create.py +5 -3
  18. krkn_lib/tests/test_krkn_kubernetes_delete.py +3 -2
  19. krkn_lib/tests/test_krkn_kubernetes_get.py +5 -4
  20. krkn_lib/tests/test_krkn_kubernetes_misc.py +3 -3
  21. krkn_lib/tests/test_krkn_kubernetes_models.py +1 -1
  22. krkn_lib/tests/test_krkn_kubernetes_pods_monitor_models.py +3 -4
  23. krkn_lib/tests/test_krkn_kubernetes_virt.py +91 -146
  24. krkn_lib/tests/test_krkn_openshift.py +7 -6
  25. krkn_lib/tests/test_krkn_telemetry_kubernetes.py +1 -3
  26. krkn_lib/tests/test_safe_logger.py +3 -1
  27. krkn_lib/tests/test_utils.py +4 -5
  28. krkn_lib/utils/functions.py +4 -3
  29. krkn_lib/version/version.py +5 -2
  30. {krkn_lib-5.1.13.dist-info → krkn_lib-6.0.1.dist-info}/METADATA +5 -9
  31. {krkn_lib-5.1.13.dist-info → krkn_lib-6.0.1.dist-info}/RECORD +33 -33
  32. {krkn_lib-5.1.13.dist-info → krkn_lib-6.0.1.dist-info}/WHEEL +1 -1
  33. {krkn_lib-5.1.13.dist-info/licenses → krkn_lib-6.0.1.dist-info}/LICENSE +0 -0
@@ -1,10 +1,10 @@
1
- from krkn_lib.models.krkn import HogConfig, HogType
2
1
  from krkn_lib.models.k8s import (
3
2
  AffectedNode,
4
3
  AffectedNodeStatus,
5
4
  AffectedPod,
6
5
  PodsStatus,
7
6
  )
7
+ from krkn_lib.models.krkn import HogConfig, HogType
8
8
  from krkn_lib.tests import BaseTest
9
9
 
10
10
 
@@ -1,13 +1,12 @@
1
1
  import time
2
2
  import unittest
3
3
 
4
-
5
- from krkn_lib.models.k8s import PodsStatus, AffectedPod
4
+ from krkn_lib.models.k8s import AffectedPod, PodsStatus
6
5
  from krkn_lib.models.pod_monitor.models import (
7
- PodEvent,
8
- PodStatus,
9
6
  MonitoredPod,
7
+ PodEvent,
10
8
  PodsSnapshot,
9
+ PodStatus,
11
10
  )
12
11
 
13
12
 
@@ -1,6 +1,39 @@
1
+ #!/usr/bin/env python3
2
+
3
+
4
+ """
5
+ Test suite for KubeVirt/virtualization-related functionality in KrknKubernetes
6
+
7
+ This test suite covers KubeVirt-specific methods in the KrknKubernetes class,
8
+ including operations on VirtualMachines (VMs), VirtualMachineInstances (VMIs),
9
+ and VirtualMachineSnapshots.
10
+
11
+ Tested functionality:
12
+ - VM operations: get, list, delete, patch
13
+ - VMI operations: get, list, create, delete, patch
14
+ - Snapshot operations: get, create, delete
15
+
16
+ Usage:
17
+ # Run all tests in this file
18
+ python -m unittest src.krkn_lib.tests.test_krkn_kubernetes_virt -v
19
+
20
+ # Run a specific test class
21
+ python -m unittest src.krkn_lib.tests.test_krkn_kubernetes_virt.TestKrknKubernetesVirt -v
22
+
23
+ # Run a specific test method
24
+ python -m unittest src.krkn_lib.tests.test_krkn_kubernetes_virt.TestKrknKubernetesVirt.test_get_vm_success -v
25
+
26
+ # Run with coverage
27
+ python -m coverage run -a -m unittest src.krkn_lib.tests.test_krkn_kubernetes_virt -v
28
+
29
+ Assisted By: Claude Code
30
+ """ # NOQA
31
+
1
32
  import unittest
2
- from unittest.mock import patch, MagicMock, PropertyMock
33
+ from unittest.mock import MagicMock, PropertyMock, patch
34
+
3
35
  from kubernetes.client.rest import ApiException
36
+
4
37
  from krkn_lib.k8s.krkn_kubernetes import KrknKubernetes
5
38
 
6
39
 
@@ -171,9 +204,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
171
204
  return_value=[namespace],
172
205
  ):
173
206
  # Configure the mock to return vmis
174
- mock_list = (
175
- self.mock_custom_client.list_namespaced_custom_object
176
- )
207
+ mock_list = self.mock_custom_client.list_namespaced_custom_object
177
208
  mock_list.return_value = vmis_response
178
209
 
179
210
  # get_vmis returns a list
@@ -198,9 +229,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
198
229
  return_value=[namespace],
199
230
  ):
200
231
  # Configure the mock to raise 404
201
- mock_list = (
202
- self.mock_custom_client.list_namespaced_custom_object
203
- )
232
+ mock_list = self.mock_custom_client.list_namespaced_custom_object
204
233
  mock_list.side_effect = api_exception
205
234
 
206
235
  result = self.lib_k8s.get_vmis(regex_name, namespace)
@@ -224,9 +253,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
224
253
  return_value=namespaces,
225
254
  ):
226
255
  # Configure mock for different responses
227
- mock_list = (
228
- self.mock_custom_client.list_namespaced_custom_object
229
- )
256
+ mock_list = self.mock_custom_client.list_namespaced_custom_object
230
257
  mock_list.side_effect = [
231
258
  vmis_response_1,
232
259
  vmis_response_2,
@@ -264,9 +291,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
264
291
  return_value=[namespace],
265
292
  ):
266
293
  # Configure the mock to return vms
267
- mock_list = (
268
- self.mock_custom_client.list_namespaced_custom_object
269
- )
294
+ mock_list = self.mock_custom_client.list_namespaced_custom_object
270
295
  mock_list.return_value = vms_response
271
296
 
272
297
  result = self.lib_k8s.get_vms(regex_name, namespace)
@@ -289,9 +314,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
289
314
  return_value=[namespace],
290
315
  ):
291
316
  # Configure the mock to raise 404
292
- mock_list = (
293
- self.mock_custom_client.list_namespaced_custom_object
294
- )
317
+ mock_list = self.mock_custom_client.list_namespaced_custom_object
295
318
  mock_list.side_effect = api_exception
296
319
 
297
320
  result = self.lib_k8s.get_vms(regex_name, namespace)
@@ -314,9 +337,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
314
337
  return_value=namespaces,
315
338
  ):
316
339
  # Configure mock for different responses
317
- mock_list = (
318
- self.mock_custom_client.list_namespaced_custom_object
319
- )
340
+ mock_list = self.mock_custom_client.list_namespaced_custom_object
320
341
  mock_list.side_effect = [
321
342
  vms_response_1,
322
343
  vms_response_2,
@@ -338,9 +359,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
338
359
  }
339
360
 
340
361
  # Configure the mock to return expected response
341
- mock_delete = (
342
- self.mock_custom_client.delete_namespaced_custom_object
343
- )
362
+ mock_delete = self.mock_custom_client.delete_namespaced_custom_object
344
363
  mock_delete.return_value = expected_response
345
364
 
346
365
  result = self.lib_k8s.delete_vm(vm_name, namespace)
@@ -361,9 +380,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
361
380
  api_exception = ApiException(status=404)
362
381
 
363
382
  # Configure the mock to raise 404
364
- mock_delete = (
365
- self.mock_custom_client.delete_namespaced_custom_object
366
- )
383
+ mock_delete = self.mock_custom_client.delete_namespaced_custom_object
367
384
  mock_delete.side_effect = api_exception
368
385
 
369
386
  result = self.lib_k8s.delete_vm(vm_name, namespace)
@@ -376,9 +393,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
376
393
  api_exception = ApiException(status=500)
377
394
 
378
395
  # Configure the mock to raise 500
379
- mock_delete = (
380
- self.mock_custom_client.delete_namespaced_custom_object
381
- )
396
+ mock_delete = self.mock_custom_client.delete_namespaced_custom_object
382
397
  mock_delete.side_effect = api_exception
383
398
 
384
399
  with self.assertRaises(ApiException):
@@ -389,27 +404,21 @@ class TestKrknKubernetesVirt(unittest.TestCase):
389
404
  vmi_name = "test-vmi"
390
405
  namespace = "test-ns"
391
406
 
392
- # Mock logging
393
- with patch("krkn_lib.k8s.krkn_kubernetes.logging") as mock_logging:
394
- # Configure the mock to return None (success)
395
- mock_delete = (
396
- self.mock_custom_client.delete_namespaced_custom_object
397
- )
398
- mock_delete.return_value = None
399
-
400
- result = self.lib_k8s.delete_vmi(vmi_name, namespace)
401
-
402
- mock_delete.assert_called_once_with(
403
- group="kubevirt.io",
404
- version="v1",
405
- namespace=namespace,
406
- plural="virtualmachineinstances",
407
- name=vmi_name,
408
- )
409
- # delete_vmi doesn't explicitly return on success (returns None)
410
- self.assertIsNone(result)
411
- # Verify logging was called
412
- mock_logging.info.assert_called_once()
407
+ # Configure the mock to return None (success)
408
+ mock_delete = self.mock_custom_client.delete_namespaced_custom_object
409
+ mock_delete.return_value = None
410
+
411
+ result = self.lib_k8s.delete_vmi(vmi_name, namespace)
412
+
413
+ mock_delete.assert_called_once_with(
414
+ group="kubevirt.io",
415
+ version="v1",
416
+ namespace=namespace,
417
+ plural="virtualmachineinstances",
418
+ name=vmi_name,
419
+ )
420
+ # delete_vmi doesn't explicitly return on success (returns None)
421
+ self.assertIsNone(result)
413
422
 
414
423
  def test_delete_vmi_not_found(self):
415
424
  """Test delete_vmi returns 1 when VMI doesn't exist"""
@@ -417,17 +426,13 @@ class TestKrknKubernetesVirt(unittest.TestCase):
417
426
  namespace = "test-ns"
418
427
  api_exception = ApiException(status=404)
419
428
 
420
- # Mock logging
421
- with patch("krkn_lib.k8s.krkn_kubernetes.logging"):
422
- # Configure the mock to raise 404
423
- mock_delete = (
424
- self.mock_custom_client.delete_namespaced_custom_object
425
- )
426
- mock_delete.side_effect = api_exception
429
+ # Configure the mock to raise 404
430
+ mock_delete = self.mock_custom_client.delete_namespaced_custom_object
431
+ mock_delete.side_effect = api_exception
427
432
 
428
- result = self.lib_k8s.delete_vmi(vmi_name, namespace)
429
- # Returns 1 on 404
430
- self.assertEqual(result, 1)
433
+ result = self.lib_k8s.delete_vmi(vmi_name, namespace)
434
+ # Returns 1 on 404
435
+ self.assertEqual(result, 1)
431
436
 
432
437
  def test_delete_vmi_api_error(self):
433
438
  """Test delete_vmi returns 1 on API error"""
@@ -435,17 +440,13 @@ class TestKrknKubernetesVirt(unittest.TestCase):
435
440
  namespace = "test-ns"
436
441
  api_exception = ApiException(status=500)
437
442
 
438
- # Mock logging
439
- with patch("krkn_lib.k8s.krkn_kubernetes.logging"):
440
- # Configure the mock to raise 500
441
- mock_delete = (
442
- self.mock_custom_client.delete_namespaced_custom_object
443
- )
444
- mock_delete.side_effect = api_exception
443
+ # Configure the mock to raise 500
444
+ mock_delete = self.mock_custom_client.delete_namespaced_custom_object
445
+ mock_delete.side_effect = api_exception
445
446
 
446
- result = self.lib_k8s.delete_vmi(vmi_name, namespace)
447
- # Returns 1 on error
448
- self.assertEqual(result, 1)
447
+ result = self.lib_k8s.delete_vmi(vmi_name, namespace)
448
+ # Returns 1 on error
449
+ self.assertEqual(result, 1)
449
450
 
450
451
  def test_get_snapshot_success(self):
451
452
  """Test get_snapshot returns snapshot when it exists"""
@@ -467,10 +468,10 @@ class TestKrknKubernetesVirt(unittest.TestCase):
467
468
  result = self.lib_k8s.get_snapshot(snapshot_name, namespace)
468
469
 
469
470
  mock_get.assert_called_once_with(
470
- group="kubevirt.io",
471
- version="v1",
471
+ group="snapshot.kubevirt.io",
472
+ version="v1beta1",
472
473
  namespace=namespace,
473
- plural="VirtualMachineSnapshot",
474
+ plural="virtualmachinesnapshots",
474
475
  name=snapshot_name,
475
476
  )
476
477
  self.assertEqual(result, expected_snapshot)
@@ -506,33 +507,20 @@ class TestKrknKubernetesVirt(unittest.TestCase):
506
507
  snapshot_name = "test-snapshot"
507
508
  namespace = "test-ns"
508
509
 
509
- # Mock the logger and snapshot_name attributes
510
- self.lib_k8s.logger = MagicMock()
511
- self.lib_k8s.snapshot_name = snapshot_name
512
-
513
510
  # Configure the mock to return None (success)
514
- mock_delete = (
515
- self.mock_custom_client.delete_namespaced_custom_object
516
- )
511
+ mock_delete = self.mock_custom_client.delete_namespaced_custom_object
517
512
  mock_delete.return_value = None
518
513
 
519
514
  # Should not raise any exception
520
515
  self.lib_k8s.delete_snapshot(snapshot_name, namespace)
521
516
 
522
517
  mock_delete.assert_called_once_with(
523
- group="kubevirt.io",
524
- version="v1",
518
+ group="snapshot.kubevirt.io",
519
+ version="v1beta1",
525
520
  namespace=namespace,
526
- plural="VirtualMachineSnapshot",
521
+ plural="virtualmachinesnapshots",
527
522
  name=snapshot_name,
528
523
  )
529
- # Verify logger was called (uses self.snapshot_name, not parameter)
530
- self.lib_k8s.logger.info.assert_any_call(
531
- f"Deleting snapshot '{snapshot_name}'..."
532
- )
533
- self.lib_k8s.logger.info.assert_any_call(
534
- f"Snapshot '{snapshot_name}' deleted successfully."
535
- )
536
524
 
537
525
  def test_delete_snapshot_not_found(self):
538
526
  """Test delete_snapshot handles deletion gracefully"""
@@ -540,48 +528,26 @@ class TestKrknKubernetesVirt(unittest.TestCase):
540
528
  namespace = "test-ns"
541
529
  api_exception = ApiException(status=404)
542
530
 
543
- # Mock the logger and snapshot_name attributes
544
- self.lib_k8s.logger = MagicMock()
545
- self.lib_k8s.snapshot_name = snapshot_name
546
-
547
531
  # Configure the mock to raise 404
548
- mock_delete = (
549
- self.mock_custom_client.delete_namespaced_custom_object
550
- )
532
+ mock_delete = self.mock_custom_client.delete_namespaced_custom_object
551
533
  mock_delete.side_effect = api_exception
552
534
 
553
- # Should not raise exception, but log warning
535
+ # Should not raise exception
554
536
  self.lib_k8s.delete_snapshot(snapshot_name, namespace)
555
537
 
556
- # Verify warning was logged
557
- self.lib_k8s.logger.warning.assert_called_once()
558
- warning_call_args = self.lib_k8s.logger.warning.call_args[0][0]
559
- self.assertIn("Failed to delete snapshot", warning_call_args)
560
-
561
538
  def test_delete_snapshot_api_error(self):
562
539
  """Test delete_snapshot handles API errors gracefully"""
563
540
  snapshot_name = "test-snapshot"
564
541
  namespace = "test-ns"
565
542
  api_exception = ApiException(status=500)
566
543
 
567
- # Mock the logger and snapshot_name attributes
568
- self.lib_k8s.logger = MagicMock()
569
- self.lib_k8s.snapshot_name = snapshot_name
570
-
571
544
  # Configure the mock to raise 500
572
- mock_delete = (
573
- self.mock_custom_client.delete_namespaced_custom_object
574
- )
545
+ mock_delete = self.mock_custom_client.delete_namespaced_custom_object
575
546
  mock_delete.side_effect = api_exception
576
547
 
577
- # Should not raise exception, but log warning
548
+ # Should not raise exception
578
549
  self.lib_k8s.delete_snapshot(snapshot_name, namespace)
579
550
 
580
- # Verify warning was logged
581
- self.lib_k8s.logger.warning.assert_called_once()
582
- warning_call_args = self.lib_k8s.logger.warning.call_args[0][0]
583
- self.assertIn("Failed to delete snapshot", warning_call_args)
584
-
585
551
  def test_create_vmi_success(self):
586
552
  """Test create_vmi successfully creates a VMI"""
587
553
  vmi_name = "test-vmi"
@@ -599,9 +565,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
599
565
  }
600
566
 
601
567
  # Configure the mock to return expected_vmi
602
- mock_create = (
603
- self.mock_custom_client.create_namespaced_custom_object
604
- )
568
+ mock_create = self.mock_custom_client.create_namespaced_custom_object
605
569
  mock_create.return_value = expected_vmi
606
570
 
607
571
  result = self.lib_k8s.create_vmi(
@@ -613,7 +577,6 @@ class TestKrknKubernetesVirt(unittest.TestCase):
613
577
  version="v1",
614
578
  namespace=namespace,
615
579
  plural="virtualmachineinstances",
616
- name=vmi_name,
617
580
  body=vmi_body,
618
581
  )
619
582
  self.assertEqual(result, expected_vmi)
@@ -627,9 +590,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
627
590
  api_exception = ApiException(status=404)
628
591
 
629
592
  # Configure the mock to raise 404
630
- mock_create = (
631
- self.mock_custom_client.create_namespaced_custom_object
632
- )
593
+ mock_create = self.mock_custom_client.create_namespaced_custom_object
633
594
  mock_create.side_effect = api_exception
634
595
 
635
596
  result = self.lib_k8s.create_vmi(
@@ -646,15 +607,11 @@ class TestKrknKubernetesVirt(unittest.TestCase):
646
607
  api_exception = ApiException(status=500)
647
608
 
648
609
  # Configure the mock to raise 500
649
- mock_create = (
650
- self.mock_custom_client.create_namespaced_custom_object
651
- )
610
+ mock_create = self.mock_custom_client.create_namespaced_custom_object
652
611
  mock_create.side_effect = api_exception
653
612
 
654
613
  with self.assertRaises(ApiException):
655
- self.lib_k8s.create_vmi(
656
- vmi_name, namespace, vm_name, vmi_body
657
- )
614
+ self.lib_k8s.create_vmi(vmi_name, namespace, vm_name, vmi_body)
658
615
 
659
616
  def test_patch_vm_success(self):
660
617
  """Test patch_vm successfully patches a VM"""
@@ -672,9 +629,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
672
629
  }
673
630
 
674
631
  # Configure the mock to return expected_vm
675
- mock_patch = (
676
- self.mock_custom_client.patch_namespaced_custom_object
677
- )
632
+ mock_patch = self.mock_custom_client.patch_namespaced_custom_object
678
633
  mock_patch.return_value = expected_vm
679
634
 
680
635
  result = self.lib_k8s.patch_vm(vm_name, namespace, vm_body)
@@ -697,9 +652,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
697
652
  api_exception = ApiException(status=404)
698
653
 
699
654
  # Configure the mock to raise 404
700
- mock_patch = (
701
- self.mock_custom_client.patch_namespaced_custom_object
702
- )
655
+ mock_patch = self.mock_custom_client.patch_namespaced_custom_object
703
656
  mock_patch.side_effect = api_exception
704
657
 
705
658
  result = self.lib_k8s.patch_vm(vm_name, namespace, vm_body)
@@ -713,9 +666,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
713
666
  api_exception = ApiException(status=500)
714
667
 
715
668
  # Configure the mock to raise 500
716
- mock_patch = (
717
- self.mock_custom_client.patch_namespaced_custom_object
718
- )
669
+ mock_patch = self.mock_custom_client.patch_namespaced_custom_object
719
670
  mock_patch.side_effect = api_exception
720
671
 
721
672
  with self.assertRaises(ApiException):
@@ -740,9 +691,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
740
691
  }
741
692
 
742
693
  # Configure the mock to return expected_vmi
743
- mock_patch = (
744
- self.mock_custom_client.patch_namespaced_custom_object
745
- )
694
+ mock_patch = self.mock_custom_client.patch_namespaced_custom_object
746
695
  mock_patch.return_value = expected_vmi
747
696
 
748
697
  result = self.lib_k8s.patch_vmi(vmi_name, namespace, vmi_body)
@@ -765,9 +714,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
765
714
  api_exception = ApiException(status=404)
766
715
 
767
716
  # Configure the mock to raise 404
768
- mock_patch = (
769
- self.mock_custom_client.patch_namespaced_custom_object
770
- )
717
+ mock_patch = self.mock_custom_client.patch_namespaced_custom_object
771
718
  mock_patch.side_effect = api_exception
772
719
 
773
720
  result = self.lib_k8s.patch_vmi(vmi_name, namespace, vmi_body)
@@ -781,9 +728,7 @@ class TestKrknKubernetesVirt(unittest.TestCase):
781
728
  api_exception = ApiException(status=500)
782
729
 
783
730
  # Configure the mock to raise 500
784
- mock_patch = (
785
- self.mock_custom_client.patch_namespaced_custom_object
786
- )
731
+ mock_patch = self.mock_custom_client.patch_namespaced_custom_object
787
732
  mock_patch.side_effect = api_exception
788
733
 
789
734
  with self.assertRaises(ApiException):
@@ -23,7 +23,6 @@ from krkn_lib.ocp.krkn_openshift import KrknOpenshift
23
23
  from krkn_lib.tests import BaseTest
24
24
  from krkn_lib.utils import SafeLogger
25
25
 
26
-
27
26
  # ==============================================================================
28
27
  # UNIT TESTS (Mocked - No external dependencies)
29
28
  # ==============================================================================
@@ -256,7 +255,9 @@ class TestGetCloudInfrastructure(unittest.TestCase):
256
255
  self.assertEqual(result, "Unknown")
257
256
 
258
257
  @patch.object(KrknOpenshift, "api_client", new_callable=PropertyMock)
259
- def test_get_cloud_infrastructure_no_api_client(self, mock_api_client_prop):
258
+ def test_get_cloud_infrastructure_no_api_client(
259
+ self, mock_api_client_prop
260
+ ):
260
261
  """Test when api_client is None."""
261
262
  mock_api_client_prop.return_value = None
262
263
 
@@ -344,9 +345,7 @@ class TestGetPrometheusApiConnectionData(unittest.TestCase):
344
345
  "items": [
345
346
  {
346
347
  "metadata": {"name": "prometheus-k8s"},
347
- "spec": {
348
- "host": host
349
- },
348
+ "spec": {"host": host},
350
349
  }
351
350
  ]
352
351
  }
@@ -503,7 +502,9 @@ class TestFilterMustGatherOcpLogFolder(unittest.TestCase):
503
502
  [r"(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z).+"],
504
503
  )
505
504
 
506
- self.assertIn("Log destination dir do not exist", str(context.exception))
505
+ self.assertIn(
506
+ "Log destination dir do not exist", str(context.exception)
507
+ )
507
508
 
508
509
 
509
510
  # ==============================================================================
@@ -432,9 +432,7 @@ class TestSetParametersBase64(unittest.TestCase):
432
432
 
433
433
  try:
434
434
  scenario_telemetry = ScenarioTelemetry()
435
- self.telemetry.set_parameters_base64(
436
- scenario_telemetry, temp_path
437
- )
435
+ self.telemetry.set_parameters_base64(scenario_telemetry, temp_path)
438
436
 
439
437
  decoded = base64.b64decode(
440
438
  scenario_telemetry.parameters_base64.encode()
@@ -347,7 +347,9 @@ class TestSafeLoggerWorkerThread(unittest.TestCase):
347
347
  # Worker thread should be running
348
348
  import threading
349
349
 
350
- threads = [t for t in threading.enumerate() if t.name == "SafeLogWriter"]
350
+ threads = [
351
+ t for t in threading.enumerate() if t.name == "SafeLogWriter"
352
+ ]
351
353
  # Should have at least one SafeLogWriter thread
352
354
  self.assertGreater(len(threads), 0)
353
355
  # All SafeLogWriter threads should be daemon threads
@@ -29,11 +29,10 @@ class UtilFunctionTests(BaseTest):
29
29
  test_workdir = os.path.join(workdir_basepath, workdir)
30
30
  os.mkdir(test_workdir)
31
31
  test_string = "Tester McTesty!"
32
- with tempfile.NamedTemporaryFile(
33
- dir=test_workdir
34
- ) as src, tempfile.NamedTemporaryFile(
35
- dir=test_workdir
36
- ) as dst: # NOQA
32
+ with (
33
+ tempfile.NamedTemporaryFile(dir=test_workdir) as src,
34
+ tempfile.NamedTemporaryFile(dir=test_workdir) as dst,
35
+ ): # NOQA
37
36
  with open(src.name, "w+") as source, open(dst.name, "w+") as dest:
38
37
  encoded_test_byte = base64.b64encode(
39
38
  test_string.encode("utf-8")
@@ -25,9 +25,10 @@ def decode_base64_file(source_filename: str, destination_filename: str):
25
25
  :param source_filename: source base64 encoded file
26
26
  :param destination_filename: destination decoded file
27
27
  """
28
- with open(source_filename, "rb") as encoded_source, open(
29
- destination_filename, "wb"
30
- ) as target:
28
+ with (
29
+ open(source_filename, "rb") as encoded_source,
30
+ open(destination_filename, "wb") as target,
31
+ ):
31
32
  with Base64IO(encoded_source) as source:
32
33
  for line in source:
33
34
  target.write(line)
@@ -1,3 +1,6 @@
1
- import importlib.metadata
1
+ try:
2
+ import importlib_metadata
3
+ except ImportError:
4
+ import importlib.metadata as importlib_metadata
2
5
 
3
- __version__ = importlib.metadata.version("krkn-lib")
6
+ __version__ = importlib_metadata.version("krkn-lib")
@@ -1,19 +1,16 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: krkn-lib
3
- Version: 5.1.13
3
+ Version: 6.0.1
4
4
  Summary: Foundation library for Kraken
5
+ Home-page: https://github.com/redhat-chaos/krkn
5
6
  License: Apache-2.0
6
- License-File: LICENSE
7
7
  Author: Red Hat Chaos Team
8
- Requires-Python: >=3.9,<4.0
8
+ Requires-Python: >=3.11,<4.0
9
9
  Classifier: License :: OSI Approved :: Apache Software License
10
10
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.9
12
- Classifier: Programming Language :: Python :: 3.10
13
11
  Classifier: Programming Language :: Python :: 3.11
14
12
  Classifier: Programming Language :: Python :: 3.12
15
13
  Classifier: Programming Language :: Python :: 3.13
16
- Classifier: Programming Language :: Python :: 3.14
17
14
  Requires-Dist: PyYAML (==6.0.1)
18
15
  Requires-Dist: base64io (>=1.0.3,<2.0.0)
19
16
  Requires-Dist: coverage (>=7.6.12,<8.0.0)
@@ -31,8 +28,7 @@ Requires-Dist: requests (>=2.29.0,<3.0.0)
31
28
  Requires-Dist: sphinx-rtd-theme (>=1.2.2,<2.0.0)
32
29
  Requires-Dist: sphinxnotes-markdown-builder (>=0.5.6,<0.6.0)
33
30
  Requires-Dist: tzlocal (==5.1)
34
- Requires-Dist: wheel (>=0.42.0,<0.43.0)
35
- Project-URL: Homepage, https://github.com/redhat-chaos/krkn
31
+ Requires-Dist: wheel (==0.46.2)
36
32
  Description-Content-Type: text/markdown
37
33
 
38
34
  ![action](https://github.com/krkn-chaos/krkn-lib/actions/workflows/build.yaml/badge.svg)