2021-03-04 06:01:39 +01:00
|
|
|
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):
|
2021-03-14 05:12:42 +01:00
|
|
|
expected_return_value = ''
|
2021-03-04 06:01:39 +01:00
|
|
|
test_config = config.GitConfig('arbitrary', '.')
|
2021-03-14 05:12:42 +01:00
|
|
|
actual_return_value = test_config.__read_git_config__('unknown')
|
|
|
|
self.assertEqual(expected_return_value, actual_return_value)
|
2021-03-04 06:01:39 +01:00
|
|
|
|
|
|
|
def test_read_git_config_string_unknown(self):
|
2021-03-14 05:12:42 +01:00
|
|
|
expected_return_value = (False, None)
|
2021-03-04 06:01:39 +01:00
|
|
|
test_config = config.GitConfig('arbitrary', '.')
|
2021-03-14 05:12:42 +01:00
|
|
|
actual_return_value = test_config.__read_git_config_string__('unknown')
|
|
|
|
self.assertEqual(expected_return_value, actual_return_value)
|
2021-03-04 06:01:39 +01:00
|
|
|
|
|
|
|
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)
|