Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Add unit tests to the "commentAnalysis.py"
Browse files Browse the repository at this point in the history
Adds positive unit tests to the functions in the commentAnalysis.py file
  • Loading branch information
pramodrj07 committed Jan 4, 2022
1 parent 3f9d9b0 commit e6238cd
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions ml-conversational-analytic-tool/test_commentAnalysis.py
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)

0 comments on commit e6238cd

Please sign in to comment.