forked from cockroachdb/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Currently just tests one function: calculate_csat() * Confirms old & new algorithm for a couple of test cases * Baked in an exception that gets raised for pages with no yes or no votes. * added `.pyc` and `__pycache__` to `.gitignore` in order to avoid synching unreadable content to git.
- Loading branch information
Showing
3 changed files
with
32 additions
and
2 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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
*~ | ||
.*.swp | ||
*.pyc | ||
__pycache__ | ||
.DS_Store | ||
generate/generate | ||
Railroad.jar | ||
|
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
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,28 @@ | ||
#!/usr/bin/env python | ||
|
||
import unittest | ||
import docs_csat as dc | ||
|
||
|
||
class TestDocsCSAT(unittest.TestCase): | ||
|
||
def test_calculate_csat(self): | ||
no_votes = {"page1": 1, "page2": 0, "page3": 1, "page4": 10} | ||
yes_votes = {"page2": 10, "page3": 10, "page5": 1, "page6": 0} | ||
pageviews = {"page2": 1000, "page4": 10} | ||
# Raises ZeroDivisionError from wegihted CSAT section, line | ||
# `average_csats[k] = yes / total` | ||
self.assertRaises(ZeroDivisionError, dc.calculate_csat, no_votes, | ||
yes_votes, pageviews) | ||
|
||
no_votes = {"page1": 1, "page2": 0, "page3": 1, "page4": 10} # 12 | ||
yes_votes = {"page2": 10, "page3": 10, "page5": 1, "page6": 1} # 22 | ||
pageviews = {"page2": 1000, "page4": 10} # 1000 yes, 10 no | ||
basic_csat, weighted_csat = dc.calculate_csat(no_votes, yes_votes, | ||
pageviews) | ||
self.assertEqual(basic_csat, 22 / (12 + 22)) | ||
self.assertEqual(weighted_csat, 1000 / (1000 + 10)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |