test_blackbox.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # test_blackbox.py -- blackbox tests
  2. # Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
  3. #
  4. # Dulwich is dual-licensed under the Apache License, Version 2.0 and the GNU
  5. # General Public License as public by the Free Software Foundation; version 2.0
  6. # or (at your option) any later version. You can redistribute it and/or
  7. # modify it under the terms of either of these two licenses.
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. #
  15. # You should have received a copy of the licenses; if not, see
  16. # <http://www.gnu.org/licenses/> for a copy of the GNU General Public License
  17. # and <http://www.apache.org/licenses/LICENSE-2.0> for a copy of the Apache
  18. # License, Version 2.0.
  19. #
  20. """Blackbox tests for Dulwich commands."""
  21. import tempfile
  22. import shutil
  23. from dulwich.repo import (
  24. Repo,
  25. )
  26. from dulwich.tests import (
  27. BlackboxTestCase,
  28. )
  29. class GitReceivePackTests(BlackboxTestCase):
  30. """Blackbox tests for dul-receive-pack."""
  31. def setUp(self):
  32. super(GitReceivePackTests, self).setUp()
  33. self.path = tempfile.mkdtemp()
  34. self.addCleanup(shutil.rmtree, self.path)
  35. self.repo = Repo.init(self.path)
  36. def test_basic(self):
  37. process = self.run_command("dul-receive-pack", [self.path])
  38. (stdout, stderr) = process.communicate(b"0000")
  39. self.assertEqual(b'0000', stdout[-4:])
  40. self.assertEqual(0, process.returncode)
  41. def test_missing_arg(self):
  42. process = self.run_command("dul-receive-pack", [])
  43. (stdout, stderr) = process.communicate()
  44. self.assertEqual(
  45. [b'usage: dul-receive-pack <git-dir>'],
  46. stderr.splitlines()[-1:])
  47. self.assertEqual(b'', stdout)
  48. self.assertEqual(1, process.returncode)
  49. class GitUploadPackTests(BlackboxTestCase):
  50. """Blackbox tests for dul-upload-pack."""
  51. def setUp(self):
  52. super(GitUploadPackTests, self).setUp()
  53. self.path = tempfile.mkdtemp()
  54. self.addCleanup(shutil.rmtree, self.path)
  55. self.repo = Repo.init(self.path)
  56. def test_missing_arg(self):
  57. process = self.run_command("dul-upload-pack", [])
  58. (stdout, stderr) = process.communicate()
  59. self.assertEqual(
  60. [b'usage: dul-upload-pack <git-dir>'],
  61. stderr.splitlines()[-1:])
  62. self.assertEqual(b'', stdout)
  63. self.assertEqual(1, process.returncode)