-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_module3.py
More file actions
25 lines (22 loc) · 892 Bytes
/
Copy pathtest_module3.py
File metadata and controls
25 lines (22 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from unittest import TestCase
from modules.module3 import clustering
class Test(TestCase):
def test_clustering(self):
country_list = [0, 1, 2, 3, 4, 5]
list_distances = [
[0, 1, 4, 7, 6, 3],
[1, 0, 3, 6, 5, 2],
[4, 3, 0, 3, 4, 3],
[7, 6, 3, 0, 5, 4],
[6, 5, 4, 5, 0, 3],
[3, 2, 3, 4, 3, 0],
]
data_distances = dict()
for country in country_list:
data_distances[country] = dict()
for country1 in country_list:
data_distances[country][country1] = list_distances[country][country_list.index(country1)]
expected_result = dict()
expected_result.update({1: {"Cluster": [0, 1, 2, 4, 5]}})
expected_result.update({3: {"Cluster": [3]}})
self.assertEqual(expected_result, clustering(data_distances, 2, (1, 4)))