from unittest import TestCase

from amqp.router.utils import sanitize_as_rabbitmq_name


class Test(TestCase):
    def test_sanitize_as_rabbitmq_name(self):
        self.assertEqual("aa.bb.cc", sanitize_as_rabbitmq_name("aa.bb/cc"))
        self.assertEqual("aa.bb.cc", sanitize_as_rabbitmq_name("aa-bb/cc"))
        self.assertEqual("aa", sanitize_as_rabbitmq_name("aa&bb/cc"))
        self.assertEqual("aa", sanitize_as_rabbitmq_name("aa+bb/cc"))
        self.assertEqual("aa", sanitize_as_rabbitmq_name("aa%bb/cc"))
        self.assertEqual("aa#bb.cc", sanitize_as_rabbitmq_name("aa#bb/cc"))
        self.assertEqual("aa#bb.cc.#", sanitize_as_rabbitmq_name("aa#bb/cc.#"))
        self.assertEqual("aa", sanitize_as_rabbitmq_name("aa?bb////cc"))
        self.assertEqual("aa.bb.cc", sanitize_as_rabbitmq_name("aa///bb////cc"))
