test_jabberjstrports.py 996 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. """
  4. Tests for L{twisted.words.protocols.jabber.jstrports}.
  5. """
  6. from __future__ import absolute_import, division
  7. from twisted.trial import unittest
  8. from twisted.words.protocols.jabber import jstrports
  9. from twisted.application.internet import TCPClient
  10. class JabberStrPortsPlaceHolderTests(unittest.TestCase):
  11. """
  12. Tests for L{jstrports}
  13. """
  14. def test_parse(self):
  15. """
  16. L{jstrports.parse} accepts an endpoint description string and returns a
  17. tuple and dict of parsed endpoint arguments.
  18. """
  19. expected = ('TCP', ('DOMAIN', 65535, 'Factory'), {})
  20. got = jstrports.parse("tcp:DOMAIN:65535", "Factory")
  21. self.assertEqual(expected, got)
  22. def test_client(self):
  23. """
  24. L{jstrports.client} returns a L{TCPClient} service.
  25. """
  26. got = jstrports.client("tcp:DOMAIN:65535", "Factory")
  27. self.assertIsInstance(got, TCPClient)