test_client.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 dulwich.client import (
  20. GitClient,
  21. )
  22. from dulwich.tests import (
  23. TestCase,
  24. )
  25. # TODO(durin42): add unit-level tests of GitClient
  26. class GitClientTests(TestCase):
  27. def setUp(self):
  28. super(GitClientTests, self).setUp()
  29. self.rout = StringIO()
  30. self.rin = StringIO()
  31. self.client = GitClient(lambda x: True, self.rin.read,
  32. self.rout.write)
  33. def test_caps(self):
  34. self.assertEquals(set(['multi_ack', 'side-band-64k', 'ofs-delta',
  35. 'thin-pack']),
  36. set(self.client._fetch_capabilities))
  37. self.assertEquals(set(['ofs-delta', 'report-status']),
  38. set(self.client._send_capabilities))
  39. def test_fetch_pack_none(self):
  40. self.rin.write(
  41. "008855dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 HEAD.multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag\n"
  42. "0000")
  43. self.rin.seek(0)
  44. self.client.fetch_pack("bla", lambda heads: [], None, None, None)
  45. self.assertEquals(self.rout.getvalue(), "0000")