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, ])
def setUp(self, mock_client): super(TestDomainService, self).setUp() self.service = DomainService(login='******') self.service.build_cookie = Mock(return_value={"cookie": "value"}) self.service.update_cookie = Mock() self.i = mock_client.return_value
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'])
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'])
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], )
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)
def test_constructor(self): # CALL ds = DomainService(login='******') # VERIFY self.assertEqual(ds.url, 'https://api.transip.nl/wsdl/?service=DomainService')
def testConstructor(self): # CALL ds = DomainService() # VERIFY self.assertEqual(ds.url, 'https://api.transip.nl/wsdl/?service=DomainService')