def test_cnameWithoutGlueRecords(self):
        """
        If an MX lookup returns a single CNAME record as a result, MXCalculator
        will perform an MX lookup for the canonical name indicated and return
        the MX record which results.
        """
        alias = "alias.example.com"
        canonical = "canonical.example.com"
        exchange = "mail.example.com"

        class DummyResolver(object):
            """
            Fake resolver which will return a CNAME for an MX lookup of a name
            which is an alias and an MX for an MX lookup of the canonical name.
            """
            def lookupMailExchange(self, domain):
                if domain == alias:
                    return defer.succeed((
                            [RRHeader(name=domain,
                                      type=Record_CNAME.TYPE,
                                      payload=Record_CNAME(canonical))],
                            [], []))
                elif domain == canonical:
                    return defer.succeed((
                            [RRHeader(name=domain,
                                      type=Record_MX.TYPE,
                                      payload=Record_MX(0, exchange))],
                            [], []))
                else:
                    return defer.fail(DNSNameError(domain))

        self.mx.resolver = DummyResolver()
        d = self.mx.getMX(alias)
        d.addCallback(self.assertEqual, Record_MX(name=exchange))
        return d
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/mail/test/test_mail.py/MXTestCase.test_cnameWithoutGlueRecords/original