2
0

test_blackbox.py 2.6 KB

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