def test_dnsaas_returns_empty_json(self): cluster = ClusterFactory() IPAddressFactory(ethernet__base_object=cluster) cluster.baseobjectcluster_set.create( is_master=True, base_object=DataCenterAssetFullFactory( rack__name='Rack #1', rack__server_room__name='SR1', rack__server_room__data_center__name='DC1', )) httpretty.register_uri(httpretty.GET, "http://100.200.250.251/api/v2/records/", body={}) req = RequestFactory().get("/") # url doesn't matter (I hope) req.user = self.user mesgs = MagicMock() v = DNSView(object=cluster) with patch("ralph.dns.views.messages", mesgs): v.get_forms(req) mesgs.error.assert_called() msgtext = mesgs.error.call_args[0][1] expected = str(_("Invalid response from DNSaaS:")) assert msgtext.startswith(expected),\ "%s not in %s" % (expected, msgtext)
def test_dnsaasintegration_enabled(self): # should not raise exception DNSView()
def test_dnsaasintegration_disabled(self): with self.assertRaises(DNSaaSIntegrationNotEnabledError): DNSView()
def test_dnsaasintegration_enabled(self, _get_oauth_token_mock): # should not raise exception _get_oauth_token_mock.return_value = 'token' DNSView()