Skip to content

Commit b37dcb4

Browse files
committed
wrote tests
1 parent 2f2b0b4 commit b37dcb4

File tree

6 files changed

+60
-10
lines changed

6 files changed

+60
-10
lines changed

demo.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@
2020

2121
print(moss.getHomePage())
2222
pprint.pprint(moss.getResults())
23-
#pprint.pprint(moss.getShareScores()
23+
# print frequency of each shared solution
24+
pprint.pprint(moss.getShareScores())
25+
# print potential distributor-culprit relationships
26+
pprint.pprint(moss.getInsights())

plagcheck/analyze.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def relatesTo(self, P1, P2, node1, node2):
4242
node_obj_dict[node2].links.append(node_obj_dict[node1])
4343
else:
4444
node_obj_dict[node1].links.append(node_obj_dict[node2])
45+
node_obj_dict[node2].links.append(node_obj_dict[node1])
4546

4647
Mgroups.linkCount += 1
4748

plagcheck/plagcheck_test.py

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,47 @@
11
"""Tests for the MOSS interface package for CodeClassroom"""
22
from plagcheck import plagcheck
3+
from plagcheck import analyze
34

45

56
def test_check():
67
"""General test"""
7-
language = "java"
8+
language = "python"
89
userid = "1"
910
temp = plagcheck.check(language, userid)
10-
temp.addFilesByWildCard("testfiles/test_java*.java")
11+
temp.addFilesByWildCard("testfiles/test_python*.py")
1112
temp.submit()
1213
results = temp.getResults()
14+
insights = temp.getInsights()
15+
share_scores = temp.getShareScores()
16+
17+
assert share_scores == {'testfiles/test_python.py': 2,
18+
'testfiles/test_python2.py': 2,
19+
'testfiles/test_python3.py': 2}
20+
21+
assert insights == {
22+
'DCtoC Paths': [],
23+
'DtoC Paths': [],
24+
'DtoDC Paths': []}
1325

1426
assert results == [
15-
{
16-
"file1": "testfiles/test_python.py",
17-
"file2": "testfiles/test_python3.py",
18-
"percentage": 90,
19-
"no_of_lines_matched": 3,
20-
"lines_matched": [["1-3", "1-3"]],
21-
}
27+
{'file1': 'testfiles/test_python2.py',
28+
'file2': 'testfiles/test_python3.py',
29+
'lines_matched': [['1-3', '1-3']],
30+
'no_of_lines_matched': 3,
31+
'percentage_file1': 90,
32+
'percentage_file2': 90},
33+
{'file1': 'testfiles/test_python.py',
34+
'file2': 'testfiles/test_python3.py',
35+
'lines_matched': [['1-3', '1-3']],
36+
'no_of_lines_matched': 3,
37+
'percentage_file1': 90,
38+
'percentage_file2': 90},
39+
{'file1': 'testfiles/test_python.py',
40+
'file2': 'testfiles/test_python2.py',
41+
'lines_matched': [['1-3', '1-3']],
42+
'no_of_lines_matched': 3,
43+
'percentage_file1': 90,
44+
'percentage_file2': 90}
2245
]
2346

2447

@@ -30,3 +53,17 @@ def test_perc_str_to_int():
3053
assert result == 42
3154
result = plagcheck.perc_str_to_int("(100%)")
3255
assert result == 100
56+
57+
58+
def test_Mgroups():
59+
mg = analyze.Mgroups()
60+
mg.createNodes({'1', '2', '3'})
61+
62+
mg.relatesTo(45, 88, '3', '1')
63+
mg.relatesTo(46, 90, '3', '2')
64+
65+
mg.set_tags()
66+
67+
assert mg.d2dc() == []
68+
assert mg.d2c() == [('3', '1'), ('3', '2')]
69+
assert mg.dc2c() == []

testfiles/test_python.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
word = str(input())
2+
print("Hello, " + word)
3+
print("your are awsm!")

testfiles/test_python2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name = str(input())
2+
print("hola, " + name)
3+
print("hola friend!")

testfiles/test_python3.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name = str(input())
2+
print("Hello, " + name)
3+
print("Yoo")

0 commit comments

Comments
 (0)