66# author: nbehrnd@yahoo.com
77# license: GPL v2, 2025
88# date: [2025-03-19 Wed]
9- # edit: [2025-04-17 Thu ]
9+ # edit: [2025-08-01 Fri ]
1010
1111"""pytest script of datawarrior_clustersort.py
1212
2929
3030
3131@pytest .mark .imported
32- def test_file_reader ():
32+ def test_file_reader () -> None :
33+ """Check recognizing headline, table body, DW's lowest cluster label."""
3334 probe_data = r"""Structure [idcode] Cluster No Is Representative record_number
3435edR\FD@KFncOLbji`HbHHrJIJYKJYSQRJiSIQITLRJ@pp@@DtuKMMP@@PARBj@ 1 No 1
3536elRRF@@DLCH`FMLfilbbRbrTVtTTRbtqbRRJzAQZijfhHbbZBA@@@@ 2 No 2
@@ -50,16 +51,21 @@ def test_file_reader():
5051
5152
5253@pytest .mark .imported
53- def test_identify_cluster_column ():
54- """identification of the cluster column"""
54+ def test_identify_cluster_column () -> None :
55+ """Check identification of the cluster column. """
5556 input_string = "Structure [idcode] Cluster No Is Representative record_number"
5657 expected_column = 1
5758 test_column = identify_cluster_column (input_string )
5859 assert test_column == expected_column , "wrong column index"
5960
6061
6162@pytest .mark .imported
62- def test_read_dw_list ():
63+ def test_read_dw_list () -> None :
64+ """Perform a frequency analysis on DW assigned cluster labels.
65+
66+ This checks if DW assigned cluster labels are used to build a
67+ dictionary where DW labels indicate (as key) to the number of
68+ times they are assigned by DW (as value)."""
6369 # some records of DW cluster 1, 5, and 8 of `100Random_Molecules.txt`
6470 mock_table_body = [
6571 r"fko`H@D@yHsQ{OdTRbbbtRLLRTvRfoEjuTuUTAAUSPSBiAKL@@ 1 No 6" ,
@@ -83,7 +89,11 @@ def test_read_dw_list():
8389
8490
8591@pytest .mark .imported
86- def test_label_sorter_default_sort ():
92+ def test_label_sorter_default_sort () -> None :
93+ """Check the normal sort of a new frequency dictionary.
94+
95+ By default, the lowest key (label) describes the cluster with the
96+ most structures (value)."""
8797 mock_dictionary = {"1" : 4 , "5" : 3 , "8" : 2 }
8898 reversed_order = False
8999 expected_dictionary = {"1" : 1 , "5" : 2 , "8" : 3 }
@@ -92,7 +102,11 @@ def test_label_sorter_default_sort():
92102
93103
94104@pytest .mark .imported
95- def test_label_sorter_reverse_sort ():
105+ def test_label_sorter_reverse_sort () -> None :
106+ """Check the reverse sort of a new frequency dictionary.
107+
108+ By default, the lowest key (label) describes the cluster with the
109+ least number of structures (value)."""
96110 mock_dictionary = {"1" : 4 , "5" : 3 , "8" : 2 }
97111 reversed_order = True
98112 expected_dictionary = {"1" : 3 , "5" : 2 , "8" : 1 }
@@ -101,7 +115,8 @@ def test_label_sorter_reverse_sort():
101115
102116
103117@pytest .mark .imported
104- def test_update_cluster_labels ():
118+ def test_update_cluster_labels () -> None :
119+ """Check the reassignment of cluster labels."""
105120 # some of DW clusters 1, 5, and 8
106121 mock_table_body = [
107122 r"fko`H@D@yHsQ{OdTRbbbtRLLRTvRfoEjuTuUTAAUSPSBiAKL@@ 1 No 6" ,
@@ -134,7 +149,8 @@ def test_update_cluster_labels():
134149
135150
136151@pytest .mark .imported
137- def test_permanent_report (tmp_path ):
152+ def test_permanent_report (tmp_path ) -> None :
153+ """Probe the generation of a permanent record."""
138154 # prepare data to write
139155 input_file = "test_input.txt"
140156 headline = "Structure [idcode] Cluster No Is Representative record_number"
0 commit comments