1
|
|
|
#pylint: disable=E1126 |
2
|
|
|
""" Unit testing module for pre-processing functions """ |
3
|
|
|
|
4
|
|
|
import unittest |
5
|
|
|
import string |
6
|
|
|
|
7
|
|
|
import crowdtruth |
8
|
|
|
from crowdtruth.configuration import DefaultConfig |
9
|
|
|
|
10
|
|
|
TEST_FILE_PREF = "test/test_data/load/" |
11
|
|
|
|
12
|
|
|
class TestConfig(DefaultConfig): |
13
|
|
|
inputColumns = ["input"] |
14
|
|
|
outputColumns = ["Answer.output"] |
15
|
|
|
open_ended_task = False |
16
|
|
|
annotation_separator = " " |
17
|
|
|
annotation_vector = list(string.ascii_uppercase) |
18
|
|
|
def processJudgments(self, judgments): |
19
|
|
|
return judgments |
20
|
|
|
|
21
|
|
|
# test_conf_const = TestConfig() |
22
|
|
|
# test_config_amt = test_conf_const.__class__ |
23
|
|
|
# data_amt, config_amt = crowdtruth.load( |
24
|
|
|
# file=TEST_FILE_PREF + "platform_amt" + str(1) + ".csv", |
25
|
|
|
# config=test_config_amt()) |
26
|
|
|
|
27
|
|
|
# test_config_cf = test_conf_const.__class__ |
28
|
|
|
# data_cf, config_cf = crowdtruth.load( |
29
|
|
|
# file=TEST_FILE_PREF + "platform_cf" + str(1) + ".csv", |
30
|
|
|
# config=test_config_cf()) |
31
|
|
|
|
32
|
|
|
class TestLoad(unittest.TestCase): |
33
|
|
|
test_conf_const = TestConfig() |
34
|
|
|
|
35
|
|
|
def test_platform(self): |
36
|
|
|
for w in range(1, 6): |
37
|
|
|
test_config_amt = self.test_conf_const.__class__ |
38
|
|
|
data_amt, config_amt = crowdtruth.load( |
39
|
|
|
file=TEST_FILE_PREF + "platform_amt" + str(w) + ".csv", |
40
|
|
|
config=test_config_amt()) |
41
|
|
|
test_config_cf = self.test_conf_const.__class__ |
42
|
|
|
data_cf, config_cf = crowdtruth.load( |
43
|
|
|
file=TEST_FILE_PREF + "platform_cf" + str(w) + ".csv", |
44
|
|
|
config=test_config_cf()) |
45
|
|
|
self.assertEqual( |
46
|
|
|
(set(data_cf["units"]["duration"].keys()) - |
47
|
|
|
set(data_amt["units"]["duration"].keys())), |
48
|
|
|
set([])) |
49
|
|
|
self.assertEqual( |
50
|
|
|
(set(data_cf["workers"]["judgment"].keys()) - |
51
|
|
|
set(data_amt["workers"]["judgment"].keys())), |
52
|
|
|
set([])) |
53
|
|
|
self.assertEqual( |
54
|
|
|
set(data_cf["workers"]["judgment"] - data_amt["workers"]["judgment"]), |
55
|
|
|
set([0])) |
56
|
|
|
|