From 3c5702ac14a7121371a7b1d9e2e38309166a5606 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 30 2017 15:31:50 +0000 Subject: Add a check that the file lock is being called Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py index f53abe8..b05e95d 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -1517,11 +1517,13 @@ index 458821a..77674a8 #print patch self.assertEqual(patch, exp) - def test_clean_git(self): + @patch('filelock.FileLock') + def test_clean_git(self, mock_fl): """ Test the clean_git method of pagure.lib.git. """ pagure.lib.git.clean_git(None, None, None) self.test_update_git() + self.assertEqual(mock_fl.call_count, 3) gitpath = os.path.join(self.path, 'test_ticket_repo.git') gitrepo = pygit2.init_repository(gitpath, bare=True) @@ -1543,6 +1545,9 @@ index 458821a..77674a8 issue = pagure.lib.search_issues(self.session, repo, issueid=1) pagure.lib.git.clean_git(issue, repo, self.path) + # 4 times: 3 in test_update_git + 1 here + self.assertEqual(mock_fl.call_count, 4) + # No more files in the git repo commit = gitrepo.revparse_single('HEAD') files = [entry.name for entry in commit.tree]