From a0f6006ae7613ba08480bfccac300ea7c7de9af4 Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Thu, 30 Sep 2021 14:24:26 -0700 Subject: [PATCH] git_config: Fixed test.gitconfig getting updated when running tests. Moved test_GetSyncAnalysisStateData to GitConfigReadWriteTests class. Deleted [repo "syncstate*..] data from tests/fixtures/test.gitconfig. Tested: ./run_tests ... tests/test_git_config.py::GitConfigReadWriteTests::test_GetSyncAnalysisStateData PASSED [ 84%] ... Bug: https://crbug.com/gerrit/15103 Change-Id: I8cb89ce10b025994a045106c9c66dd243ae8ba50 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/319557 Tested-by: Raman Tenneti Reviewed-by: Mike Frysinger --- tests/fixtures/test.gitconfig | 10 --------- tests/test_git_config.py | 38 +++++++++++++++++------------------ 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/tests/fixtures/test.gitconfig b/tests/fixtures/test.gitconfig index b178cf60..9b3f2574 100644 --- a/tests/fixtures/test.gitconfig +++ b/tests/fixtures/test.gitconfig @@ -11,13 +11,3 @@ intk = 10k intm = 10m intg = 10g -[repo "syncstate.main"] - synctime = 2021-09-14T17:23:43.537338Z - version = 1 -[repo "syncstate.sys"] - argv = ['/usr/bin/pytest-3'] -[repo "syncstate.superproject"] - test = false -[repo "syncstate.options"] - verbose = true - mpupdate = false diff --git a/tests/test_git_config.py b/tests/test_git_config.py index faf12a2e..a4fad9ef 100644 --- a/tests/test_git_config.py +++ b/tests/test_git_config.py @@ -104,25 +104,6 @@ class GitConfigReadOnlyTests(unittest.TestCase): for key, value in TESTS: self.assertEqual(value, self.config.GetInt('section.%s' % (key,))) - def test_GetSyncAnalysisStateData(self): - """Test config entries with a sync state analysis data.""" - superproject_logging_data = {} - superproject_logging_data['test'] = False - options = type('options', (object,), {})() - options.verbose = 'true' - options.mp_update = 'false' - TESTS = ( - ('superproject.test', 'false'), - ('options.verbose', 'true'), - ('options.mpupdate', 'false'), - ('main.version', '1'), - ) - self.config.UpdateSyncAnalysisState(options, superproject_logging_data) - sync_data = self.config.GetSyncAnalysisStateData() - for key, value in TESTS: - self.assertEqual(sync_data[f'{git_config.SYNC_STATE_PREFIX}{key}'], value) - self.assertTrue(sync_data[f'{git_config.SYNC_STATE_PREFIX}main.synctime']) - class GitConfigReadWriteTests(unittest.TestCase): """Read/write tests of the GitConfig class.""" @@ -187,6 +168,25 @@ class GitConfigReadWriteTests(unittest.TestCase): config = self.get_config() self.assertIsNone(config.GetBoolean('foo.bar')) + def test_GetSyncAnalysisStateData(self): + """Test config entries with a sync state analysis data.""" + superproject_logging_data = {} + superproject_logging_data['test'] = False + options = type('options', (object,), {})() + options.verbose = 'true' + options.mp_update = 'false' + TESTS = ( + ('superproject.test', 'false'), + ('options.verbose', 'true'), + ('options.mpupdate', 'false'), + ('main.version', '1'), + ) + self.config.UpdateSyncAnalysisState(options, superproject_logging_data) + sync_data = self.config.GetSyncAnalysisStateData() + for key, value in TESTS: + self.assertEqual(sync_data[f'{git_config.SYNC_STATE_PREFIX}{key}'], value) + self.assertTrue(sync_data[f'{git_config.SYNC_STATE_PREFIX}main.synctime']) + if __name__ == '__main__': unittest.main()