Skip to content

Commit

Permalink
Initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tycho Pandelaar committed Oct 9, 2023
1 parent a187c18 commit ec39e4f
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/test_main.py
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()
49 changes: 49 additions & 0 deletions tests/test_table.py
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()

0 comments on commit ec39e4f

Please sign in to comment.