detect Windows UNC prefix for remote network drives
This commit is contained in:
parent
eef70499e7
commit
6b678942f0
6 changed files with 136 additions and 9 deletions
7
tests/samples/netuse/v1
Normal file
7
tests/samples/netuse/v1
Normal file
|
@ -0,0 +1,7 @@
|
|||
New connections will be remembered.
|
||||
|
||||
Status Local Remote Network
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
C: \\vboxsrv\Projects VirtualBox Shared Folders
|
||||
The command completed successfully.
|
8
tests/samples/netuse/v2
Normal file
8
tests/samples/netuse/v2
Normal file
|
@ -0,0 +1,8 @@
|
|||
New connections will be remembered.
|
||||
|
||||
Status Local Remote Network
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
C: \\vboxsrv\Projects VirtualBox Shared Folders
|
||||
OK D: \\192.0.0.1\work VirtualBox Shared Folders
|
||||
The command completed successfully.
|
|
@ -6,7 +6,7 @@ from wakatime.heartbeat import Heartbeat
|
|||
import os
|
||||
import logging
|
||||
from testfixtures import log_capture
|
||||
from .utils import TestCase
|
||||
from .utils import DynamicIterable, TestCase, mock
|
||||
|
||||
|
||||
class HeartbeatTestCase(TestCase):
|
||||
|
@ -116,3 +116,31 @@ class HeartbeatTestCase(TestCase):
|
|||
|
||||
self.assertNothingPrinted()
|
||||
self.assertNothingLogged(logs)
|
||||
|
||||
def test_parsing(self):
|
||||
|
||||
class Args(object):
|
||||
hide_file_names = ['.*']
|
||||
hide_project_names = []
|
||||
plugin = None
|
||||
|
||||
samples = [
|
||||
('v1', 'C:\\v1\\file.txt', '\\\\vboxsrv\\Projects\\v1\\file.txt'),
|
||||
('v2', 'D:\\stuff\\v2\\file.py', '\\\\192.0.0.1\\work\\stuff\\v2\\file.py'),
|
||||
]
|
||||
for sample, filepath, expected in samples:
|
||||
with mock.patch('wakatime.heartbeat.Popen') as mock_popen:
|
||||
|
||||
class MockCommunicate(object):
|
||||
pass
|
||||
|
||||
stdout = open('tests/samples/netuse/' + sample).read()
|
||||
mock_communicate = MockCommunicate()
|
||||
mock_communicate.communicate = mock.MagicMock(return_value=DynamicIterable((stdout, ''), max_calls=1))
|
||||
mock_popen.return_value = mock_communicate
|
||||
|
||||
heartbeat = Heartbeat({'user_agent': 'test'}, Args(), None, _clone=True)
|
||||
result = heartbeat._to_unc_path(filepath)
|
||||
self.assertEquals(expected, result)
|
||||
|
||||
self.assertNothingPrinted()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue