'If an MX lookup returns a CNAME and the MX record for the CNAME, the
L{Deferred} returned by L{MXCalculator.getMX} should be called back
with the name from the MX record without further lookups being
attempted.'

def test_cnameWithGlueRecords(self):

    lookedUp = []
    alias = 'alias.example.com'
    canonical = 'canonical.example.com'
    exchange = 'mail.example.com'
    class DummyResolver(object, ):
        def lookupMailExchange(self, domain):
            if ((domain != alias) or lookedUp):
                return ([], [], [])
            return defer.succeed(([RRHeader(name=alias, type=Record_CNAME.TYPE, payload=Record_CNAME(canonical)), RRHeader(name=canonical, type=Record_MX.TYPE, payload=Record_MX(name=exchange))], [], []))
    self.mx.resolver = DummyResolver()
    d = self.mx.getMX(alias)
    d.addCallback(self.assertEqual, Record_MX(name=exchange))
    return d
