mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
add tests
This commit is contained in:
1
tests/fixtures/generic/git-log-full-shortstat.json
vendored
Normal file
1
tests/fixtures/generic/git-log-full-shortstat.json
vendored
Normal file
File diff suppressed because one or more lines are too long
19602
tests/fixtures/generic/git-log-full-shortstat.out
vendored
Normal file
19602
tests/fixtures/generic/git-log-full-shortstat.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-full-stat.json
vendored
Normal file
1
tests/fixtures/generic/git-log-full-stat.json
vendored
Normal file
File diff suppressed because one or more lines are too long
28851
tests/fixtures/generic/git-log-full-stat.out
vendored
Normal file
28851
tests/fixtures/generic/git-log-full-stat.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-full.json
vendored
Normal file
1
tests/fixtures/generic/git-log-full.json
vendored
Normal file
File diff suppressed because one or more lines are too long
14966
tests/fixtures/generic/git-log-full.out
vendored
Normal file
14966
tests/fixtures/generic/git-log-full.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-fuller-shortstat.json
vendored
Normal file
1
tests/fixtures/generic/git-log-fuller-shortstat.json
vendored
Normal file
File diff suppressed because one or more lines are too long
24468
tests/fixtures/generic/git-log-fuller-shortstat.out
vendored
Normal file
24468
tests/fixtures/generic/git-log-fuller-shortstat.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-fuller-stat.json
vendored
Normal file
1
tests/fixtures/generic/git-log-fuller-stat.json
vendored
Normal file
File diff suppressed because one or more lines are too long
33717
tests/fixtures/generic/git-log-fuller-stat.out
vendored
Normal file
33717
tests/fixtures/generic/git-log-fuller-stat.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-fuller.json
vendored
Normal file
1
tests/fixtures/generic/git-log-fuller.json
vendored
Normal file
File diff suppressed because one or more lines are too long
19832
tests/fixtures/generic/git-log-fuller.out
vendored
Normal file
19832
tests/fixtures/generic/git-log-fuller.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-medium-shortstat.json
vendored
Normal file
1
tests/fixtures/generic/git-log-medium-shortstat.json
vendored
Normal file
File diff suppressed because one or more lines are too long
19602
tests/fixtures/generic/git-log-medium-shortstat.out
vendored
Normal file
19602
tests/fixtures/generic/git-log-medium-shortstat.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-medium-stat.json
vendored
Normal file
1
tests/fixtures/generic/git-log-medium-stat.json
vendored
Normal file
File diff suppressed because one or more lines are too long
28851
tests/fixtures/generic/git-log-medium-stat.out
vendored
Normal file
28851
tests/fixtures/generic/git-log-medium-stat.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-medium.json
vendored
Normal file
1
tests/fixtures/generic/git-log-medium.json
vendored
Normal file
File diff suppressed because one or more lines are too long
14966
tests/fixtures/generic/git-log-medium.out
vendored
Normal file
14966
tests/fixtures/generic/git-log-medium.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-oneline-shortstat.json
vendored
Normal file
1
tests/fixtures/generic/git-log-oneline-shortstat.json
vendored
Normal file
File diff suppressed because one or more lines are too long
4751
tests/fixtures/generic/git-log-oneline-shortstat.out
vendored
Normal file
4751
tests/fixtures/generic/git-log-oneline-shortstat.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-oneline-stat.json
vendored
Normal file
1
tests/fixtures/generic/git-log-oneline-stat.json
vendored
Normal file
File diff suppressed because one or more lines are too long
14000
tests/fixtures/generic/git-log-oneline-stat.out
vendored
Normal file
14000
tests/fixtures/generic/git-log-oneline-stat.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-oneline.json
vendored
Normal file
1
tests/fixtures/generic/git-log-oneline.json
vendored
Normal file
File diff suppressed because one or more lines are too long
2433
tests/fixtures/generic/git-log-oneline.out
vendored
Normal file
2433
tests/fixtures/generic/git-log-oneline.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-short-shortstat.json
vendored
Normal file
1
tests/fixtures/generic/git-log-short-shortstat.json
vendored
Normal file
File diff suppressed because one or more lines are too long
16916
tests/fixtures/generic/git-log-short-shortstat.out
vendored
Normal file
16916
tests/fixtures/generic/git-log-short-shortstat.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-short-stat.json
vendored
Normal file
1
tests/fixtures/generic/git-log-short-stat.json
vendored
Normal file
File diff suppressed because one or more lines are too long
26165
tests/fixtures/generic/git-log-short-stat.out
vendored
Normal file
26165
tests/fixtures/generic/git-log-short-stat.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log-short.json
vendored
Normal file
1
tests/fixtures/generic/git-log-short.json
vendored
Normal file
File diff suppressed because one or more lines are too long
12280
tests/fixtures/generic/git-log-short.out
vendored
Normal file
12280
tests/fixtures/generic/git-log-short.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
tests/fixtures/generic/git-log.json
vendored
Normal file
1
tests/fixtures/generic/git-log.json
vendored
Normal file
File diff suppressed because one or more lines are too long
14966
tests/fixtures/generic/git-log.out
vendored
Normal file
14966
tests/fixtures/generic/git-log.out
vendored
Normal file
File diff suppressed because it is too large
Load Diff
215
tests/test_git_log.py
Normal file
215
tests/test_git_log.py
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
import os
|
||||||
|
import unittest
|
||||||
|
import json
|
||||||
|
import jc.parsers.git_log
|
||||||
|
|
||||||
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
class MyTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
# input
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-short.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_short = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-short-stat.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_short_stat = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-short-shortstat.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_short_shortstat = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-medium.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_medium = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-medium-stat.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_medium_stat = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-medium-shortstat.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_medium_shortstat = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-full.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_full = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-full-stat.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_full_stat = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-full-shortstat.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_full_shortstat = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-fuller.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_fuller = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-fuller-stat.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_fuller_stat = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-fuller-shortstat.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_fuller_shortstat = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-oneline.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_oneline = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-oneline-stat.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_oneline_stat = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-oneline-shortstat.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_oneline_shortstat = f.read()
|
||||||
|
|
||||||
|
# output
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-short.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_short_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-short-stat.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_short_stat_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-short-shortstat.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_short_shortstat_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-medium.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_medium_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-medium-stat.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_medium_stat_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-medium-shortstat.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_medium_shortstat_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-full.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_full_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-full-stat.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_full_stat_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-full-shortstat.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_full_shortstat_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-fuller.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_fuller_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-fuller-stat.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_fuller_stat_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-fuller-shortstat.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_fuller_shortstat_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-oneline.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_oneline_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-oneline-stat.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_oneline_stat_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-oneline-shortstat.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.git_log_oneline_shortstat_json = json.loads(f.read())
|
||||||
|
|
||||||
|
|
||||||
|
def test_git_log_nodata(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log' with no data
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse('', quiet=True), [])
|
||||||
|
|
||||||
|
def test_git_log(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log, quiet=True), self.git_log_json)
|
||||||
|
|
||||||
|
def test_git_log_short(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=short'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_short, quiet=True), self.git_log_short_json)
|
||||||
|
|
||||||
|
def test_git_log_short_stat(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=short --stat'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_short_stat, quiet=True), self.git_log_short_stat_json)
|
||||||
|
|
||||||
|
def test_git_log_short_shortstat(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=short --shortstat'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_short_shortstat, quiet=True), self.git_log_short_shortstat_json)
|
||||||
|
|
||||||
|
def test_git_log_medium(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=medium'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_medium, quiet=True), self.git_log_medium_json)
|
||||||
|
|
||||||
|
def test_git_log_medium_stat(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=medium --stat'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_medium_stat, quiet=True), self.git_log_medium_stat_json)
|
||||||
|
|
||||||
|
def test_git_log_medium_shortstat(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=medium --shortstat'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_medium_shortstat, quiet=True), self.git_log_medium_shortstat_json)
|
||||||
|
|
||||||
|
def test_git_log_full(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=full'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_full, quiet=True), self.git_log_full_json)
|
||||||
|
|
||||||
|
def test_git_log_full_stat(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=full --stat'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_full_stat, quiet=True), self.git_log_full_stat_json)
|
||||||
|
|
||||||
|
def test_git_log_full_shortstat(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=full --shortstat'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_full_shortstat, quiet=True), self.git_log_full_shortstat_json)
|
||||||
|
|
||||||
|
def test_git_log_fuller(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=fuller'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_fuller, quiet=True), self.git_log_fuller_json)
|
||||||
|
|
||||||
|
def test_git_log_fuller_stat(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=fuller --stat'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_fuller_stat, quiet=True), self.git_log_fuller_stat_json)
|
||||||
|
|
||||||
|
def test_git_log_fuller_shortstat(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=fuller --shortstat'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_fuller_shortstat, quiet=True), self.git_log_fuller_shortstat_json)
|
||||||
|
|
||||||
|
def test_git_log_oneline(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=oneline'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_oneline, quiet=True), self.git_log_oneline_json)
|
||||||
|
|
||||||
|
def test_git_log_oneline_stat(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=oneline --stat'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_oneline_stat, quiet=True), self.git_log_oneline_stat_json)
|
||||||
|
|
||||||
|
def test_git_log_oneline_shortstat(self):
|
||||||
|
"""
|
||||||
|
Test 'git_log --format=oneline --shortstat'
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.git_log.parse(self.git_log_oneline_shortstat, quiet=True), self.git_log_oneline_shortstat_json)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
Reference in New Issue
Block a user