예제 #1
0
def update_contact_consent(email_address,
                           accepts_dit_email_marketing,
                           modified_at=None,
                           **kwargs):
    """
    Update consent preferences.
    """
    consent.update_consent(
        email_address,
        accepts_dit_email_marketing,
        modified_at=modified_at,
        **kwargs,
    )
예제 #2
0
def update_contact_consent(email_address, accepts_dit_email_marketing, modified_at=None):
    """
    Archive inactive companies.
    """
    if not is_feature_flag_active(UPDATE_CONSENT_SERVICE_FEATURE_FLAG):
        logger.info(
            f'Feature flag "{UPDATE_CONSENT_SERVICE_FEATURE_FLAG}" is not active, exiting.',
        )
        return
    consent.update_consent(
        email_address,
        accepts_dit_email_marketing,
        modified_at=modified_at,
    )
예제 #3
0
 def test_forward_zipkin_headers(self, requests_mock):
     """
     Forward zipkin headers from origin request to the API call
     """
     headers = {
         'x-b3-traceid': '123',
         'x-b3-spanid': '456',
     }
     matcher = requests_mock.post(
         f'{settings.CONSENT_SERVICE_BASE_URL}'
         f'{consent.CONSENT_SERVICE_PERSON_PATH}',
         text=generate_hawk_response({
             'consents': [
                 CONSENT_SERVICE_EMAIL_CONSENT_TYPE,
             ],
             'modified_at': '2020-03-12T15:33:50.907000Z',
             'email': '*****@*****.**',
             'phone': '',
             'key_type': 'email',
         }),
         status_code=status.HTTP_201_CREATED,
     )
     result = consent.update_consent('*****@*****.**', False, None,
                                     headers=headers)
     assert result is None
     assert headers.items() <= matcher.last_request.headers.items()
     assert matcher.called_once
예제 #4
0
 def test_update(self, requests_mock, accepts_marketing):
     """
     Try to update consent status
     """
     matcher = requests_mock.post(
         f'{settings.CONSENT_SERVICE_BASE_URL}'
         f'{consent.CONSENT_SERVICE_PERSON_PATH}',
         text=generate_hawk_response({
             'consents': [
                 CONSENT_SERVICE_EMAIL_CONSENT_TYPE,
             ],
             'modified_at':
             '2020-03-12T15:33:50.907000Z',
             'email':
             '*****@*****.**',
             'phone':
             '',
             'key_type':
             'email',
         }),
         status_code=status.HTTP_201_CREATED,
     )
     result = consent.update_consent('*****@*****.**', accepts_marketing)
     assert result is None
     assert matcher.called_once