New argument --sync-offline-activity
This commit is contained in:
parent
1ae230639f
commit
722baba6e6
8 changed files with 127 additions and 3 deletions
|
@ -8,5 +8,6 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
|
|||
[--exclude-unknown-project] [--include INCLUDE]
|
||||
[--include-only-with-project-file] [--extra-heartbeats]
|
||||
[--log-file LOG_FILE] [--api-url API_URL] [--timeout TIMEOUT]
|
||||
[--sync-offline-activity SYNC_OFFLINE_ACTIVITY]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
wakatime: error: Missing api key. Find your api key from wakatime.com/settings/api-key.
|
||||
|
|
|
@ -8,5 +8,6 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
|
|||
[--exclude-unknown-project] [--include INCLUDE]
|
||||
[--include-only-with-project-file] [--extra-heartbeats]
|
||||
[--log-file LOG_FILE] [--api-url API_URL] [--timeout TIMEOUT]
|
||||
[--sync-offline-activity SYNC_OFFLINE_ACTIVITY]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
wakatime: error: Missing api key. Find your api key from wakatime.com/settings/api-key.
|
||||
|
|
|
@ -8,5 +8,6 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
|
|||
[--exclude-unknown-project] [--include INCLUDE]
|
||||
[--include-only-with-project-file] [--extra-heartbeats]
|
||||
[--log-file LOG_FILE] [--api-url API_URL] [--timeout TIMEOUT]
|
||||
[--sync-offline-activity SYNC_OFFLINE_ACTIVITY]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
wakatime: error: argument --timeout: invalid int value: 'abc'
|
||||
|
|
|
@ -8,6 +8,7 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN]
|
|||
[--exclude-unknown-project] [--include INCLUDE]
|
||||
[--include-only-with-project-file] [--extra-heartbeats]
|
||||
[--log-file LOG_FILE] [--api-url API_URL] [--timeout TIMEOUT]
|
||||
[--sync-offline-activity SYNC_OFFLINE_ACTIVITY]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
|
||||
Common interface for the WakaTime api.
|
||||
|
@ -76,6 +77,14 @@ optional arguments:
|
|||
--api-url API_URL Heartbeats api url. For debugging with a local server.
|
||||
--timeout TIMEOUT Number of seconds to wait when sending heartbeats to
|
||||
api. Defaults to 60 seconds.
|
||||
--sync-offline-activity SYNC_OFFLINE_ACTIVITY
|
||||
Amount of offline activity to sync from your local
|
||||
~/.wakatime.db sqlite3 file to your WakaTime Dashboard
|
||||
before exiting. Can be "none" or a positive integer
|
||||
number. Defaults to 5, meaning for every heartbeat
|
||||
sent while online 5 offline heartbeats are synced. Can
|
||||
be used without --entity to only sync offline activity
|
||||
without generating new heartbeats.
|
||||
--config CONFIG Defaults to ~/.wakatime.cfg.
|
||||
--verbose Turns on debug messages in log file.
|
||||
--version show program's version number and exit
|
||||
|
|
|
@ -230,6 +230,96 @@ class ArgumentsTestCase(TestCase):
|
|||
self.patched['wakatime.offlinequeue.Queue.push'].assert_not_called()
|
||||
self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called()
|
||||
|
||||
@log_capture()
|
||||
def test_missing_entity_argument_with_sync_offline_activity_arg(self, logs):
|
||||
logging.disable(logging.NOTSET)
|
||||
|
||||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = CustomResponse()
|
||||
|
||||
config = 'tests/samples/configs/good_config.cfg'
|
||||
args = ['--config', config, '--sync-offline-activity', '5']
|
||||
|
||||
retval = execute(args)
|
||||
|
||||
self.assertEquals(retval, SUCCESS)
|
||||
self.assertNothingPrinted()
|
||||
self.assertNothingLogged(logs)
|
||||
|
||||
self.assertHeartbeatNotSavedOffline()
|
||||
self.assertOfflineHeartbeatsSynced()
|
||||
|
||||
@log_capture()
|
||||
def test_missing_entity_argument_with_sync_offline_activity_none(self, logs):
|
||||
logging.disable(logging.NOTSET)
|
||||
|
||||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = CustomResponse()
|
||||
|
||||
config = 'tests/samples/configs/good_config.cfg'
|
||||
args = ['--config', config, '--sync-offline-activity', 'none']
|
||||
|
||||
with self.assertRaises(SystemExit) as e:
|
||||
execute(args)
|
||||
|
||||
self.assertEquals(int(str(e.exception)), 2)
|
||||
self.assertEquals(sys.stdout.getvalue(), '')
|
||||
expected = 'error: argument --entity is required'
|
||||
self.assertIn(expected, sys.stderr.getvalue())
|
||||
|
||||
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
|
||||
expected = ''
|
||||
self.assertEquals(log_output, expected)
|
||||
|
||||
self.assertHeartbeatNotSavedOffline()
|
||||
self.assertOfflineHeartbeatsNotSynced()
|
||||
|
||||
@log_capture()
|
||||
def test_invalid_sync_offline_activity(self, logs):
|
||||
logging.disable(logging.NOTSET)
|
||||
|
||||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = CustomResponse()
|
||||
|
||||
config = 'tests/samples/configs/good_config.cfg'
|
||||
args = ['--config', config, '--sync-offline-activity', 'all']
|
||||
|
||||
with self.assertRaises(SystemExit) as e:
|
||||
execute(args)
|
||||
|
||||
self.assertEquals(int(str(e.exception)), 2)
|
||||
self.assertEquals(sys.stdout.getvalue(), '')
|
||||
expected = 'error: argument --sync-offline-activity must be "none" or an integer number'
|
||||
self.assertIn(expected, sys.stderr.getvalue())
|
||||
|
||||
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
|
||||
expected = ''
|
||||
self.assertEquals(log_output, expected)
|
||||
|
||||
self.assertHeartbeatNotSavedOffline()
|
||||
self.assertOfflineHeartbeatsNotSynced()
|
||||
|
||||
@log_capture()
|
||||
def test_invalid_negative_sync_offline_activity(self, logs):
|
||||
logging.disable(logging.NOTSET)
|
||||
|
||||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = CustomResponse()
|
||||
|
||||
config = 'tests/samples/configs/good_config.cfg'
|
||||
args = ['--config', config, '--sync-offline-activity', '-1']
|
||||
|
||||
with self.assertRaises(SystemExit) as e:
|
||||
execute(args)
|
||||
|
||||
self.assertEquals(int(str(e.exception)), 2)
|
||||
self.assertEquals(sys.stdout.getvalue(), '')
|
||||
expected = 'error: argument --sync-offline-activity must be "none" or an integer number'
|
||||
self.assertIn(expected, sys.stderr.getvalue())
|
||||
|
||||
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
|
||||
expected = ''
|
||||
self.assertEquals(log_output, expected)
|
||||
|
||||
self.assertHeartbeatNotSavedOffline()
|
||||
self.assertOfflineHeartbeatsNotSynced()
|
||||
|
||||
@log_capture()
|
||||
def test_missing_api_key(self, logs):
|
||||
logging.disable(logging.NOTSET)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue