This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests to the "commentAnalysis.py"
Adds positive unit tests to the functions in the commentAnalysis.py file
- Loading branch information
1 parent
3f9d9b0
commit e6238cd
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import unittest | ||
from commentAnalysis import CommentAnalyzer | ||
|
||
|
||
class TestCommentAnalysis(unittest.TestCase): | ||
|
||
|
||
def test_CommentAnalyzer_init(self): | ||
analyzer = CommentAnalyzer(['test']) | ||
""" positive test """ | ||
self.assertEqual(analyzer.word_count, {'test': 0}) | ||
""" negative test """ | ||
self.assertNotEqual(analyzer.word_count, {'test': 1}) | ||
|
||
def test_analyze_comments(self): | ||
analyzer = CommentAnalyzer(['test']) | ||
""" positive test """ | ||
result = analyzer.analyzeComment("This is a test comment") | ||
self.assertEqual(result, {'test': 1, 'Sentiment': 0.0, 'Code Blocks': 0}) | ||
""" negative test """ | ||
self.assertNotEqual(result, {'test': 0, 'Sentiment': 0.0, 'Code Blocks': 0}) | ||
|
||
def test_preProcess(self): | ||
analyzer = CommentAnalyzer(['test']) | ||
result = analyzer.preProcess("This is a test comment") | ||
""" positive test """ | ||
self.assertEqual(result, "this is a test comment") | ||
""" negative test """ | ||
self.assertNotEqual(result, "This is a test comment") | ||
|
||
def test_countWords(self): | ||
analyzer = CommentAnalyzer(['test']) | ||
result = analyzer.countWords("This is a test comment") | ||
""" positive test """ | ||
self.assertEqual(result, {'test': 1}) | ||
""" negative test """ | ||
self.assertNotEqual(result, {'test': 0}) | ||
|
||
def test_getSentiment(self): | ||
analyzer = CommentAnalyzer(['test']) | ||
result = analyzer.getSentiment("This is a test comment") | ||
""" positive test """ | ||
self.assertEqual(result, 0.0) | ||
""" negative test """ | ||
self.assertNotEqual(result, 0.1) | ||
|
||
def test_getCodeBlockCount(self): | ||
analyzer = CommentAnalyzer(['test']) | ||
result = analyzer.getCodeBlockCount("This is a test comment") | ||
""" positive test """ | ||
self.assertEqual(result, 0) | ||
""" negative test """ | ||
self.assertNotEqual(result, 1) |