@@ -158,6 +158,13 @@ def test_wakatime_project_file(self):
158158 entity = 'projects/wakatime_project_file/emptyfile.txt' ,
159159 )
160160
161+ def test_wakatime_project_file_used_even_when_project_names_hidden (self ):
162+ self .shared (
163+ expected_project = 'waka-project-file' ,
164+ entity = 'projects/wakatime_project_file/emptyfile.txt' ,
165+ extra_args = ['--hide-project-names' ],
166+ )
167+
161168 def test_git_project_detected (self ):
162169 tempdir = tempfile .mkdtemp ()
163170 shutil .copytree ('tests/samples/projects/git' , os .path .join (tempdir , 'git' ))
@@ -169,6 +176,33 @@ def test_git_project_detected(self):
169176 entity = os .path .join (tempdir , 'git' , 'emptyfile.txt' ),
170177 )
171178
179+ def test_get_project_not_used_when_project_names_hidden (self ):
180+ response = Response ()
181+ response .status_code = 0
182+ self .patched ['wakatime.packages.requests.adapters.HTTPAdapter.send' ].return_value = response
183+
184+ tempdir = tempfile .mkdtemp ()
185+ shutil .copytree ('tests/samples/projects/git' , os .path .join (tempdir , 'git' ))
186+ shutil .move (os .path .join (tempdir , 'git' , 'dot_git' ), os .path .join (tempdir , 'git' , '.git' ))
187+
188+ now = u (int (time .time ()))
189+ entity = os .path .join (tempdir , 'git' , 'emptyfile.txt' )
190+ config = 'tests/samples/configs/good_config.cfg'
191+
192+ args = ['--hide-project-names' , '--file' , entity , '--config' , config , '--time' , now ]
193+
194+ execute (args )
195+ self .assertHeartbeatSavedOffline ()
196+
197+ self .assertNotEquals ('git' , self .patched ['wakatime.offlinequeue.Queue.push' ].call_args [0 ][0 ]['project' ])
198+ self .assertEquals (None , self .patched ['wakatime.offlinequeue.Queue.push' ].call_args [0 ][0 ]['branch' ])
199+ proj = open (os .path .join (tempdir , 'git' , '.wakatime-project' )).read ()
200+ self .assertEquals (proj , self .patched ['wakatime.offlinequeue.Queue.push' ].call_args [0 ][0 ]['project' ])
201+
202+ execute (args )
203+
204+ self .assertEquals (proj , self .patched ['wakatime.offlinequeue.Queue.push' ].call_args [0 ][0 ]['project' ])
205+
172206 @log_capture ()
173207 def test_ioerror_when_reading_git_branch (self , logs ):
174208 logging .disable (logging .NOTSET )
0 commit comments