-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-[x] Finished test for cli: -[x] checks if the main cli function produces stdout in the terminal -[x] checks for all the supporting functions, that they are returning appropriate values and raising errors otherwise -[x] Encapsulated chart selection into a new method -[ ] Need to add test that cli can accept and handle various combination of stdin
- Loading branch information
Showing
3 changed files
with
82 additions
and
22 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
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,53 @@ | ||
import io | ||
import random | ||
import psutil | ||
import unittest | ||
import unittest.mock | ||
|
||
from access import add_path | ||
from cli import cli, check_color, check_attr, check_chart | ||
from disk import DiskUsage, Color, Attr, Chart | ||
from click.testing import CliRunner | ||
|
||
class TestCli(unittest.TestCase): | ||
|
||
def test_vizex(self): | ||
self.test_cli() | ||
|
||
def test_cli(self): | ||
runner = CliRunner() | ||
result = runner.invoke(cli, ['barh']) | ||
assert result.exit_code == 0 | ||
|
||
def test_check_color(self): | ||
user_inputs = [ | ||
'red', 'green', 'BLUE', 'Yellow', | ||
'beige', 'pink', 'purple', 'oraNge' | ||
] | ||
for color in user_inputs: | ||
self.assertTrue(check_color(color) in Color) | ||
with self.assertRaises(KeyError): | ||
check_color('burgundy') | ||
|
||
def test_check_attr(self): | ||
user_inputs = [ | ||
'bold', 'dim', 'underlined', | ||
'blink', 'reverse', 'hidden' | ||
] | ||
for attr in user_inputs: | ||
self.assertTrue(check_attr(attr) in Attr) | ||
with self.assertRaises(KeyError): | ||
check_attr('italic') | ||
|
||
def test_check_chart(self): | ||
user_inputs = [ | ||
'barv', 'barh', 'pie' | ||
] | ||
for chart in user_inputs: | ||
self.assertTrue(check_chart(chart) in Chart) | ||
with self.assertRaises(NameError): | ||
check_chart('scatter') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |