From dc5dcf0cb18a7c464e4a22b9e57f8bd9b265afa3 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Mon, 7 Sep 2015 20:43:06 -0700 Subject: [PATCH] tests for project map config section --- tests/samples/project_map.cfg | 4 ++++ tests/test_wakatime_project.py | 21 +++++++++++++++++++++ wakatime/projects/base.py | 14 ++------------ 3 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 tests/samples/project_map.cfg diff --git a/tests/samples/project_map.cfg b/tests/samples/project_map.cfg new file mode 100644 index 0000000..b76ce1d --- /dev/null +++ b/tests/samples/project_map.cfg @@ -0,0 +1,4 @@ +[settings] +debug = false +api_key = 1234 +[projectmap] diff --git a/tests/test_wakatime_project.py b/tests/test_wakatime_project.py index 64dac35..399ea15 100644 --- a/tests/test_wakatime_project.py +++ b/tests/test_wakatime_project.py @@ -94,3 +94,24 @@ class LanguagesTestCase(utils.TestCase): execute(args) self.assertEquals('svn', self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['project']) + + def test_project_map(self): + response = Response() + 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' + + fh.write(open('tests/samples/project_map.cfg').read()) + fh.write('{0} = proj-map'.format(os.path.realpath(os.path.dirname(entity)))) + fh.flush() + + config = fh.name + + args = ['--file', entity, '--config', config, '--time', now] + + execute(args) + + self.assertEquals('proj-map', self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['project']) diff --git a/wakatime/projects/base.py b/wakatime/projects/base.py index 60c3ac4..882b035 100644 --- a/wakatime/projects/base.py +++ b/wakatime/projects/base.py @@ -25,22 +25,12 @@ class BaseProject(object): self.path = path self._configs = configs - def project_type(self): - """ Returns None if this is the base class. - Returns the type of project if this is a - valid project. - """ - project_type = self.__class__.__name__.lower() - if project_type == 'baseproject': - project_type = None - return project_type - def process(self): """ Processes self.path into a project and returns True if project is valid, otherwise returns False. """ - return False + return False # pragma: nocover def name(self): """ Returns the project's name. @@ -50,4 +40,4 @@ class BaseProject(object): def branch(self): """ Returns the current branch. """ - return None + return None # pragma: nocover