test_blackbox.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # test_blackbox.py -- blackbox tests
  2. # Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; version 2
  7. # of the License or (at your option) a later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. # MA 02110-1301, USA.
  18. """Blackbox tests for Dulwich commands."""
  19. import tempfile
  20. from dulwich.repo import (
  21. Repo,
  22. )
  23. from dulwich.tests import (
  24. BlackboxTestCase,
  25. )
  26. class GitReceivePackTests(BlackboxTestCase):
  27. """Blackbox tests for dul-receive-pack."""
  28. def setUp(self):
  29. super(GitReceivePackTests, self).setUp()
  30. self.path = tempfile.mkdtemp()
  31. self.repo = Repo.init(self.path)
  32. def test_basic(self):
  33. process = self.run_command("dul-receive-pack", [self.path])
  34. (stdout, stderr) = process.communicate(b"0000")
  35. self.assertEqual(b'', stderr, stderr)
  36. self.assertEqual(b'0000', stdout[-4:])
  37. self.assertEqual(0, process.returncode)
  38. def test_missing_arg(self):
  39. process = self.run_command("dul-receive-pack", [])
  40. (stdout, stderr) = process.communicate()
  41. self.assertEqual([b'usage: dul-receive-pack <git-dir>'], stderr.splitlines())
  42. self.assertEqual(b'', stdout)
  43. self.assertEqual(1, process.returncode)
  44. class GitUploadPackTests(BlackboxTestCase):
  45. """Blackbox tests for dul-upload-pack."""
  46. def setUp(self):
  47. super(GitUploadPackTests, self).setUp()
  48. self.path = tempfile.mkdtemp()
  49. self.repo = Repo.init(self.path)
  50. def test_missing_arg(self):
  51. process = self.run_command("dul-upload-pack", [])
  52. (stdout, stderr) = process.communicate()
  53. self.assertEqual([b'usage: dul-upload-pack <git-dir>'], stderr.splitlines())
  54. self.assertEqual(b'', stdout)
  55. self.assertEqual(1, process.returncode)