Coverage for tests\constraints\test_factory.py: 100.00%
10 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/constraints/test_factory.py
5* Description: Unittests for the `constraints.factory` module.
6* Author: Erwan SCHILD
7* Created: 17/03/2021
8* Licence: CeCILL (https://cecill.info/licences.fr.html)
9"""
11# ==============================================================================
12# IMPORT PYTHON DEPENDENCIES
13# ==============================================================================
15import pytest
17from cognitivefactory.interactive_clustering.constraints.binary import BinaryConstraintsManager
18from cognitivefactory.interactive_clustering.constraints.factory import managing_factory
21# ==============================================================================
22# test_managing_factory_for_not_implemented_constraints_manager
23# ==============================================================================
24def test_managing_factory_for_not_implemented_constraints_manager():
25 """
26 Test that the `constraints.factory.managing_factory` method raises an `ValueError` for not implemented constraints manager.
27 """
29 # Check `ValueError` for bad string value for `manager`.
30 with pytest.raises(ValueError, match="`manager`"):
31 managing_factory(manager="unknown", list_of_data_IDs=["first", "second", "third"])
34# ==============================================================================
35# test_managing_factory_for_binary_constraints_manager
36# ==============================================================================
37def test_managing_factory_for_binary_constraints_manager():
38 """
39 Test that the `constraints.factory.managing_factory` can initialize an instance of `BinaryConstraintsManager`.
40 """
42 # Check `hierarchical` clustering.
43 constraints_manager = managing_factory(algorithm="binary", list_of_data_IDs=["first", "second", "third"])
44 assert isinstance(constraints_manager, BinaryConstraintsManager)