forked from CommitAnalyzingService/CAS_CodeRepoAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_categorization.py
executable file
·73 lines (59 loc) · 2.98 KB
/
test_categorization.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from classifier.classifier import *
from caslogging import logging
logging.info('Test categorization... ')
classifier = Classifier()
# Test classification of corrective commits
# fix,bug,wrong,fail,problem
corrective_msg_1 = "fixed something"
corrective_msg_2 = "bam, there goes a bug!"
corrective_msg_3 = "x was wrong, but no more!"
corrective_msg_4 = "Houston, we *had* a problem"
corrective_msg_5 = "My watch is fun"
corrective_msg_6 = "This is definitively NOT a you-know what!"
assert(classifier.categorize(corrective_msg_1) == "Corrective")
assert(classifier.categorize(corrective_msg_2) == "Corrective")
assert(classifier.categorize(corrective_msg_3) == "Corrective")
assert(classifier.categorize(corrective_msg_4) == "Corrective")
assert(classifier.categorize(corrective_msg_5) != "Corrective")
assert(classifier.categorize(corrective_msg_6) != "Corrective")
# Test classification of feature additions
# new,add,requirement,initial,create
feature_msg_1 = "new awesome thing added to that brillinat code"
feature_msg_2 = "adding some color to this mundane gui!"
feature_msg_3 = "Adding requirement.."
feature_msg_4 = "This is an initial commit"
feature_msg_5 = "Creating a new class for x,y, AND z!"
feature_msg_6 = "This is definitively NOT a you-know what!"
assert(classifier.categorize(feature_msg_1) == "Feature Addition")
assert(classifier.categorize(feature_msg_2) == "Feature Addition")
assert(classifier.categorize(feature_msg_3) == "Feature Addition")
assert(classifier.categorize(feature_msg_4) == "Feature Addition")
assert(classifier.categorize(feature_msg_5) == "Feature Addition")
assert(classifier.categorize(feature_msg_6) != "Feature Addition")
# Test classification of preventative commits
# test,junit,coverage,assert
prev_msg_1 = "testing to make sure of stuff"
prev_msg_2 = "junit rocks, stay heavy!"
prev_msg_3 = "coverage is now much higher"
prev_msg_4 = "asserting that our code doesn't make computers 'splode"
prev_msg_5 = "I am totally awesome"
assert(classifier.categorize(prev_msg_1) == "Preventative")
assert(classifier.categorize(prev_msg_2) == "Preventative")
assert(classifier.categorize(prev_msg_3) == "Preventative")
assert(classifier.categorize(prev_msg_4) == "Preventative")
assert(classifier.categorize(prev_msg_5) != "Preventative")
# Test that corrective classification again
# fix,bug,wrong,fail,problem
corrective_msg_1 = "fixed something"
corrective_msg_2 = "bam, there goes a bug!"
corrective_msg_3 = "x was wrong, but no more!"
corrective_msg_4 = "Houston, we *had* a problem"
corrective_msg_5 = "My watch is fun"
corrective_msg_6 = "This is definitively NOT a you-know what!"
assert(classifier.categorize(corrective_msg_1) == "Corrective")
assert(classifier.categorize(corrective_msg_2) == "Corrective")
assert(classifier.categorize(corrective_msg_3) == "Corrective")
assert(classifier.categorize(corrective_msg_4) == "Corrective")
assert(classifier.categorize(corrective_msg_5) != "Corrective")
assert(classifier.categorize(corrective_msg_6) != "Corrective")
logging.info("Passed tests")