diff --git a/tests/test_wakatime_languages.py b/tests/test_wakatime_languages.py index 8c656c7..fec6d24 100644 --- a/tests/test_wakatime_languages.py +++ b/tests/test_wakatime_languages.py @@ -11,6 +11,10 @@ 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: @@ -57,10 +61,18 @@ class LanguagesTestCase(utils.TestCase): 'time': float(now), 'type': 'file', } - stats = ANY + stats = { + u('cursorpos'): None, + u('dependencies'): ANY, + u('language'): u('Python'), + u('lineno'): None, + u('lines'): 26, + } + 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, stats, None) + 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() diff --git a/tests/test_wakatime_main.py b/tests/test_wakatime_main.py index 894fc56..bcb19fe 100644 --- a/tests/test_wakatime_main.py +++ b/tests/test_wakatime_main.py @@ -11,6 +11,10 @@ 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: @@ -126,9 +130,16 @@ class BaseTestCase(utils.TestCase): 'time': float(now), 'type': 'file', } - stats = ANY + stats = { + u('cursorpos'): None, + u('dependencies'): [], + u('language'): u('Text only'), + u('lineno'): None, + u('lines'): 2, + } - self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, stats, None) + self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, ANY, None) + 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_hidden_filename(self): @@ -160,9 +171,16 @@ class BaseTestCase(utils.TestCase): 'time': float(now), 'type': 'file', } - stats = ANY + stats = { + u('cursorpos'): None, + u('dependencies'): [], + u('language'): u('Text only'), + u('lineno'): None, + u('lines'): 2, + } - self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, stats, None) + self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, ANY, None) + 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_500_response(self): @@ -194,9 +212,16 @@ class BaseTestCase(utils.TestCase): 'time': float(now), 'type': 'file', } - stats = ANY + stats = { + u('cursorpos'): None, + u('dependencies'): [], + u('language'): u('Text only'), + u('lineno'): None, + u('lines'): 2, + } - self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, stats, None) + self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, ANY, None) + 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_400_response(self): @@ -251,9 +276,16 @@ class BaseTestCase(utils.TestCase): 'time': float(now), 'type': 'file', } - stats = ANY + stats = { + u('cursorpos'): None, + u('dependencies'): [], + u('language'): u('Text only'), + u('lineno'): None, + u('lines'): 2, + } - self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, stats, None) + self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, ANY, None) + 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_set_project_from_command_line(self): @@ -285,7 +317,14 @@ class BaseTestCase(utils.TestCase): 'time': float(now), 'type': 'file', } - stats = ANY + stats = { + u('cursorpos'): None, + u('dependencies'): [], + u('language'): u('Text only'), + u('lineno'): None, + u('lines'): 2, + } - self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, stats, None) + self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, ANY, None) + self.assertEquals(stats, json.loads(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][1])) self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called()