def test_logged_call_to_registry(self, mock_localdate): mock_localdate.return_value = datetime(2017, 3, 8) self._init_logger() pubreq = DebugPublicRequest() form = self._get_send_password_form(pubreq) pubreq.logged_call_to_registry(form) properties = [('handle', 'foo.cz'), ('handleType', 'domain'), ('confirmMethod', 'signed_email'), ('sendTo', 'email_in_registry')] self.assertEqual(self.LOGGER.create_request.mock_calls, [ call('127.0.0.1', 'Public Request', PublicRequestsLogEntryType.AUTH_INFO, properties=properties), call().close(properties=[], references=[('publicrequest', 42)]), ]) self.assertEqual(self.LOGGER.create_request.return_value.result, 'Ok') cleaned_data = { 'handle': 'foo.cz', 'object_type': 'domain', 'confirmation_method': ConfirmationMethod.SIGNED_EMAIL, 'send_to': DeliveryType('email_in_registry', ''), } self.assertEqual(cache.get(pubreq.public_key), { 'cleaned_data': cleaned_data, 'public_request_id': 42 })
def get_initial(self): data = super(SendPasswordFormView, self).get_initial() data["handle"] = self.request.GET.get("handle") data["object_type"] = self.request.GET.get("object_type") send_to = self.request.GET.get("send_to") if send_to and send_to in (SEND_TO_IN_REGISTRY, SEND_TO_CUSTOM): data["send_to"] = DeliveryType(send_to, '') return data
def test_logged_call_to_registry_no_logger(self, mock_localdate): mock_localdate.return_value = datetime(2017, 3, 8) pubreq = DebugPublicRequest() form = SendPasswordForm({ "object_type": "domain", "handle": "foo.cz", "confirmation_method": "signed_email", "send_to_0": "email_in_registry", }) self.assertTrue(form.is_valid()) pubreq.logged_call_to_registry(form) cleaned_data = { 'handle': 'foo.cz', 'object_type': 'domain', 'confirmation_method': ConfirmationMethod.SIGNED_EMAIL, 'send_to': DeliveryType('email_in_registry', ''), } self.assertEqual(cache.get(pubreq.public_key), { 'cleaned_data': cleaned_data, 'public_request_id': 42 }) self.assertEqual(self.LOGGER.mock_calls, [])
def compress(self, data_list: Iterable) -> DeliveryType: """Return the ChoiceField value and CharField value.""" return DeliveryType(*data_list)