test config file parsing with more config options

This commit is contained in:
Alan Hamlett 2015-09-29 22:34:14 -07:00
parent 5809fc0b84
commit 75aa9a2994
7 changed files with 44 additions and 28 deletions

View file

@ -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

View file

@ -29,7 +29,7 @@ class LanguagesTestCase(utils.TestCase):
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time())) now = u(int(time.time()))
config = 'tests/samples/configs/sample.cfg' config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/see.h' entity = 'tests/samples/codefiles/see.h'
args = ['--file', entity, '--config', config, '--time', now] 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 self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time())) 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' entity = 'tests/samples/codefiles/c_only/see.h'
args = ['--file', entity, '--config', config, '--time', now] 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 self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time())) 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' entity = 'tests/samples/codefiles/c_and_cpp/empty.h'
args = ['--file', entity, '--config', config, '--time', now] args = ['--file', entity, '--config', config, '--time', now]

View file

@ -15,7 +15,7 @@ from wakatime.packages.requests.models import Response
from . import utils from . import utils
class LanguagesTestCase(utils.TestCase): class LoggingTestCase(utils.TestCase):
patch_these = [ patch_these = [
'wakatime.packages.requests.adapters.HTTPAdapter.send', 'wakatime.packages.requests.adapters.HTTPAdapter.send',
'wakatime.offlinequeue.Queue.push', 'wakatime.offlinequeue.Queue.push',
@ -37,7 +37,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/codefiles/python.py' 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] args = ['--file', entity, '--config', config, '--time', now]
retval = execute(args) retval = execute(args)
@ -87,7 +87,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/codefiles/python.py' 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'] args = ['--file', entity, '--config', config, '--time', now, '--verbose']
retval = execute(args) retval = execute(args)

View file

@ -50,7 +50,7 @@ class BaseTestCase(utils.TestCase):
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
entity = 'tests/samples/codefiles/twolinefile.txt' 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] args = ['--file', entity, '--key', '123', '--config', config]
retval = execute(args) retval = execute(args)
@ -98,13 +98,13 @@ class BaseTestCase(utils.TestCase):
self.patched['wakatime.session_cache.SessionCache.get'].assert_not_called() self.patched['wakatime.session_cache.SessionCache.get'].assert_not_called()
def test_config_file(self): def test_good_config_file(self):
response = Response() response = Response()
response.status_code = 201 response.status_code = 201
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
entity = 'tests/samples/codefiles/emptyfile.txt' entity = 'tests/samples/codefiles/emptyfile.txt'
config = 'tests/samples/configs/sample.cfg' config = 'tests/samples/configs/has_everything.cfg'
args = ['--file', entity, '--config', config] args = ['--file', entity, '--config', config]
retval = execute(args) retval = execute(args)
self.assertEquals(retval, 0) self.assertEquals(retval, 0)
@ -158,7 +158,7 @@ class BaseTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/codefiles/twolinefile.txt' 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] args = ['--file', entity, '--key', '123', '--config', config, '--time', now]
@ -304,7 +304,7 @@ class BaseTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/codefiles/twolinefile.txt' 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] args = ['--file', entity, '--alternate-project', 'xyz', '--config', config, '--time', now]
@ -345,7 +345,7 @@ class BaseTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/codefiles/twolinefile.txt' 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] 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 self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
entity = 'tests/samples/codefiles/missingfile.txt' entity = 'tests/samples/codefiles/missingfile.txt'
config = 'tests/samples/configs/sample.cfg' config = 'tests/samples/configs/good_config.cfg'
args = ['--file', entity, '--config', config] args = ['--file', entity, '--config', config]
retval = execute(args) retval = execute(args)
self.assertEquals(retval, 0) self.assertEquals(retval, 0)
@ -405,7 +405,7 @@ class BaseTestCase(utils.TestCase):
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
entity = 'tests/samples/codefiles/emptyfile.txt' 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'] args = ['--file', entity, '--config', config, '--proxy', 'localhost:1234']
retval = execute(args) retval = execute(args)
self.assertEquals(retval, 0) self.assertEquals(retval, 0)
@ -427,7 +427,7 @@ class BaseTestCase(utils.TestCase):
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
entity = 'google.com' entity = 'google.com'
config = 'tests/samples/configs/sample.cfg' config = 'tests/samples/configs/good_config.cfg'
now = u(int(time.time())) now = u(int(time.time()))
args = ['--entity', entity, '--entitytype', 'domain', '--config', config, '--time', now] 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 self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
entity = 'Firefox' entity = 'Firefox'
config = 'tests/samples/configs/sample.cfg' config = 'tests/samples/configs/good_config.cfg'
now = u(int(time.time())) now = u(int(time.time()))
args = ['--entity', entity, '--entitytype', 'app', '--config', config, '--time', now] args = ['--entity', entity, '--entitytype', 'app', '--config', config, '--time', now]

View file

@ -35,7 +35,7 @@ class OfflineQueueTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/codefiles/twolinefile.txt' 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] args = ['--file', entity, '--config', config, '--time', now]
execute(args) execute(args)
@ -55,7 +55,7 @@ class OfflineQueueTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/codefiles/twolinefile.txt' 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] args = ['--file', entity, '--config', config, '--time', now]
execute(args) execute(args)
@ -75,7 +75,7 @@ class OfflineQueueTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/codefiles/twolinefile.txt' 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] args = ['--file', entity, '--config', config, '--time', now]
execute(args) execute(args)
@ -98,7 +98,7 @@ class OfflineQueueTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/codefiles/emptyfile.txt' 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] args = ['--file', entity, '--config', config, '--time', now]
execute(args) execute(args)
@ -120,7 +120,7 @@ class OfflineQueueTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/codefiles/twolinefile.txt' 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] args = ['--file', entity, '--config', config, '--time', now]
execute(args) execute(args)
@ -150,7 +150,7 @@ class OfflineQueueTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/codefiles/twolinefile.txt' 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: with utils.mock.patch('wakatime.offlinequeue.Queue.connect') as mock_connect:
mock_connect.side_effect = sqlite3.Error('') mock_connect.side_effect = sqlite3.Error('')

View file

@ -47,7 +47,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/projects/git/emptyfile.txt' 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] args = ['--project', 'forced-project', '--file', entity, '--config', config, '--time', now]
@ -62,7 +62,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/projects/wakatime_project_file/emptyfile.txt' 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] args = ['--file', entity, '--config', config, '--time', now]
@ -81,7 +81,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = os.path.join(tempdir, 'git', 'emptyfile.txt') 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] args = ['--file', entity, '--config', config, '--time', now]
@ -104,7 +104,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/projects/svn/afolder/emptyfile.txt' 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] args = ['--file', entity, '--config', config, '--time', now]
@ -128,7 +128,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/projects/svn/afolder/emptyfile.txt' 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] args = ['--file', entity, '--config', config, '--time', now]
@ -146,7 +146,7 @@ class LanguagesTestCase(utils.TestCase):
now = u(int(time.time())) now = u(int(time.time()))
entity = 'tests/samples/projects/hg/emptyfile.txt' 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] args = ['--file', entity, '--config', config, '--time', now]