diff --git a/pyproject.toml b/pyproject.toml index c72da62..14ee48a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ sr-detector = { path = "./sr-detector" } nltk = "^3.9.1" scikit-learn = "^1.5.1" cohere = "^5.9.1" +loguru = "^0.7.2" [tool.poetry.group.dev.dependencies] pytest = "^8.2.2" diff --git a/sr-data/src/tests/test_cluster.py b/sr-data/src/tests/test_cluster.py new file mode 100644 index 0000000..9386801 --- /dev/null +++ b/sr-data/src/tests/test_cluster.py @@ -0,0 +1,45 @@ +""" +Test case for cluster step. +""" +# The MIT License (MIT) +# +# Copyright (c) 2024 Aliaksei Bialiauski +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +import os +import shutil +import unittest +from sr_data.steps.cluster import kmeans + + +class TestCluster(unittest.TestCase): + + def test_clusters_kmeans_numerical(self): + kmeans( + os.path.join( + os.path.dirname(os.path.realpath(__file__)), "to-cluster.csv" + ), + "kmeans" + ) + expected = "kmeans/to-cluster/clusters" + self.assertTrue( + os.path.exists(expected), + f"Path {expected} does not exists" + ) + shutil.rmtree("kmeans") diff --git a/sr-data/src/tests/to-cluster.csv b/sr-data/src/tests/to-cluster.csv new file mode 100644 index 0000000..87d5232 --- /dev/null +++ b/sr-data/src/tests/to-cluster.csv @@ -0,0 +1,9 @@ +repo,score +jeff/foo,112.5 +jeff/testing,112.5 +jeff/some,112.5 +jeff/dummy,112.5 +jeff/bar2,112.5 +jeff/test1,112.5 +jeff/test,112.5 +jeff/bar,112.5