From 75aa9a2994d0b263108281301b7628c84c192cdb Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Tue, 29 Sep 2015 22:34:14 -0700 Subject: [PATCH] test config file parsing with more config options --- tests/samples/configs/has_everything.cfg | 16 +++++++++++++++ .../{sample.cfg => has_regex_errors.cfg} | 0 tests/test_languages.py | 6 +++--- tests/test_logging.py | 6 +++--- tests/test_main.py | 20 +++++++++---------- tests/test_offlinequeue.py | 12 +++++------ tests/test_project.py | 12 +++++------ 7 files changed, 44 insertions(+), 28 deletions(-) create mode 100644 tests/samples/configs/has_everything.cfg rename tests/samples/configs/{sample.cfg => has_regex_errors.cfg} (100%) diff --git a/tests/samples/configs/has_everything.cfg b/tests/samples/configs/has_everything.cfg new file mode 100644 index 0000000..139d063 --- /dev/null +++ b/tests/samples/configs/has_everything.cfg @@ -0,0 +1,16 @@ +[settings] +verbose = true +api_key = 1234567 +logfile = /tmp/waka +hidefilenames = true +exclude = + ^COMMIT_EDITMSG$ + ^TAG_EDITMSG$ + ^/var/ + ^/etc/ +include = + .* +offline = false +proxy = https://user:pass@localhost:8080 +timeout = abc +api_url = https://localhost:0/api/v1/heartbeats diff --git a/tests/samples/configs/sample.cfg b/tests/samples/configs/has_regex_errors.cfg similarity index 100% rename from tests/samples/configs/sample.cfg rename to tests/samples/configs/has_regex_errors.cfg diff --git a/tests/test_languages.py b/tests/test_languages.py index 74ca7f3..45562a8 100644 --- a/tests/test_languages.py +++ b/tests/test_languages.py @@ -29,7 +29,7 @@ class LanguagesTestCase(utils.TestCase): self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response now = u(int(time.time())) - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' entity = 'tests/samples/codefiles/see.h' args = ['--file', entity, '--config', config, '--time', now] @@ -54,7 +54,7 @@ class LanguagesTestCase(utils.TestCase): self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response now = u(int(time.time())) - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' entity = 'tests/samples/codefiles/c_only/see.h' args = ['--file', entity, '--config', config, '--time', now] @@ -70,7 +70,7 @@ class LanguagesTestCase(utils.TestCase): self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response now = u(int(time.time())) - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' entity = 'tests/samples/codefiles/c_and_cpp/empty.h' args = ['--file', entity, '--config', config, '--time', now] diff --git a/tests/test_logging.py b/tests/test_logging.py index 3aeba33..eb99dfa 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -15,7 +15,7 @@ from wakatime.packages.requests.models import Response from . import utils -class LanguagesTestCase(utils.TestCase): +class LoggingTestCase(utils.TestCase): patch_these = [ 'wakatime.packages.requests.adapters.HTTPAdapter.send', 'wakatime.offlinequeue.Queue.push', @@ -37,7 +37,7 @@ class LanguagesTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/codefiles/python.py' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/has_regex_errors.cfg' args = ['--file', entity, '--config', config, '--time', now] retval = execute(args) @@ -87,7 +87,7 @@ class LanguagesTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/codefiles/python.py' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/has_regex_errors.cfg' args = ['--file', entity, '--config', config, '--time', now, '--verbose'] retval = execute(args) diff --git a/tests/test_main.py b/tests/test_main.py index 26dd1fe..1d16a39 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -50,7 +50,7 @@ class BaseTestCase(utils.TestCase): self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response entity = 'tests/samples/codefiles/twolinefile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--key', '123', '--config', config] retval = execute(args) @@ -98,13 +98,13 @@ class BaseTestCase(utils.TestCase): self.patched['wakatime.session_cache.SessionCache.get'].assert_not_called() - def test_config_file(self): + def test_good_config_file(self): response = Response() response.status_code = 201 self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response entity = 'tests/samples/codefiles/emptyfile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/has_everything.cfg' args = ['--file', entity, '--config', config] retval = execute(args) self.assertEquals(retval, 0) @@ -158,7 +158,7 @@ class BaseTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/codefiles/twolinefile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--key', '123', '--config', config, '--time', now] @@ -304,7 +304,7 @@ class BaseTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/codefiles/twolinefile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--alternate-project', 'xyz', '--config', config, '--time', now] @@ -345,7 +345,7 @@ class BaseTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/codefiles/twolinefile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--project', 'xyz', '--config', config, '--time', now] @@ -385,7 +385,7 @@ class BaseTestCase(utils.TestCase): self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response entity = 'tests/samples/codefiles/missingfile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config] retval = execute(args) self.assertEquals(retval, 0) @@ -405,7 +405,7 @@ class BaseTestCase(utils.TestCase): self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response entity = 'tests/samples/codefiles/emptyfile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config, '--proxy', 'localhost:1234'] retval = execute(args) self.assertEquals(retval, 0) @@ -427,7 +427,7 @@ class BaseTestCase(utils.TestCase): self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response entity = 'google.com' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' now = u(int(time.time())) args = ['--entity', entity, '--entitytype', 'domain', '--config', config, '--time', now] @@ -464,7 +464,7 @@ class BaseTestCase(utils.TestCase): self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response entity = 'Firefox' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' now = u(int(time.time())) args = ['--entity', entity, '--entitytype', 'app', '--config', config, '--time', now] diff --git a/tests/test_offlinequeue.py b/tests/test_offlinequeue.py index fcf3125..c4d21d2 100644 --- a/tests/test_offlinequeue.py +++ b/tests/test_offlinequeue.py @@ -35,7 +35,7 @@ class OfflineQueueTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/codefiles/twolinefile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config, '--time', now] execute(args) @@ -55,7 +55,7 @@ class OfflineQueueTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/codefiles/twolinefile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config, '--time', now] execute(args) @@ -75,7 +75,7 @@ class OfflineQueueTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/codefiles/twolinefile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config, '--time', now] execute(args) @@ -98,7 +98,7 @@ class OfflineQueueTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/codefiles/emptyfile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config, '--time', now] execute(args) @@ -120,7 +120,7 @@ class OfflineQueueTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/codefiles/twolinefile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config, '--time', now] execute(args) @@ -150,7 +150,7 @@ class OfflineQueueTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/codefiles/twolinefile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' with utils.mock.patch('wakatime.offlinequeue.Queue.connect') as mock_connect: mock_connect.side_effect = sqlite3.Error('') diff --git a/tests/test_project.py b/tests/test_project.py index f49e9f8..8f90bef 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -47,7 +47,7 @@ class LanguagesTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/projects/git/emptyfile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--project', 'forced-project', '--file', entity, '--config', config, '--time', now] @@ -62,7 +62,7 @@ class LanguagesTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/projects/wakatime_project_file/emptyfile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config, '--time', now] @@ -81,7 +81,7 @@ class LanguagesTestCase(utils.TestCase): now = u(int(time.time())) entity = os.path.join(tempdir, 'git', 'emptyfile.txt') - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config, '--time', now] @@ -104,7 +104,7 @@ class LanguagesTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/projects/svn/afolder/emptyfile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config, '--time', now] @@ -128,7 +128,7 @@ class LanguagesTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/projects/svn/afolder/emptyfile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config, '--time', now] @@ -146,7 +146,7 @@ class LanguagesTestCase(utils.TestCase): now = u(int(time.time())) entity = 'tests/samples/projects/hg/emptyfile.txt' - config = 'tests/samples/configs/sample.cfg' + config = 'tests/samples/configs/good_config.cfg' args = ['--file', entity, '--config', config, '--time', now]