test_client.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # test_client.py -- Tests for the git protocol, client side
  2. # Copyright (C) 2009 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. # or (at your option) any later version of the License.
  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. from cStringIO import StringIO
  19. from unittest import TestCase
  20. from dulwich.client import (
  21. GitClient,
  22. )
  23. class GitClientTests(TestCase):
  24. def setUp(self):
  25. self.rout = StringIO()
  26. self.rin = StringIO()
  27. self.client = GitClient(lambda x: True, self.rin.read,
  28. self.rout.write)
  29. def test_caps(self):
  30. self.assertEquals(['multi_ack', 'side-band-64k', 'ofs-delta', 'thin-pack'], self.client._capabilities)
  31. def test_fetch_pack_none(self):
  32. self.rin.write(
  33. "008855dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 HEAD.multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag\n"
  34. "0000")
  35. self.rin.seek(0)
  36. self.client.fetch_pack("bla", lambda heads: [], None, None, None)
  37. self.assertEquals(self.rout.getvalue(), "0000")