test_blackbox.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # test_blackbox.py -- blackbox tests
  2. # Copyright (C) 2010 Jelmer Vernooij <jelmer@jelmer.uk>
  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 shutil
  22. import tempfile
  23. from dulwich.repo import Repo
  24. from . import BlackboxTestCase
  25. class GitReceivePackTests(BlackboxTestCase):
  26. """Blackbox tests for dul-receive-pack."""
  27. def setUp(self):
  28. super().setUp()
  29. self.path = tempfile.mkdtemp()
  30. self.addCleanup(shutil.rmtree, self.path)
  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"0000", stdout[-4:])
  36. self.assertEqual(0, process.returncode)
  37. def test_missing_arg(self):
  38. process = self.run_command("dul-receive-pack", [])
  39. (stdout, stderr) = process.communicate()
  40. self.assertEqual(
  41. [b"usage: dul-receive-pack <git-dir>"], stderr.splitlines()[-1:]
  42. )
  43. self.assertEqual(b"", stdout)
  44. self.assertEqual(1, process.returncode)
  45. class GitUploadPackTests(BlackboxTestCase):
  46. """Blackbox tests for dul-upload-pack."""
  47. def setUp(self):
  48. super().setUp()
  49. self.path = tempfile.mkdtemp()
  50. self.addCleanup(shutil.rmtree, self.path)
  51. self.repo = Repo.init(self.path)
  52. def test_missing_arg(self):
  53. process = self.run_command("dul-upload-pack", [])
  54. (stdout, stderr) = process.communicate()
  55. self.assertEqual(
  56. [b"usage: dul-upload-pack <git-dir>"], stderr.splitlines()[-1:]
  57. )
  58. self.assertEqual(b"", stdout)
  59. self.assertEqual(1, process.returncode)