From 22ddc41f253c595457cf953143246c5813cf7cc7 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Sat, 26 Sep 2015 19:12:54 -0700 Subject: [PATCH] test alternate api key config setting --- .../configs/sample_alternate_apikey.cfg | 14 +++++++++++++ tests/test_main.py | 20 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/samples/configs/sample_alternate_apikey.cfg diff --git a/tests/samples/configs/sample_alternate_apikey.cfg b/tests/samples/configs/sample_alternate_apikey.cfg new file mode 100644 index 0000000..fb89896 --- /dev/null +++ b/tests/samples/configs/sample_alternate_apikey.cfg @@ -0,0 +1,14 @@ +[settings] +debug = false +apikey = 1234 +ignore = + COMMIT_EDITMSG$ + TAG_EDITMSG$ +exclude = + excludeme + \(invalid regex) +include = + \(invalid regex) + includeme +offline = true +hidefilenames = false diff --git a/tests/test_main.py b/tests/test_main.py index 3650041..7f728e3 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -116,6 +116,26 @@ class BaseTestCase(utils.TestCase): self.patched['wakatime.offlinequeue.Queue.push'].assert_not_called() self.patched['wakatime.offlinequeue.Queue.pop'].assert_called_once_with() + def test_api_key_without_underscore_accepted(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_alternate_apikey.cfg' + args = ['--file', entity, '--config', config] + retval = execute(args) + self.assertEquals(retval, 0) + 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_not_called() + self.patched['wakatime.session_cache.SessionCache.save'].assert_called_once_with(ANY) + + self.patched['wakatime.offlinequeue.Queue.push'].assert_not_called() + self.patched['wakatime.offlinequeue.Queue.pop'].assert_called_once_with() + def test_bad_config_file(self): entity = 'tests/samples/codefiles/emptyfile.txt' config = 'tests/samples/configs/bad_config.cfg'