Coverage for tests\sampling\test_cluster_based.py: 100.00%
15 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-17 13:31 +0100
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-17 13:31 +0100
1# -*- coding: utf-8 -*-
3"""
4* Name: interactive-clustering/tests/sampling/test_cluster_based.py
5* Description: Unittests for the `sampling.cluster_based` module.
6* Author: Erwan SCHILD
7* Created: 04/10/2021
8* Licence: CeCILL (https://cecill.info/licences.fr.html)
9"""
11# ==============================================================================
12# IMPORT PYTHON DEPENDENCIES
13# ==============================================================================
15import pytest
17from cognitivefactory.interactive_clustering.sampling.clusters_based import ClustersBasedConstraintsSampling
20# ==============================================================================
21# test_cluster_based_for_incorrect_clusters_restriction_parameter
22# ==============================================================================
23def test_cluster_based_for_incorrect_clusters_restriction_parameter():
24 """
25 Test that the `sampling.cluster_based.ClustersBasedConstraintsSampling` initialization raises an `ValueError` for incorrect `clusters_restriction` parameter.
26 """
28 # Check `ValueError` for bad string value for `clusters_restriction`.
29 with pytest.raises(ValueError, match="`clusters_restriction`"):
30 ClustersBasedConstraintsSampling(
31 clusters_restriction="unknown",
32 )
35# ==============================================================================
36# test_cluster_based_for_incorrect_distance_restriction_parameter
37# ==============================================================================
38def test_cluster_based_for_incorrect_distance_restriction_parameter():
39 """
40 Test that the `sampling.cluster_based.ClustersBasedConstraintsSampling` initialization raises an `ValueError` for incorrect `distance_restriction` parameter.
41 """
43 # Check `ValueError` for bad string value for `distance_restriction`.
44 with pytest.raises(ValueError, match="`distance_restriction`"):
45 ClustersBasedConstraintsSampling(
46 distance_restriction="unknown",
47 )
50# ==============================================================================
51# test_cluster_based_for_incorrect_without_added_constraints_parameter
52# ==============================================================================
53def test_cluster_based_for_incorrect_without_added_constraints_parameter():
54 """
55 Test that the `sampling.cluster_based.ClustersBasedConstraintsSampling` initialization raises an `ValueError` for incorrect `without_added_constraints` parameter.
56 """
58 # Check `ValueError` for bad string value for `without_added_constraints`.
59 with pytest.raises(ValueError, match="`without_added_constraints`"):
60 ClustersBasedConstraintsSampling(
61 without_added_constraints="unknown",
62 )
65# ==============================================================================
66# test_cluster_based_for_incorrect_without_inferred_constraints_parameter
67# ==============================================================================
68def test_cluster_based_for_incorrect_without_inferred_constraints_parameter():
69 """
70 Test that the `sampling.cluster_based.ClustersBasedConstraintsSampling` initialization raises an `ValueError` for incorrect `without_inferred_constraints` parameter.
71 """
73 # Check `ValueError` for bad string value for `without_inferred_constraints`.
74 with pytest.raises(ValueError, match="`without_inferred_constraints`"):
75 ClustersBasedConstraintsSampling(
76 without_inferred_constraints="unknown",
77 )