test_reflog.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # test_reflog.py -- tests for reflog.py
  2. # encoding: utf-8
  3. # Copyright (C) 2015 Jelmer Vernooij <jelmer@jelmer.uk>
  4. #
  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. """Tests for dulwich.reflog."""
  22. from dulwich.reflog import (
  23. format_reflog_line,
  24. parse_reflog_line,
  25. )
  26. from dulwich.tests import (
  27. TestCase,
  28. )
  29. class ReflogLineTests(TestCase):
  30. def test_format(self):
  31. self.assertEqual(
  32. b'0000000000000000000000000000000000000000 '
  33. b'49030649db3dfec5a9bc03e5dde4255a14499f16 Jelmer Vernooij '
  34. b'<jelmer@jelmer.uk> 1446552482 +0000 '
  35. b'clone: from git://jelmer.uk/samba',
  36. format_reflog_line(
  37. b'0000000000000000000000000000000000000000',
  38. b'49030649db3dfec5a9bc03e5dde4255a14499f16',
  39. b'Jelmer Vernooij <jelmer@jelmer.uk>',
  40. 1446552482, 0, b'clone: from git://jelmer.uk/samba'))
  41. self.assertEqual(
  42. b'0000000000000000000000000000000000000000 '
  43. b'49030649db3dfec5a9bc03e5dde4255a14499f16 Jelmer Vernooij '
  44. b'<jelmer@jelmer.uk> 1446552482 +0000 '
  45. b'clone: from git://jelmer.uk/samba',
  46. format_reflog_line(
  47. None,
  48. b'49030649db3dfec5a9bc03e5dde4255a14499f16',
  49. b'Jelmer Vernooij <jelmer@jelmer.uk>',
  50. 1446552482, 0, b'clone: from git://jelmer.uk/samba'))
  51. def test_parse(self):
  52. reflog_line = (
  53. b'0000000000000000000000000000000000000000 '
  54. b'49030649db3dfec5a9bc03e5dde4255a14499f16 Jelmer Vernooij '
  55. b'<jelmer@jelmer.uk> 1446552482 +0000 '
  56. b'clone: from git://jelmer.uk/samba'
  57. )
  58. self.assertEqual(
  59. (b'0000000000000000000000000000000000000000',
  60. b'49030649db3dfec5a9bc03e5dde4255a14499f16',
  61. b'Jelmer Vernooij <jelmer@jelmer.uk>',
  62. 1446552482, 0, b'clone: from git://jelmer.uk/samba'),
  63. parse_reflog_line(reflog_line))