support regex patterns in projectmap config section

This commit is contained in:
Alan Hamlett 2016-04-18 21:34:00 +02:00
parent 5466fa478a
commit 615fa5cdac
4 changed files with 43 additions and 28 deletions

View file

@ -2,3 +2,5 @@
debug = false
api_key = 1234
[projectmap]
samples/projects/proj.{3}_map/ = proj-map
samples/projects/project_map(\d+)/ = proj-map{0}

View file

@ -160,18 +160,27 @@ class LanguagesTestCase(utils.TestCase):
response.status_code = 0
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
with tempfile.NamedTemporaryFile() as fh:
now = u(int(time.time()))
entity = 'tests/samples/projects/project_map/emptyfile.txt'
now = u(int(time.time()))
entity = 'tests/samples/projects/project_map/emptyfile.txt'
config = 'tests/samples/configs/project_map.cfg'
fh.write(open('tests/samples/configs/project_map.cfg').read().encode('utf-8'))
fh.write('{0} = proj-map'.format(os.path.realpath(os.path.dirname(os.path.dirname(entity)))).encode('utf-8'))
fh.flush()
args = ['--file', entity, '--config', config, '--time', now]
config = fh.name
execute(args)
args = ['--file', entity, '--config', config, '--time', now]
self.assertEquals('proj-map', self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['project'])
execute(args)
def test_project_map_group_usage(self):
response = Response()
response.status_code = 0
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
self.assertEquals('proj-map', self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['project'])
now = u(int(time.time()))
entity = 'tests/samples/projects/project_map42/emptyfile.txt'
config = 'tests/samples/configs/project_map.cfg'
args = ['--file', entity, '--config', config, '--time', now]
execute(args)
self.assertEquals('proj-map42', self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['project'])