Ejemplo n.º 1
0
    def test_find_records(self):
        mock_connection = mock.Mock()
        zone = Zone(mock_connection, {})
        zone.id = None
        rr_names = ['amazon.com', 'amazon.com', 'aws.amazon.com',
                    'aws.amazon.com']
        mock_rrs = []
        # Create some mock resource records.
        for rr_name in rr_names:
            mock_rr = mock.Mock()
            mock_rr.name = rr_name
            mock_rr.type = 'A'
            mock_rr.weight = None
            mock_rr.region = None
            mock_rrs.append(mock_rr)

        # Set the last resource record to ``None``. The ``find_records`` loop
        # should never hit this.
        mock_rrs[3] = None

        mock_connection.get_all_rrsets.return_value = mock_rrs
        mock_connection._make_qualified.return_value = 'amazon.com'

        # Ensure that the ``None`` type object was not iterated over.
        try:
            result_rrs = zone.find_records('amazon.com', 'A', all=True)
        except AttributeError as e:
            self.fail("find_records() iterated too far into resource"
                      " record list.")

        # Determine that the resulting records are correct.
        self.assertEqual(result_rrs, [mock_rrs[0], mock_rrs[1]])
Ejemplo n.º 2
0
 def _get_records(self):
     """
 Returns all Route53 records for the domain.
 """
     zone = Zone(self.conn.route53, {'Id': self._hosted_zone_id})
     result = zone.find_records(self._domain, RecordType.CNAME, all=True)
     # Always return a list of records.
     if not result:
         return []
     elif isinstance(result, Record):
         return [result]
     else:
         return result
Ejemplo n.º 3
0
 def _get_records(self):
   """
   Returns all Route53 records for the domain.
   """
   zone = Zone(self.conn.route53, {'Id': self._hosted_zone_id})
   result = zone.find_records(self._domain, RecordType.CNAME, all=True)
   # Always return a list of records.
   if not result:
     return []
   elif isinstance(result, Record):
     return [result]
   else:
     return result