-
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.
- Loading branch information
Tycho Pandelaar
committed
Oct 9, 2023
1 parent
a187c18
commit ec39e4f
Showing
2 changed files
with
90 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,41 @@ | ||
import unittest | ||
from main import show_usage | ||
|
||
|
||
class TestMain(unittest.TestCase): | ||
|
||
def test_show_usage(self): | ||
expected_usage = """ | ||
Usage: | ||
`gitgrove COMMAND` | ||
or one of the shortcuts: | ||
`gg COMMAND`, `ggs`, `ggf`, `ggp`, `ggpr`, `ggc`, `ggb BRANCH`, `ggd` | ||
Commands: | ||
-s, --status : Show all the repository statuses. | ||
-f, --fetch : Fetch all repositories. | ||
-p, --pull : Pull all repositories. | ||
-pr, --prune : Prunes objects that are no longer reachable. | ||
-c, --cleanup : Clean up and optimize the local repositories. | ||
-b, --branch BRANCH: Switch all repositories to a specified branch. | ||
-d, --development : Switch all repositories to the development branch. | ||
Shortcuts: | ||
gg : Same as gitgrove. | ||
ggs : Show all the repository statuses. | ||
ggf : Fetch all repositories. | ||
ggp : Pull all repositories. | ||
ggpr : Prunes objects that are no longer reachable. | ||
ggc : Clean up and optimize the local repositories. | ||
ggb BRANCH: Switch all repositories to a specified branch. | ||
ggd : Switch all repositories to the development branch. | ||
""" | ||
|
||
actual_usage = show_usage() | ||
|
||
self.assertEqual(expected_usage, actual_usage) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,49 @@ | ||
import unittest | ||
from table import Table, Cell, TableRenderer | ||
|
||
|
||
class TestCell(unittest.TestCase): | ||
|
||
def test_init(self): | ||
cell = Cell("Hello, world!") | ||
|
||
self.assertEqual(cell.content, "Hello, world!") | ||
self.assertEqual(cell.justify, "left") | ||
self.assertEqual(cell.color, ANSI_WHITE) | ||
|
||
cell = Cell("Hello, world!", justify="right", color=ANSI_RED) | ||
|
||
self.assertEqual(cell.content, "Hello, world!") | ||
self.assertEqual(cell.justify, "right") | ||
self.assertEqual(cell.color, ANSI_RED) | ||
|
||
|
||
class TestTable(unittest.TestCase): | ||
|
||
def test_init(self): | ||
table = Table() | ||
self.assertEqual(table.rows, []) | ||
|
||
|
||
class TestTableIntegration(unittest.TestCase): | ||
|
||
def test_render_table(self): | ||
table = Table() | ||
table.add_row(["Name", "Age"]) | ||
table.add_row(["John Doe", 30]) | ||
|
||
renderer = TableRenderer(table, ANSI_GREY, ANSI_WHITE) | ||
rendered_table = renderer.render() | ||
|
||
expected_rendered_table = """ | ||
╔═══════╦═══════╗ | ||
║ Name ║ Age ║ | ||
╠═══════╬═══════╣ | ||
║ John Doe ║ 30 ║ | ||
╚═══════╩═══════╝ | ||
""" | ||
|
||
self.assertEqual(rendered_table, expected_rendered_table) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |