示例#1
0
    def test_set_dns_entries(self, mock_client):
        # SETUP
        ds = DomainService('sundayafternoon')
        ds.build_cookie = Mock(return_value={"cookie": "value"})
        ds.update_cookie = Mock()

        i = mock_client.return_value
        i.service.setDnsEntries.return_value = None

        dns_entry = DnsEntry('testentry', 86400, DnsEntry.TYPE_A, '127.0.0.1')

        # CALL
        result = ds.set_dns_entries('domain1', [
            dns_entry,
        ])

        # VERIFY
        ds.build_cookie.assert_called_with(mode=MODE_RW,
                                           method='setDnsEntries',
                                           parameters=('domain1', [
                                               dns_entry,
                                           ]))
        ds.update_cookie.assert_called_with({"cookie": "value"})
        i.service.setDnsEntries.assert_called_with('domain1', [
            dns_entry,
        ])
示例#2
0
 def test_remove_dns_entries(self, mock_client):
     ds = DomainService('sundayafternoon')
     ds.build_cookie = Mock(return_value={'cookie': 'value'})
     ds.update_cookie = Mock()
     getinfo_result = Mock()
     dns_entry1 = DnsEntry(
         'testentry1',
         86400,
         DnsEntry.TYPE_A,
         '127.0.0.1',
     )
     dns_entry2 = DnsEntry(
         'testentry2',
         86400,
         DnsEntry.TYPE_A,
         '127.0.0.1',
     )
     getinfo_result.dnsEntries = [
         dns_entry1,
         dns_entry2,
     ]
     mock_client.return_value.service.getInfo.return_value = getinfo_result
     ds.remove_dns_entries('domain1', [dns_entry1])
     mock_client.return_value.service.setDnsEntries.assert_called_with(
         'domain1',
         [dns_entry2],
     )
示例#3
0
    def testGetDomains(self, mock_client):
        # SETUP
        ds = DomainService('sundayafternoon')
        ds.build_cookie = Mock(return_value={"cookie": "value"})
        ds.update_cookie = Mock()

        i = mock_client.return_value
        i.service.getDomainNames.return_value = ['domain1', 'domain2']

        # CALL
        result = ds.get_domain_names()

        # VERIFY
        ds.build_cookie.assert_called_with(mode=MODE_RO,
                                           method='getDomainNames')
        ds.update_cookie.assert_called_with({"cookie": "value"})
        i.service.getDomainNames.assert_called_with()
        self.assertEqual(result, ['domain1', 'domain2'])
示例#4
0
    def testGetInfo(self, mock_client):
        # SETUP
        ds = DomainService()
        ds.build_cookie = Mock(return_value={"cookie": "value"})
        ds.update_cookie = Mock()

        i = mock_client.return_value
        i.service.getInfo.return_value = ['foo']

        # CALL
        result = ds.get_info('example.com')

        # VERIFY
        ds.build_cookie.assert_called_with(mode=MODE_RO,
                                           method='getInfo',
                                           parameters=['example.com'])
        ds.update_cookie.assert_called_with({"cookie": "value"})
        i.service.getInfo.assert_called_with('example.com')
        self.assertEqual(result, ['foo'])
示例#5
0
    def test_get_info(self, mock_client):
        # SETUP
        ds = DomainService(login='******')
        ds.build_cookie = Mock(return_value={"cookie": "value"})
        ds.update_cookie = Mock()

        i = mock_client.return_value
        getinfo_result = Mock()
        getinfo_result.dnsEntries = [
            DnsEntry('testentry', 86400, DnsEntry.TYPE_A, '127.0.0.1')
        ]
        i.service.getInfo.return_value = getinfo_result

        # CALL
        result = ds.get_info('example.com')

        # VERIFY
        ds.build_cookie.assert_called_with(mode=MODE_RO,
                                           method='getInfo',
                                           parameters=['example.com'])
        ds.update_cookie.assert_called_with({"cookie": "value"})
        i.service.getInfo.assert_called_with('example.com')
        self.assertEqual(result, getinfo_result)