def test_bareGitRepo(self): d = tempfile.TemporaryDirectory() self._createBareGitRepo(d.name) c = Config.fromGitRepo(d.name) self.assertTrue("Database" in c) self.assertTrue("master" in c) self.assertEqual(c["Database"]["Engine"], "sqlite") self.assertEqual(c.repoPath, d.name) c = Config.fromPath(d.name) self.assertTrue("Database" in c) self.assertTrue("master" in c) self.assertEqual(c["Database"]["Engine"], "sqlite") self.assertEqual(c.repoPath, d.name) d.cleanup()
def test_bareGitRepo(self): d = tempfile.TemporaryDirectory() self._createBareGitRepo(d.name) c = Config.fromGitRepo(d.name) self.assertTrue('Database' in c) self.assertTrue('master' in c) self.assertEqual(c['Database']['Engine'], 'sqlite') self.assertEqual(c.repoPath, d.name) c = Config.fromPath(d.name) self.assertTrue('Database' in c) self.assertTrue('master' in c) self.assertEqual(c['Database']['Engine'], 'sqlite') self.assertEqual(c.repoPath, d.name) d.cleanup()
def test_gitRepo(self): path = "/home/git/repositories/test.git" isdir = mock.MagicMock(return_value=True) git = mock.MagicMock() git.return_value = git git.getBranches.return_value = ["master", "development", "gitdh"] confFile = mock.MagicMock() confFile.getFileName.return_value = "gitdh.conf" confFile.getFileContent.return_value = self.cStr git.getFiles.return_value = [confFile] with mock.patch("gitdh.git.Git", new=git): c = Config.fromGitRepo(path) self.assertTrue("Database" in c) self.assertTrue("master" in c) self.assertEqual(c["Database"]["Engine"], "sqlite") self.assertEqual(c.repoPath, path) git.assert_called_once_with(path) git.getBranches.assert_called_once_with() git.getFiles.assert_called_once_with(branch="gitdh") confFile.getFileName.assert_called_once_with() confFile.getFileContent.assert_called_once_with() git.reset_mock() confFile.reset_mock() with mock.patch("os.path.isdir", new=isdir): c = Config.fromPath(path) self.assertTrue("Database" in c) self.assertTrue("master" in c) self.assertEqual(c["Database"]["Engine"], "sqlite") self.assertEqual(c.repoPath, path) git.assert_called_once_with(path) git.getBranches.assert_called_once_with() git.getFiles.assert_called_once_with(branch="gitdh") confFile.getFileName.assert_called_once_with() confFile.getFileContent.assert_called_once_with() isdir.assert_called_once_with(path)
def test_gitRepo(self): path = "/home/git/repositories/test.git" isdir = mock.MagicMock(return_value=True) git = mock.MagicMock() git.return_value = git git.getBranches.return_value = ["master", "development", "gitdh"] confFile = mock.MagicMock() confFile.getFileName.return_value = "gitdh.conf" confFile.getFileContent.return_value = self.cStr git.getFiles.return_value = [confFile] with mock.patch('gitdh.git.Git', new=git): c = Config.fromGitRepo(path) self.assertTrue('Database' in c) self.assertTrue('master' in c) self.assertEqual(c['Database']['Engine'], 'sqlite') self.assertEqual(c.repoPath, path) git.assert_called_once_with(path) git.getBranches.assert_called_once_with() git.getFiles.assert_called_once_with(branch='gitdh') confFile.getFileName.assert_called_once_with() confFile.getFileContent.assert_called_once_with() git.reset_mock() confFile.reset_mock() with mock.patch('os.path.isdir', new=isdir): c = Config.fromPath(path) self.assertTrue('Database' in c) self.assertTrue('master' in c) self.assertEqual(c['Database']['Engine'], 'sqlite') self.assertEqual(c.repoPath, path) git.assert_called_once_with(path) git.getBranches.assert_called_once_with() git.getFiles.assert_called_once_with(branch='gitdh') confFile.getFileName.assert_called_once_with() confFile.getFileContent.assert_called_once_with() isdir.assert_called_once_with(path)