예제 #1
0
  def testWriteToYamlFile(self):
    with open(self.result_file_path, 'w') as yaml_file:
      export_util.WriteToYamlFile(yaml_file, util.GetRecordSetsForExport())

    with open(self.result_file_path) as results:
      with open(self.yaml_file_path) as expected:
        self.assertEqual(expected.read().splitlines(),
                         results.read().splitlines())
예제 #2
0
  def testWriteToZoneFile(self):
    with open(self.result_file_path, 'w') as zone_file:
      export_util.WriteToZoneFile(zone_file, util.GetRecordSetsForExport(),
                                  'zone.com.')

    with open(self.result_file_path) as results:
      with open(self.zone_file_path) as expected:
        self.assertEqual(expected.read().splitlines(),
                         results.read().splitlines())
  def testTransactionAddData(self):
    shutil.copyfile(
        self.initial_transaction, transaction_util.DEFAULT_PATH)

    test_zone = util.GetManagedZones()[0]
    test_record = util.GetRecordSetsForExport()[5]
    self.Run(
        'dns record-sets transaction add -z {0} --name {1} --ttl {2} --type '
        '{3} {4}'.format(test_zone.name, test_record.name,
                         test_record.ttl, test_record.type,
                         ' '.join(test_record.rrdatas)))
    self.AssertErrContains(
        'Record addition appended to transaction at [{0}].'.format(
            transaction_util.DEFAULT_PATH))

    with open(self.initial_transaction) as expected:
      expected_change = transaction_util.ChangeFromYamlFile(expected)
      expected_change.additions.append(test_record)
    with open(transaction_util.DEFAULT_PATH) as actual:
      actual_change = transaction_util.ChangeFromYamlFile(actual)
      self.assertEqual(expected_change, actual_change)
예제 #4
0
  def _ExportToFileHelper(self, expected_file, flags=''):
    test_zone = util.GetManagedZones()[0]
    self.mocked_dns_v1.managedZones.Get.Expect(
        self.messages.DnsManagedZonesGetRequest(
            managedZone=test_zone.name,
            project=self.Project()),
        test_zone)

    self.mocked_dns_v1.resourceRecordSets.List.Expect(
        self.messages.DnsResourceRecordSetsListRequest(
            project=self.Project(),
            managedZone=test_zone.name,
            maxResults=100),
        self.messages.ResourceRecordSetsListResponse(
            rrsets=util.GetRecordSetsForExport()))

    self.Run('dns record-sets export -z {0} {1} {2}'.format(
        test_zone.name, self.result_file_path, flags))
    with open(self.result_file_path) as results:
      with open(expected_file) as expected:
        self.assertEqual(expected.read().splitlines(),
                         results.read().splitlines())
예제 #5
0
 def testTransactionRemoveData(self):
   self._TransactionRemoveHelper(util.GetRecordSetsForExport()[5])
예제 #6
0
 def testTransactionRemoveDifferentRecord(self):
   self._TransactionRemoveNonExistingHelper(
       util.GetRecordSets()[0], util.GetRecordSetsForExport()[:1])