add test for --hidefilenames arg
This commit is contained in:
parent
fdba83a1c7
commit
62dfdc7993
2 changed files with 48 additions and 2 deletions
|
@ -377,6 +377,52 @@ class MainTestCase(utils.TestCase):
|
|||
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_hide_all_filenames_from_cli_arg(self):
|
||||
response = Response()
|
||||
response.status_code = 0
|
||||
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
|
||||
|
||||
with utils.TemporaryDirectory() as tempdir:
|
||||
entity = 'tests/samples/codefiles/twolinefile.txt'
|
||||
shutil.copy(entity, os.path.join(tempdir, 'twolinefile.txt'))
|
||||
entity = os.path.realpath(os.path.join(tempdir, 'twolinefile.txt'))
|
||||
now = u(int(time.time()))
|
||||
config = 'tests/samples/configs/good_config.cfg'
|
||||
key = str(uuid.uuid4())
|
||||
|
||||
args = ['--file', entity, '--key', key, '--config', config, '--time', now, '--hidefilenames']
|
||||
|
||||
retval = execute(args)
|
||||
self.assertEquals(retval, API_ERROR)
|
||||
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': 'Text only',
|
||||
'lines': 2,
|
||||
'entity': 'HIDDEN.txt',
|
||||
'project': os.path.basename(os.path.abspath('.')),
|
||||
'time': float(now),
|
||||
'type': 'file',
|
||||
}
|
||||
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(ANY, ANY, None)
|
||||
for key, val in self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].items():
|
||||
self.assertEquals(heartbeat[key], val)
|
||||
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_hide_matching_filenames(self):
|
||||
response = Response()
|
||||
response.status_code = 0
|
||||
|
|
|
@ -533,8 +533,8 @@ def format_file_path(filepath):
|
|||
try:
|
||||
filepath = os.path.realpath(os.path.abspath(filepath))
|
||||
filepath = re.sub(r'[/\\]', os.path.sep, filepath)
|
||||
except:
|
||||
pass # pragma: nocover
|
||||
except: # pragma: nocover
|
||||
pass
|
||||
return filepath
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue