test config file parsing with more config options
This commit is contained in:
parent
5809fc0b84
commit
75aa9a2994
7 changed files with 44 additions and 28 deletions
16
tests/samples/configs/has_everything.cfg
Normal file
16
tests/samples/configs/has_everything.cfg
Normal 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
|
|
@ -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]
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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('')
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
Loading…
Reference in a new issue