gitinspector/tests/test_config.py
2021-03-13 23:12:42 -05:00

37 lines
1.3 KiB
Python

import unittest
from gitinspector import config
class TestConfig(unittest.TestCase):
def test_GitConfig_init(self):
expected_run = 'run'
expected_repo = 'repo'
expected_global_only = False
test_config = config.GitConfig(expected_run, expected_repo)
self.assertEqual(expected_run, test_config.run)
self.assertEqual(expected_repo, test_config.repo)
self.assertEqual(expected_global_only, test_config.global_only)
def test_read_git_config_unknown_variable(self):
expected_return_value = ''
test_config = config.GitConfig('arbitrary', '.')
actual_return_value = test_config.__read_git_config__('unknown')
self.assertEqual(expected_return_value, actual_return_value)
def test_read_git_config_string_unknown(self):
expected_return_value = (False, None)
test_config = config.GitConfig('arbitrary', '.')
actual_return_value = test_config.__read_git_config_string__('unknown')
self.assertEqual(expected_return_value, actual_return_value)
def test_read(self):
class Dummy():
pass
test_config = config.GitConfig(Dummy(), '.')
with self.assertRaises(AttributeError):
self.assertFalse(test_config.run.hard)
test_config.read()
self.assertFalse(test_config.run.hard)