Coverage for tests\clustering\test_abstract.py: 100.00%
8 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/clustering/test_abstract.py
5* Description: Unittests for the `clustering.abstract` 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.clustering.abstract import (
18 AbstractConstrainedClustering,
19 rename_clusters_by_order,
20)
23# ==============================================================================
24# test_AbstractConstrainedClustering_is_abstract
25# ==============================================================================
26def test_AbstractConstrainedClustering_is_abstract():
27 """
28 Test that the `clustering.abstract.AbstractConstrainedClustering` class is abstract.
29 """
31 # Check `TypeError` for initialization of `AbstractConstrainedClustering`.
32 with pytest.raises(TypeError, match="Can't instantiate abstract class"):
33 AbstractConstrainedClustering()
36# ==============================================================================
37# test_rename_clusters_by_order
38# ==============================================================================
39def test_rename_clusters_by_order():
40 """
41 Test that the `clustering.abstract.test_rename_clusters_by_order` mathod works.
42 """
44 assert rename_clusters_by_order(clusters={"d": 2, "b": 0, "a": 1, "e": 0, "c": 1}) == {
45 "a": 0,
46 "b": 1,
47 "c": 0,
48 "d": 2,
49 "e": 1,
50 }