tests for verbose logging
This commit is contained in:
parent
f1e08d9e85
commit
cde35d7ccd
2 changed files with 30 additions and 2 deletions
|
@ -74,3 +74,31 @@ class LanguagesTestCase(utils.TestCase):
|
||||||
self.assertEquals(logging.WARNING, logging.getLogger('WakaTime').level)
|
self.assertEquals(logging.WARNING, logging.getLogger('WakaTime').level)
|
||||||
self.assertEquals(logfile, logging.getLogger('WakaTime').handlers[0].baseFilename)
|
self.assertEquals(logfile, logging.getLogger('WakaTime').handlers[0].baseFilename)
|
||||||
logs.check()
|
logs.check()
|
||||||
|
|
||||||
|
@log_capture()
|
||||||
|
def test_verbose_flag_enables_verbose_logging(self, logs):
|
||||||
|
logging.disable(logging.NOTSET)
|
||||||
|
|
||||||
|
response = Response()
|
||||||
|
response.status_code = 0
|
||||||
|
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
||||||
|
|
||||||
|
now = u(int(time.time()))
|
||||||
|
entity = 'tests/samples/codefiles/python.py'
|
||||||
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
args = ['--file', entity, '--config', config, '--time', now, '--verbose']
|
||||||
|
|
||||||
|
retval = execute(args)
|
||||||
|
self.assertEquals(retval, 102)
|
||||||
|
self.assertEquals(sys.stdout.getvalue(), '')
|
||||||
|
self.assertEquals(sys.stderr.getvalue(), '')
|
||||||
|
|
||||||
|
self.assertEquals(logging.DEBUG, logging.getLogger('WakaTime').level)
|
||||||
|
logfile = os.path.realpath(os.path.expanduser('~/.wakatime.log'))
|
||||||
|
self.assertEquals(logfile, logging.getLogger('WakaTime').handlers[0].baseFilename)
|
||||||
|
output = [u(' ').join(x) for x in logs.actual()]
|
||||||
|
self.assertEquals(output[0], u('WakaTime WARNING Regex error (unbalanced parenthesis) for include pattern: \\(invalid regex)'))
|
||||||
|
self.assertEquals(output[1], u('WakaTime WARNING Regex error (unbalanced parenthesis) for exclude pattern: \\(invalid regex)'))
|
||||||
|
self.assertEquals(output[2], u('WakaTime DEBUG Sending heartbeat to api at https://wakatime.com/api/v1/heartbeats'))
|
||||||
|
self.assertIn('Python', output[3])
|
||||||
|
self.assertIn('response_code', output[4])
|
||||||
|
|
|
@ -16,8 +16,8 @@ import sys
|
||||||
from .compat import u
|
from .compat import u
|
||||||
try:
|
try:
|
||||||
from collections import OrderedDict # pragma: nocover
|
from collections import OrderedDict # pragma: nocover
|
||||||
except ImportError:
|
except ImportError: # pragma: nocover
|
||||||
from .packages.ordereddict import OrderedDict # pragma: nocover
|
from .packages.ordereddict import OrderedDict
|
||||||
try:
|
try:
|
||||||
from .packages import simplejson as json # pragma: nocover
|
from .packages import simplejson as json # pragma: nocover
|
||||||
except (ImportError, SyntaxError): # pragma: nocover
|
except (ImportError, SyntaxError): # pragma: nocover
|
||||||
|
|
Loading…
Reference in a new issue