mirror of
https://github.com/ejwa/gitinspector.git
synced 2024-11-16 00:28:25 +01:00
More tests
This commit is contained in:
parent
53d81bcd26
commit
23cbb297d9
1 changed files with 97 additions and 0 deletions
97
tests/test_changes.py
Normal file
97
tests/test_changes.py
Normal file
|
@ -0,0 +1,97 @@
|
|||
import unittest
|
||||
from gitinspector import changes
|
||||
|
||||
|
||||
FAKE_FILE_NAME = 'Arbitrary.ext'
|
||||
FAKE_COMMIT_STRING = "1614563270|2021-02-28|53d81bcd2612dbc47e73c71ee43baae83c1ec252|JP White|jpwhite3@gmail.com"
|
||||
|
||||
|
||||
class TestAuthorInfo(unittest.TestCase):
|
||||
|
||||
def test_AuthorInfo_attrs(self):
|
||||
author = changes.AuthorInfo()
|
||||
expected_email = None
|
||||
expected_insertions = 0
|
||||
expected_deletions = 0
|
||||
expected_commits = 0
|
||||
self.assertEqual(expected_email, author.email)
|
||||
self.assertEqual(expected_insertions, author.insertions)
|
||||
self.assertEqual(expected_deletions, author.deletions)
|
||||
self.assertEqual(expected_commits, author.commits)
|
||||
|
||||
|
||||
class TestFileDiff(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
pass
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_FileDiff_init(self):
|
||||
test_string = 'ArbitraryName|-++-+'
|
||||
file_diff = changes.FileDiff(test_string)
|
||||
expected_name = 'ArbitraryName'
|
||||
self.assertEqual(expected_name, file_diff.name)
|
||||
expected_insertions = 3
|
||||
self.assertEqual(expected_insertions, file_diff.insertions)
|
||||
expected_deletions = 2
|
||||
self.assertEqual(expected_deletions, file_diff.deletions)
|
||||
|
||||
def test_is_not_filediff_line(self):
|
||||
actual = changes.FileDiff.is_filediff_line(FAKE_FILE_NAME)
|
||||
self.assertFalse(actual)
|
||||
|
||||
def test_is_filediff_line(self):
|
||||
test_file_diff_string = "arbitrary|--- a/file.txt"
|
||||
actual = changes.FileDiff.is_filediff_line(test_file_diff_string)
|
||||
self.assertTrue(actual)
|
||||
|
||||
def test_get_extension(self):
|
||||
expected = 'ext'
|
||||
actual = changes.FileDiff.get_extension(FAKE_FILE_NAME)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_get_extension_from_file_without_extension(self):
|
||||
test_file_name = 'Arbitrary'
|
||||
expected = ''
|
||||
actual = changes.FileDiff.get_extension(test_file_name)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_get_filename(self):
|
||||
expected = FAKE_FILE_NAME
|
||||
actual = changes.FileDiff.get_filename(expected)
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_is_not_valid_extension(self):
|
||||
result = changes.FileDiff.is_valid_extension(FAKE_FILE_NAME)
|
||||
self.assertFalse(result)
|
||||
|
||||
def test_is_valid_extension(self):
|
||||
test_file_name = 'Arbitrary.cpp'
|
||||
result = changes.FileDiff.is_valid_extension(test_file_name)
|
||||
self.assertTrue(result)
|
||||
|
||||
|
||||
class TestCommitClass(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
pass
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def test_Commit_init(self):
|
||||
commit = changes.Commit(FAKE_COMMIT_STRING)
|
||||
expected_timestamp = '1614563270'
|
||||
expected_date = '2021-02-28'
|
||||
expected_sha = '53d81bcd2612dbc47e73c71ee43baae83c1ec252'
|
||||
expected_author = 'JP White'
|
||||
expected_email = 'jpwhite3@gmail.com'
|
||||
self.assertEqual(expected_timestamp, commit.timestamp)
|
||||
self.assertEqual(expected_date, commit.date)
|
||||
self.assertEqual(expected_sha, commit.sha)
|
||||
self.assertEqual(expected_author, commit.author)
|
||||
self.assertEqual(expected_email, commit.email)
|
Loading…
Reference in a new issue