test bower dependencies
This commit is contained in:
parent
8aa20da2f1
commit
9884eea311
15 changed files with 166 additions and 85 deletions
11
tests/samples/codefiles/bower.json
Normal file
11
tests/samples/codefiles/bower.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"name": "wakatime",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"animate.css": "latest",
|
||||||
|
"bootstrap": "latest",
|
||||||
|
"bootstrap-daterangepicker": "latest",
|
||||||
|
"moment": "latest",
|
||||||
|
"moment-timezone": "latest",
|
||||||
|
}
|
||||||
|
}
|
118
tests/test_dependencies.py
Normal file
118
tests/test_dependencies.py
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
from wakatime.main import execute
|
||||||
|
from wakatime.packages import requests
|
||||||
|
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
from wakatime.compat import u
|
||||||
|
from wakatime.packages.requests.models import Response
|
||||||
|
from . import utils
|
||||||
|
|
||||||
|
try:
|
||||||
|
from .packages import simplejson as json
|
||||||
|
except (ImportError, SyntaxError):
|
||||||
|
import json
|
||||||
|
try:
|
||||||
|
from mock import ANY
|
||||||
|
except ImportError:
|
||||||
|
from unittest.mock import ANY
|
||||||
|
|
||||||
|
|
||||||
|
class LanguagesTestCase(utils.TestCase):
|
||||||
|
patch_these = [
|
||||||
|
'wakatime.packages.requests.adapters.HTTPAdapter.send',
|
||||||
|
'wakatime.offlinequeue.Queue.push',
|
||||||
|
['wakatime.offlinequeue.Queue.pop', None],
|
||||||
|
'wakatime.session_cache.SessionCache.save',
|
||||||
|
'wakatime.session_cache.SessionCache.delete',
|
||||||
|
['wakatime.session_cache.SessionCache.get', requests.session],
|
||||||
|
]
|
||||||
|
|
||||||
|
def python_dependencies_detected(self):
|
||||||
|
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/good_config.cfg'
|
||||||
|
|
||||||
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
|
retval = execute(args)
|
||||||
|
self.assertEquals(retval, 102)
|
||||||
|
self.assertEquals(sys.stdout.getvalue(), '')
|
||||||
|
self.assertEquals(sys.stderr.getvalue(), '')
|
||||||
|
|
||||||
|
self.patched['wakatime.session_cache.SessionCache.get'].assert_called_once_with()
|
||||||
|
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
|
||||||
|
self.patched['wakatime.session_cache.SessionCache.save'].assert_not_called()
|
||||||
|
|
||||||
|
heartbeat = {
|
||||||
|
'language': u('Python'),
|
||||||
|
'lines': 27,
|
||||||
|
'entity': os.path.realpath(entity),
|
||||||
|
'project': u(os.path.basename(os.path.realpath('.'))),
|
||||||
|
'dependencies': ANY,
|
||||||
|
'branch': os.environ.get('TRAVIS_COMMIT', ANY),
|
||||||
|
'time': float(now),
|
||||||
|
'type': 'file',
|
||||||
|
}
|
||||||
|
stats = {
|
||||||
|
u('cursorpos'): None,
|
||||||
|
u('dependencies'): ANY,
|
||||||
|
u('language'): u('Python'),
|
||||||
|
u('lineno'): None,
|
||||||
|
u('lines'): 27,
|
||||||
|
}
|
||||||
|
expected_dependencies = ['wakatime', 'mock', 'django', 'simplejson', 'os']
|
||||||
|
|
||||||
|
self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, ANY, None)
|
||||||
|
for dep in expected_dependencies:
|
||||||
|
self.assertIn(dep, self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['dependencies'])
|
||||||
|
self.assertEquals(stats, json.loads(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][1]))
|
||||||
|
self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called()
|
||||||
|
|
||||||
|
def test_bower_dependencies_detected(self):
|
||||||
|
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/bower.json'
|
||||||
|
config = 'tests/samples/configs/good_config.cfg'
|
||||||
|
|
||||||
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
|
retval = execute(args)
|
||||||
|
self.assertEquals(sys.stdout.getvalue(), '')
|
||||||
|
self.assertEquals(sys.stderr.getvalue(), '')
|
||||||
|
self.assertEquals(retval, 102)
|
||||||
|
|
||||||
|
heartbeat = {
|
||||||
|
'language': u('JSON'),
|
||||||
|
'lines': 11,
|
||||||
|
'entity': os.path.realpath(entity),
|
||||||
|
'project': u(os.path.basename(os.path.realpath('.'))),
|
||||||
|
'dependencies': ANY,
|
||||||
|
'branch': os.environ.get('TRAVIS_COMMIT', ANY),
|
||||||
|
'time': float(now),
|
||||||
|
'type': 'file',
|
||||||
|
}
|
||||||
|
stats = {
|
||||||
|
u('cursorpos'): None,
|
||||||
|
u('dependencies'): ANY,
|
||||||
|
u('language'): u('JSON'),
|
||||||
|
u('lineno'): None,
|
||||||
|
u('lines'): 11,
|
||||||
|
}
|
||||||
|
expected_dependencies = ['animate.css', 'moment', 'moment-timezone']
|
||||||
|
|
||||||
|
self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, ANY, None)
|
||||||
|
for dep in expected_dependencies:
|
||||||
|
self.assertIn(dep, self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['dependencies'])
|
||||||
|
self.assertEquals(stats, json.loads(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][1]))
|
||||||
|
self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called()
|
|
@ -4,22 +4,11 @@
|
||||||
from wakatime.main import execute
|
from wakatime.main import execute
|
||||||
from wakatime.packages import requests
|
from wakatime.packages import requests
|
||||||
|
|
||||||
import os
|
|
||||||
import time
|
import time
|
||||||
import sys
|
|
||||||
from wakatime.compat import u
|
from wakatime.compat import u
|
||||||
from wakatime.packages.requests.models import Response
|
from wakatime.packages.requests.models import Response
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
try:
|
|
||||||
from .packages import simplejson as json
|
|
||||||
except (ImportError, SyntaxError):
|
|
||||||
import json
|
|
||||||
try:
|
|
||||||
from mock import ANY
|
|
||||||
except ImportError:
|
|
||||||
from unittest.mock import ANY
|
|
||||||
|
|
||||||
|
|
||||||
class LanguagesTestCase(utils.TestCase):
|
class LanguagesTestCase(utils.TestCase):
|
||||||
patch_these = [
|
patch_these = [
|
||||||
|
@ -31,59 +20,13 @@ class LanguagesTestCase(utils.TestCase):
|
||||||
['wakatime.session_cache.SessionCache.get', requests.session],
|
['wakatime.session_cache.SessionCache.get', requests.session],
|
||||||
]
|
]
|
||||||
|
|
||||||
def test_python_dependencies_detected(self):
|
|
||||||
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/sample.cfg'
|
|
||||||
|
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
|
||||||
|
|
||||||
retval = execute(args)
|
|
||||||
self.assertEquals(retval, 102)
|
|
||||||
self.assertEquals(sys.stdout.getvalue(), '')
|
|
||||||
self.assertEquals(sys.stderr.getvalue(), '')
|
|
||||||
|
|
||||||
self.patched['wakatime.session_cache.SessionCache.get'].assert_called_once_with()
|
|
||||||
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
|
|
||||||
self.patched['wakatime.session_cache.SessionCache.save'].assert_not_called()
|
|
||||||
|
|
||||||
heartbeat = {
|
|
||||||
'language': u('Python'),
|
|
||||||
'lines': 27,
|
|
||||||
'entity': os.path.realpath(entity),
|
|
||||||
'project': u(os.path.basename(os.path.realpath('.'))),
|
|
||||||
'dependencies': ANY,
|
|
||||||
'branch': os.environ.get('TRAVIS_COMMIT', ANY),
|
|
||||||
'time': float(now),
|
|
||||||
'type': 'file',
|
|
||||||
}
|
|
||||||
stats = {
|
|
||||||
u('cursorpos'): None,
|
|
||||||
u('dependencies'): ANY,
|
|
||||||
u('language'): u('Python'),
|
|
||||||
u('lineno'): None,
|
|
||||||
u('lines'): 27,
|
|
||||||
}
|
|
||||||
expected_dependencies = ['wakatime', 'mock', 'django', 'simplejson', 'os']
|
|
||||||
expected_dependencies = ['wakatime', 'mock', 'django', 'simplejson', 'os']
|
|
||||||
|
|
||||||
self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, ANY, None)
|
|
||||||
for dep in expected_dependencies:
|
|
||||||
self.assertIn(dep, self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['dependencies'])
|
|
||||||
self.assertEquals(stats, json.loads(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][1]))
|
|
||||||
self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called()
|
|
||||||
|
|
||||||
def test_language_detected_for_header_file(self):
|
def test_language_detected_for_header_file(self):
|
||||||
response = Response()
|
response = Response()
|
||||||
response.status_code = 500
|
response.status_code = 500
|
||||||
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/sample.cfg'
|
config = 'tests/samples/configs/sample.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]
|
||||||
|
|
||||||
|
@ -108,7 +51,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/sample.cfg'
|
config = 'tests/samples/configs/sample.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]
|
||||||
|
|
||||||
|
@ -124,7 +67,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/sample.cfg'
|
config = 'tests/samples/configs/sample.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]
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,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/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
retval = execute(args)
|
retval = execute(args)
|
||||||
|
@ -60,7 +60,7 @@ class LanguagesTestCase(utils.TestCase):
|
||||||
with tempfile.NamedTemporaryFile() as fh:
|
with tempfile.NamedTemporaryFile() as fh:
|
||||||
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/good_config.cfg'
|
config = 'tests/samples/configs/good_config.cfg'
|
||||||
logfile = os.path.realpath(fh.name)
|
logfile = os.path.realpath(fh.name)
|
||||||
args = ['--file', entity, '--config', config, '--time', now, '--logfile', logfile]
|
args = ['--file', entity, '--config', config, '--time', now, '--logfile', logfile]
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,9 @@ class BaseTestCase(utils.TestCase):
|
||||||
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
|
||||||
|
|
||||||
args = ['--file', 'tests/samples/codefiles/twolinefile.txt', '--key', '123', '--config', 'tests/samples/sample.cfg']
|
entity = 'tests/samples/codefiles/twolinefile.txt'
|
||||||
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
args = ['--file', entity, '--key', '123', '--config', config]
|
||||||
|
|
||||||
retval = execute(args)
|
retval = execute(args)
|
||||||
self.assertEquals(retval, 0)
|
self.assertEquals(retval, 0)
|
||||||
|
@ -62,7 +64,9 @@ class BaseTestCase(utils.TestCase):
|
||||||
self.patched['wakatime.offlinequeue.Queue.pop'].assert_called_once_with()
|
self.patched['wakatime.offlinequeue.Queue.pop'].assert_called_once_with()
|
||||||
|
|
||||||
def test_missing_config_file(self):
|
def test_missing_config_file(self):
|
||||||
args = ['--file', 'tests/samples/codefiles/emptyfile.txt', '--config', 'foo']
|
config = 'foo'
|
||||||
|
entity = 'tests/samples/codefiles/emptyfile.txt'
|
||||||
|
args = ['--file', entity, '--config', config]
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
execute(args)
|
execute(args)
|
||||||
expected_stdout = u("Error: Could not read from config file foo\n")
|
expected_stdout = u("Error: Could not read from config file foo\n")
|
||||||
|
@ -77,7 +81,9 @@ class BaseTestCase(utils.TestCase):
|
||||||
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
|
||||||
|
|
||||||
args = ['--file', 'tests/samples/codefiles/emptyfile.txt', '--config', 'tests/samples/sample.cfg']
|
entity = 'tests/samples/codefiles/emptyfile.txt'
|
||||||
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
args = ['--file', entity, '--config', config]
|
||||||
retval = execute(args)
|
retval = execute(args)
|
||||||
self.assertEquals(retval, 0)
|
self.assertEquals(retval, 0)
|
||||||
self.assertEquals(sys.stdout.getvalue(), '')
|
self.assertEquals(sys.stdout.getvalue(), '')
|
||||||
|
@ -91,7 +97,9 @@ class BaseTestCase(utils.TestCase):
|
||||||
self.patched['wakatime.offlinequeue.Queue.pop'].assert_called_once_with()
|
self.patched['wakatime.offlinequeue.Queue.pop'].assert_called_once_with()
|
||||||
|
|
||||||
def test_bad_config_file(self):
|
def test_bad_config_file(self):
|
||||||
args = ['--file', 'tests/samples/codefiles/emptyfile.txt', '--config', 'tests/samples/bad_config.cfg']
|
entity = 'tests/samples/codefiles/emptyfile.txt'
|
||||||
|
config = 'tests/samples/configs/bad_config.cfg'
|
||||||
|
args = ['--file', entity, '--config', config]
|
||||||
retval = execute(args)
|
retval = execute(args)
|
||||||
self.assertEquals(retval, 103)
|
self.assertEquals(retval, 103)
|
||||||
self.assertIn('ParsingError', sys.stdout.getvalue())
|
self.assertIn('ParsingError', sys.stdout.getvalue())
|
||||||
|
@ -108,7 +116,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/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--key', '123', '--config', config, '--time', now]
|
args = ['--file', entity, '--key', '123', '--config', config, '--time', now]
|
||||||
|
|
||||||
|
@ -149,7 +157,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/paranoid.cfg'
|
config = 'tests/samples/configs/paranoid.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--key', '123', '--config', config, '--time', now]
|
args = ['--file', entity, '--key', '123', '--config', config, '--time', now]
|
||||||
|
|
||||||
|
@ -191,7 +199,7 @@ class BaseTestCase(utils.TestCase):
|
||||||
now = u(int(time.time()))
|
now = u(int(time.time()))
|
||||||
|
|
||||||
args = ['--file', 'tests/samples/codefiles/twolinefile.txt', '--key', '123',
|
args = ['--file', 'tests/samples/codefiles/twolinefile.txt', '--key', '123',
|
||||||
'--config', 'tests/samples/paranoid.cfg', '--time', now]
|
'--config', 'tests/samples/configs/paranoid.cfg', '--time', now]
|
||||||
|
|
||||||
|
|
||||||
retval = execute(args)
|
retval = execute(args)
|
||||||
|
@ -232,7 +240,7 @@ class BaseTestCase(utils.TestCase):
|
||||||
now = u(int(time.time()))
|
now = u(int(time.time()))
|
||||||
|
|
||||||
args = ['--file', 'tests/samples/codefiles/twolinefile.txt', '--key', '123',
|
args = ['--file', 'tests/samples/codefiles/twolinefile.txt', '--key', '123',
|
||||||
'--config', 'tests/samples/paranoid.cfg', '--time', now]
|
'--config', 'tests/samples/configs/paranoid.cfg', '--time', now]
|
||||||
|
|
||||||
|
|
||||||
retval = execute(args)
|
retval = execute(args)
|
||||||
|
@ -254,7 +262,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/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--alternate-project', 'xyz', '--config', config, '--time', now]
|
args = ['--file', entity, '--alternate-project', 'xyz', '--config', config, '--time', now]
|
||||||
|
|
||||||
|
@ -295,7 +303,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/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--project', 'xyz', '--config', config, '--time', now]
|
args = ['--file', entity, '--project', 'xyz', '--config', config, '--time', now]
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,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/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
execute(args)
|
execute(args)
|
||||||
|
@ -44,7 +44,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/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
execute(args)
|
execute(args)
|
||||||
|
@ -60,7 +60,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/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
execute(args)
|
execute(args)
|
||||||
|
@ -81,7 +81,7 @@ class OfflineQueueTestCase(utils.TestCase):
|
||||||
|
|
||||||
now = u(int(time.time()))
|
now = u(int(time.time()))
|
||||||
entity = fh.name
|
entity = fh.name
|
||||||
config = 'tests/samples/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
execute(args)
|
execute(args)
|
||||||
|
|
|
@ -30,7 +30,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/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--project', 'forced-project', '--file', entity, '--config', config, '--time', now]
|
args = ['--project', 'forced-project', '--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
|
@ -45,7 +45,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/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
|
@ -64,7 +64,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/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
|
@ -81,13 +81,13 @@ class LanguagesTestCase(utils.TestCase):
|
||||||
mock_git.return_value = False
|
mock_git.return_value = False
|
||||||
|
|
||||||
with utils.mock.patch('wakatime.projects.subversion.Popen.communicate') as mock_popen:
|
with utils.mock.patch('wakatime.projects.subversion.Popen.communicate') as mock_popen:
|
||||||
stdout = open('tests/samples/svn_output').read()
|
stdout = open('tests/samples/output/svn').read()
|
||||||
stderr = ''
|
stderr = ''
|
||||||
mock_popen.return_value = (stdout, stderr)
|
mock_popen.return_value = (stdout, stderr)
|
||||||
|
|
||||||
now = u(int(time.time()))
|
now = u(int(time.time()))
|
||||||
entity = 'tests/samples/projects/svn/emptyfile.txt'
|
entity = 'tests/samples/projects/svn/emptyfile.txt'
|
||||||
config = 'tests/samples/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ class LanguagesTestCase(utils.TestCase):
|
||||||
|
|
||||||
now = u(int(time.time()))
|
now = u(int(time.time()))
|
||||||
entity = 'tests/samples/projects/svn/emptyfile.txt'
|
entity = 'tests/samples/projects/svn/emptyfile.txt'
|
||||||
config = 'tests/samples/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
|
@ -129,7 +129,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/sample.cfg'
|
config = 'tests/samples/configs/sample.cfg'
|
||||||
|
|
||||||
args = ['--file', entity, '--config', config, '--time', now]
|
args = ['--file', entity, '--config', config, '--time', now]
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ class LanguagesTestCase(utils.TestCase):
|
||||||
now = u(int(time.time()))
|
now = u(int(time.time()))
|
||||||
entity = 'tests/samples/projects/project_map/emptyfile.txt'
|
entity = 'tests/samples/projects/project_map/emptyfile.txt'
|
||||||
|
|
||||||
fh.write(open('tests/samples/project_map.cfg').read().encode('utf-8'))
|
fh.write(open('tests/samples/configs/project_map.cfg').read().encode('utf-8'))
|
||||||
fh.write('{0} = proj-map'.format(os.path.realpath(os.path.dirname(os.path.dirname(entity)))).encode('utf-8'))
|
fh.write('{0} = proj-map'.format(os.path.realpath(os.path.dirname(os.path.dirname(entity)))).encode('utf-8'))
|
||||||
fh.flush()
|
fh.flush()
|
||||||
|
|
||||||
|
|
|
@ -426,7 +426,8 @@ def execute(argv=None):
|
||||||
kwargs['stats'] = stats
|
kwargs['stats'] = stats
|
||||||
kwargs['hostname'] = args.hostname or socket.gethostname()
|
kwargs['hostname'] = args.hostname or socket.gethostname()
|
||||||
|
|
||||||
if send_heartbeat(**kwargs):
|
rv = send_heartbeat(**kwargs)
|
||||||
|
if rv:
|
||||||
queue = Queue()
|
queue = Queue()
|
||||||
while True:
|
while True:
|
||||||
heartbeat = queue.pop()
|
heartbeat = queue.pop()
|
||||||
|
|
Loading…
Reference in a new issue