test_GitModifier.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # vim: set fileencoding=utf-8 :
  2. """
  3. Test L{gbp.git.GitModifier}
  4. """
  5. from . import context
  6. def test_author():
  7. """
  8. Methods tested:
  9. - L{gbp.git.GitModifier.get_author_env}
  10. - L{gbp.git.GitModifier.get_committer_env}
  11. - L{gbp.git.GitModifier.keys}
  12. >>> import gbp.git
  13. >>> modifier = gbp.git.GitModifier('foo', 'bar')
  14. >>> modifier.name
  15. 'foo'
  16. >>> modifier.email
  17. 'bar'
  18. >>> modifier.get_author_env()['GIT_AUTHOR_EMAIL']
  19. 'bar'
  20. >>> modifier.get_author_env()['GIT_AUTHOR_NAME']
  21. 'foo'
  22. >>> modifier.get_committer_env()['GIT_COMMITTER_NAME']
  23. 'foo'
  24. >>> modifier.get_committer_env()['GIT_COMMITTER_EMAIL']
  25. 'bar'
  26. >>> modifier._get_env('foo')
  27. Traceback (most recent call last):
  28. ...
  29. GitModifierError: Neither committer nor author
  30. >>> modifier['name']
  31. 'foo'
  32. >>> modifier['email']
  33. 'bar'
  34. >>> modifier['date']
  35. """
  36. def test_date():
  37. """
  38. Methods tested:
  39. - L{gbp.git.GitModifier.__init__}
  40. Properties tested:
  41. - L{gbp.git.GitModifier.date}
  42. - L{gbp.git.GitModifier.datetime}
  43. - L{gbp.git.GitModifier.tz_offset}
  44. >>> import gbp.git
  45. >>> import datetime
  46. >>> modifier = gbp.git.GitModifier('foo', 'bar', 1)
  47. >>> modifier.date
  48. '1 +0000'
  49. >>> modifier.date = '1 +0400'
  50. >>> modifier.date
  51. '1 +0400'
  52. >>> modifier['date']
  53. '1 +0400'
  54. >>> modifier.datetime # doctest: +ELLIPSIS
  55. datetime.datetime(1970, 1, 1, 4, 0, 1, tzinfo=<gbp.git.modifier.GitTz...>)
  56. >>> modifier.date = datetime.datetime(1970, 1, 1, 0, 0, 1)
  57. >>> modifier.date
  58. '1 +0000'
  59. >>> modifier.datetime # doctest: +ELLIPSIS
  60. datetime.datetime(1970, 1, 1, 0, 0, 1, tzinfo=<gbp.git.modifier.GitTz...>)
  61. >>> modifier.tz_offset
  62. '+0000'
  63. """
  64. def test_dict():
  65. """
  66. Test C{dict} interface
  67. >>> import gbp.git
  68. >>> modifier = gbp.git.GitModifier('foo', 'bar', 1)
  69. >>> sorted(modifier.keys())
  70. ['date', 'email', 'name']
  71. >>> sorted(modifier.items())
  72. [('date', '1 +0000'), ('email', 'bar'), ('name', 'foo')]
  73. """