You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4 KiB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. from . import constants
  4. import pytest
  5. # """
  6. # >>> import pEp
  7. # >>> me = pEp.Identity("alice.smith@peptest.ch", "Alice Smith", "23")
  8. # >>> me.username
  9. # 'Alice Smith'
  10. # >>> print(me)
  11. # Alice Smith <alice.smith@peptest.ch>
  12. # >>> you = pEp.Identity("bob.bourne@peptest.ch", "Bob Bourne", "42")
  13. # >>> print(you)
  14. # Bob Bourne <bob.bourne@peptest.ch>
  15. # >>> m = pEp.outgoing_message(me)
  16. # >>> m.to = [you]
  17. # >>> m.shortmsg = "let's meet next week"
  18. # >>> m.longmsg = "Please call me back"
  19. # >>> m2 = m.encrypt()
  20. # >>> print(m2)
  21. # >>> m3, keys, rating, flags = m2.decrypt()
  22. # >>> rating
  23. # pEp.rating.reliable
  24. # """
  25. #
  26. # if __name__ == "__main__":
  27. # import doctest
  28. # doctest.testmod()
  29. def test_basic(pEp, model):
  30. me = pEp.Identity(
  31. model.alice.addr,
  32. model.alice.name,
  33. model.alice.user_id
  34. )
  35. assert me.username == model.alice.name
  36. assert str(me) == str(model.alice)
  37. you = pEp.Identity(
  38. model.bob.addr,
  39. model.bob.name,
  40. model.bob.user_id
  41. )
  42. assert str(you) == str(model.bob)
  43. #TODO: pEp.outgoing_message() needs to return type pEp.Message not None
  44. m = pEp.outgoing_message(me)
  45. m.to = [you]
  46. m.shortmsg = constants.SUBJECT
  47. m.longmsg = constants.BODY
  48. #TODO: encrypt needs to return message type
  49. m2 = m.encrypt()
  50. m3, keys, rating, flags = m2.decrypt()
  51. #TODO: fix pEp.rating
  52. # assert rating == pEp.