def test_normalize_it_normalizes_and_hashes(self):
        initial_state = {
            'f5first': 'First',
            'f5last': 'Last',
            'fi': 'A',
            'dobd': '01',
            'dobm': '02',
            'doby': '2000',
            'lead_id': 'lead-id-3',
        }
        user_data = UserData(
            f5first=initial_state['f5first'],
            f5last=initial_state['f5last'],
            fi=initial_state['fi'],
            dobd=initial_state['dobd'],
            dobm=initial_state['dobm'],
            doby=initial_state['doby'],
            lead_id=initial_state['lead_id'],
        )

        actual = user_data.normalize()
        expected = {
            'f5first':
            Normalize.hash_sha_256(initial_state['f5first'].lower()),
            'f5last': Normalize.hash_sha_256(initial_state['f5last'].lower()),
            'fi': Normalize.hash_sha_256(initial_state['fi'].lower()),
            'dobd': Normalize.hash_sha_256(initial_state['dobd']),
            'dobm': Normalize.hash_sha_256(initial_state['dobm']),
            'doby': Normalize.hash_sha_256(initial_state['doby']),
            'lead_id': initial_state['lead_id'],
        }

        self.assertEqual(actual, expected)
Exemplo n.º 2
0
    def test_normalize(self, normalize_mock, hash_sha_256_mock):
        initial_state = {
            'f5first': 'FirstName',
            'f5last': 'LastName',
            'fi': 'FI',
            'dobd': '01',
            'dobm': '02',
            'doby': '2000',
        }
        user_data = UserData(
            f5first=initial_state['f5first'],
            f5last=initial_state['f5last'],
            fi=initial_state['fi'],
            dobd=initial_state['dobd'],
            dobm=initial_state['dobm'],
            doby=initial_state['doby'],
        )
        hash_sha_256_mock.side_effect = (lambda field: field + '-sha256'
                                         if field else None)
        normalize_mock.side_effect = (lambda _, field: field + '-normal'
                                      if field else None)
        actual = user_data.normalize()
        expected = {}
        for key, value in initial_state.items():
            expected[key] = '%s-normal-sha256' % value

        self.assertEqual(actual, expected)
Exemplo n.º 3
0
def notify_view_content(product_id, url, remote_address, user_agent):
    user_data = UserData(
        # It is recommended to send Client IP and User Agent for Conversions API Events.
        client_ip_address=remote_address,
        client_user_agent=user_agent
        # fbc='fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890',
        # fbp='fb.1.1558571054389.1098115397',
    )

    content = Content(
        product_id=product_id,
    )

    custom_data = CustomData(
        contents=[content],
    )

    event = Event(
        event_name='ViewContent',
        event_time=int(time.time()),
        user_data=user_data,
        custom_data=custom_data,
        event_source_url=url,
        action_source=ActionSource.WEBSITE,
    )

    event_request = EventRequest(
        events=[event],
        pixel_id=FACEBOOK_PIXEL_ID,
    )

    event_response = event_request.execute()
Exemplo n.º 4
0
    def test_constructor(self):
        event_name = 'event_name-0'
        event_time = 123
        event_source_url = 'event_source_url-2'
        opt_out = False
        event_id = 'event_id-3'
        user_data = UserData(email='*****@*****.**')
        custom_data = CustomData(order_id=123)
        data_processing_options = ['4' '5']
        data_processing_options_country = 6
        data_processing_options_state = 7
        action_source = ActionSource.APP
        event = Event(
            event_name=event_name,
            event_time=event_time,
            event_source_url=event_source_url,
            opt_out=opt_out,
            event_id=event_id,
            user_data=user_data,
            custom_data=custom_data,
            data_processing_options=data_processing_options,
            data_processing_options_country=data_processing_options_country,
            data_processing_options_state=data_processing_options_state,
            action_source=action_source,
        )
        expected_params = {
            'event_name': event_name,
            'event_time': event_time,
            'event_source_url': event_source_url,
            'opt_out': opt_out,
            'event_id': event_id,
            'user_data': user_data.normalize(),
            'custom_data': custom_data.normalize(),
            'data_processing_options': data_processing_options,
            'data_processing_options_country': data_processing_options_country,
            'data_processing_options_state': data_processing_options_state,
            'action_source': action_source.value,
        }

        self.assertEqual(event.normalize(), expected_params)
Exemplo n.º 5
0
def notify_initiate_checkout(basket_id, user_id, url, remote_address, user_agent):
    basket = Basket.objects.get(id=basket_id)
    user_phone = None
    user_email = None
    if user_id:
        user = ShopUser.objects.get(id=user_id)
        user_phone = user.phone
        user_email = user.email

    user_data = UserData(
        email=user_email,
        phone=user_phone,
        # It is recommended to send Client IP and User Agent for Conversions API Events.
        client_ip_address=remote_address,
        client_user_agent=user_agent
        # fbc='fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890',
        # fbp='fb.1.1558571054389.1098115397',
    )

    contents = []
    for item in basket.items.all():
        contents.append(Content(
            product_id=item.product.id,
            title=item.product.title,
            brand=item.product.manufacturer.name,
            item_price=str(item.price.quantize(Decimal('1'), rounding=ROUND_HALF_EVEN)),
            quantity=item.quantity
        ))

    custom_data = CustomData(
        contents=contents,
        content_type='product',
        currency='rub',
        value=float(basket.total)
    )

    event = Event(
        event_name='InitiateCheckout',
        event_time=int(time.time()),
        user_data=user_data,
        custom_data=custom_data,
        event_source_url=url,
        action_source=ActionSource.WEBSITE,
    )

    event_request = EventRequest(
        events=[event],
        pixel_id=FACEBOOK_PIXEL_ID,
    )

    event_response = event_request.execute()
    log.error(event_response)
    def test_single_getters_and_setters_with_none(self):
        user_data = UserData()

        self.assertIsNone(user_data.email)
        self.assertIsNone(user_data.phone)
        self.assertIsNone(user_data.gender)
        self.assertIsNone(user_data.date_of_birth)
        self.assertIsNone(user_data.last_name)
        self.assertIsNone(user_data.first_name)
        self.assertIsNone(user_data.city)
        self.assertIsNone(user_data.state)
        self.assertIsNone(user_data.country_code)
        self.assertIsNone(user_data.zip_code)
        self.assertIsNone(user_data.external_id)
Exemplo n.º 7
0
def build_predicted_revenue_events(df, event_name):
    """
    Creates a list of Facebook Event objects which can be pushed to the Facebook Conversions API.
    Also creates DataFrame for logging which can be used to stream insert to a BigQuery log table.

    :param df: A DataFrame with the events to build Facebook events for
    :type df: pd.DataFrame

    Returns: A tuple with a list of Facebook events and a DataFrame for logs
    rtype: (list of Event, pd.DataFrame)
    """
    events = []
    logs = []
    for index, row in df.iterrows():
        date = int(time.mktime(datetime.strptime(row['date'], '%Y%m%d').timetuple()))
        user_data = UserData(
            country_code=row['shop'],
            fbp=row['facebook_browser_id']
        )

        custom_data = CustomData(
            currency=row['currency'],
            value=row['predicted_revenue']
        )

        event = Event(
            event_name=event_name,
            event_time=date,
            user_data=user_data,
            custom_data=custom_data,
            data_processing_options=[]
        )
        events.append(event)

        logs.append(
            {
                "facebook_browser_id": row['facebook_browser_id'],
                "shop": row['shop'],
                "date_source": row['date'],
                "date_processed": datetime.today().strftime('%Y-%m-%d-%H:%M:%S'),
                "predicted_revenue": row['predicted_revenue'],
                "currency": row['currency']
            }
        )
    df_logs = pd.DataFrame(logs)
    return events, df_logs
    def test_multiple_values_constructor_with_only_plural_values(self):
        initial_state = {
            'emails': ['*****@*****.**', '*****@*****.**'],
            'phones': ['12345678912', '12062072008'],
            'genders': [Gender.MALE, Gender.FEMALE],
            'dates_of_birth': ['19900101', '19660202'],
            'last_names': ['smith', 'brown'],
            'first_names': ['joe', 'mary'],
            'cities': ['seattle', 'san francisco'],
            'states': ['ca', 'wa'],
            'country_codes': ['us', 'ca'],
            'zip_codes': ['98001', '12345'],
            'external_ids': ['123', '456']
        }

        user_data = UserData(emails=initial_state['emails'],
                             phones=initial_state['phones'],
                             genders=initial_state['genders'],
                             dates_of_birth=initial_state['dates_of_birth'],
                             last_names=initial_state['last_names'],
                             first_names=initial_state['first_names'],
                             cities=initial_state['cities'],
                             states=initial_state['states'],
                             country_codes=initial_state['country_codes'],
                             zip_codes=initial_state['zip_codes'],
                             external_ids=initial_state['external_ids'])

        self.assertListEqual(user_data.emails, initial_state['emails'])
        self.assertListEqual(user_data.phones, initial_state['phones'])
        self.assertListEqual(user_data.genders, initial_state['genders'])
        self.assertListEqual(user_data.dates_of_birth,
                             initial_state['dates_of_birth'])
        self.assertListEqual(user_data.last_names, initial_state['last_names'])
        self.assertListEqual(user_data.first_names,
                             initial_state['first_names'])
        self.assertListEqual(user_data.cities, initial_state['cities'])
        self.assertListEqual(user_data.states, initial_state['states'])
        self.assertListEqual(user_data.country_codes,
                             initial_state['country_codes'])
        self.assertListEqual(user_data.zip_codes, initial_state['zip_codes'])
        self.assertListEqual(user_data.external_ids,
                             initial_state['external_ids'])
Exemplo n.º 9
0
def notify_add_to_cart(product_id, url, remote_address, user_agent):
    product = Product.objects.get(id=product_id)

    user_data = UserData(
        # It is recommended to send Client IP and User Agent for Conversions API Events.
        client_ip_address=remote_address,
        client_user_agent=user_agent
        # fbc='fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890',
        # fbp='fb.1.1558571054389.1098115397',
    )

    content = Content(
        product_id=product_id,
        item_price=str(product.price.quantize(Decimal('1'), rounding=ROUND_HALF_EVEN))
    )

    custom_data = CustomData(
        contents=[content],
        content_type='product',
        currency='rub'
    )

    event = Event(
        event_name='AddToCart',
        event_time=int(time.time()),
        user_data=user_data,
        custom_data=custom_data,
        event_source_url=url,
        action_source=ActionSource.WEBSITE,
    )

    event_request = EventRequest(
        events=[event],
        pixel_id=FACEBOOK_PIXEL_ID,
    )

    event_response = event_request.execute()
    log.error(event_response)
    def test_multiple_values_constructor_with_singular_and_plural_values(self):
        params = [
            ['email', 'emails'],
            ['phone', 'phones'],
            ['gender', 'genders'],
            ['date_of_birth', 'dates_of_birth'],
            ['last_name', 'last_names'],
            ['first_name', 'first_names'],
            ['city', 'cities'],
            ['state', 'states'],
            ['country_code', 'country_codes'],
            ['zip_code', 'zip_codes'],
            ['external_id', 'external_ids'],
        ]

        for p in params:
            param_dict = {p[0]: 'test', p[1]: ['test', 'test']}
            with self.assertRaises(ValueError) as context:
                user_data = UserData(**param_dict)
            self.assertEqual(
                UserData.multi_value_constructor_err.format(
                    list(param_dict)[0],
                    list(param_dict)[1]), str(context.exception))
    def test_multiple_values_getters_and_setters(self):
        initial_state = {
            'emails': ['*****@*****.**', '*****@*****.**'],
            'phones': ['12345678912', '12062072008'],
            'genders': [Gender.MALE, Gender.FEMALE],
            'dates_of_birth': ['19900101', '19660202'],
            'last_names': ['smith', 'brown'],
            'first_names': ['joe', 'mary'],
            'cities': ['seattle', 'san francisco'],
            'states': ['ca', 'wa'],
            'country_codes': ['us', 'ca'],
            'zip_codes': ['98001', '12345'],
            'external_ids': ['123', '456']
        }
        user_data = UserData()
        user_data.emails = initial_state['emails']
        user_data.phones = initial_state['phones']
        user_data.genders = initial_state['genders']
        user_data.dates_of_birth = initial_state['dates_of_birth']
        user_data.last_names = initial_state['last_names']
        user_data.first_names = initial_state['first_names']
        user_data.cities = initial_state['cities']
        user_data.states = initial_state['states']
        user_data.country_codes = initial_state['country_codes']
        user_data.zip_codes = initial_state['zip_codes']
        user_data.external_ids = initial_state['external_ids']

        self.assertListEqual(user_data.emails, initial_state['emails'])
        self.assertListEqual(user_data.phones, initial_state['phones'])
        self.assertListEqual(user_data.genders, initial_state['genders'])
        self.assertListEqual(user_data.dates_of_birth,
                             initial_state['dates_of_birth'])
        self.assertListEqual(user_data.last_names, initial_state['last_names'])
        self.assertListEqual(user_data.first_names,
                             initial_state['first_names'])
        self.assertListEqual(user_data.cities, initial_state['cities'])
        self.assertListEqual(user_data.states, initial_state['states'])
        self.assertListEqual(user_data.country_codes,
                             initial_state['country_codes'])
        self.assertListEqual(user_data.zip_codes, initial_state['zip_codes'])
        self.assertListEqual(user_data.external_ids,
                             initial_state['external_ids'])

        # Also check that single getters/setters when multiple values exist
        self.assertEqual(user_data.email, initial_state['emails'][0])
        self.assertEqual(user_data.phone, initial_state['phones'][0])
        self.assertEqual(user_data.gender, initial_state['genders'][0])
        self.assertEqual(user_data.date_of_birth,
                         initial_state['dates_of_birth'][0])
        self.assertEqual(user_data.last_name, initial_state['last_names'][0])
        self.assertEqual(user_data.first_name, initial_state['first_names'][0])
        self.assertEqual(user_data.city, initial_state['cities'][0])
        self.assertEqual(user_data.state, initial_state['states'][0])
        self.assertEqual(user_data.country_code,
                         initial_state['country_codes'][0])
        self.assertEqual(user_data.zip_code, initial_state['zip_codes'][0])
        self.assertEqual(user_data.external_id,
                         initial_state['external_ids'][0])
    def test_normalize_it_normalizes_and_hashes(self):
        initial_state = {
            'emails': ['*****@*****.**', '*****@*****.**', '*****@*****.**'],
            'phones': ['12345678912', '12062072008', '12062072008'],
            'genders': [Gender.MALE, Gender.FEMALE, Gender.FEMALE],
            'dates_of_birth': ['19900101', '19660202', '19660202'],
            'last_names': ['smith', 'brown', 'brown'],
            'first_names': ['joe', 'mary', 'mary'],
            'cities': ['seattle', 'sanfrancisco', 'sanfrancisco'],
            'states': ['ca', 'wa', 'wa'],
            'country_codes': ['us', 'ca', 'ca'],
            'zip_codes': ['98001', '12345', '12345'],
            'external_ids': ['123', '456', '456'],
            'f5first': 'First',
            'f5last': 'Last',
            'fi': 'A',
            'dobd': '01',
            'dobm': '02',
            'doby': '2000',
            'lead_id': 'lead-id-3',
        }
        user_data = UserData(
            f5first=initial_state['f5first'],
            f5last=initial_state['f5last'],
            fi=initial_state['fi'],
            dobd=initial_state['dobd'],
            dobm=initial_state['dobm'],
            doby=initial_state['doby'],
            lead_id=initial_state['lead_id'],
        )
        user_data.emails = initial_state['emails']
        user_data.phones = initial_state['phones']
        user_data.genders = initial_state['genders']
        user_data.dates_of_birth = initial_state['dates_of_birth']
        user_data.last_names = initial_state['last_names']
        user_data.first_names = initial_state['first_names']
        user_data.cities = initial_state['cities']
        user_data.states = initial_state['states']
        user_data.country_codes = initial_state['country_codes']
        user_data.zip_codes = initial_state['zip_codes']
        user_data.external_ids = initial_state['external_ids']

        actual = user_data.normalize()
        expected = {
            'em':
            self.__hash_list(initial_state['emails'][0:2]),
            'ph':
            self.__hash_list(initial_state['phones'][0:2]),
            'ge':
            self.__hash_list(
                list(map(lambda g: g.value, initial_state['genders'][0:2]))),
            'db':
            self.__hash_list(initial_state['dates_of_birth'][0:2]),
            'ln':
            self.__hash_list(initial_state['last_names'][0:2]),
            'fn':
            self.__hash_list(initial_state['first_names'][0:2]),
            'ct':
            self.__hash_list(initial_state['cities'][0:2]),
            'st':
            self.__hash_list(initial_state['states'][0:2]),
            'zp':
            self.__hash_list(initial_state['zip_codes'][0:2]),
            'country':
            self.__hash_list(initial_state['country_codes'][0:2]),
            'external_id':
            initial_state['external_ids'][0:2],
            'f5first':
            Normalize.hash_sha_256(initial_state['f5first'].lower()),
            'f5last':
            Normalize.hash_sha_256(initial_state['f5last'].lower()),
            'fi':
            Normalize.hash_sha_256(initial_state['fi'].lower()),
            'dobd':
            Normalize.hash_sha_256(initial_state['dobd']),
            'dobm':
            Normalize.hash_sha_256(initial_state['dobm']),
            'doby':
            Normalize.hash_sha_256(initial_state['doby']),
            'lead_id':
            initial_state['lead_id'],
        }

        not_equal_items = {
            k: actual[k]
            for k in actual
            if k not in expected or sorted(actual[k]) != sorted(expected[k])
        }
        self.assertEqual(len(not_equal_items), 0)
        self.assertEqual(len(actual), len(expected))
    def test_multi_value_normalization_with_empty(self):
        user_data = UserData()
        user_data.emails = []
        user_data.phones = []
        user_data.genders = []
        user_data.dates_of_birth = []
        user_data.last_names = []
        user_data.first_names = []
        user_data.cities = []
        user_data.states = []
        user_data.country_codes = []
        user_data.zip_codes = []
        user_data.external_ids = []

        normalized_data = user_data.normalize()

        self.assertFalse(normalized_data)
Exemplo n.º 14
0
from facebook_business.adobjects.serverside.delivery_category import DeliveryCategory
from facebook_business.adobjects.serverside.event import Event
from facebook_business.adobjects.serverside.event_request import EventRequest
from facebook_business.adobjects.serverside.user_data import UserData
from facebook_business.api import FacebookAdsApi

access_token = '<ACCESS_TOKEN>'
pixel_id = 'ADS_PIXEL_ID>'

FacebookAdsApi.init(access_token=access_token)

user_data = UserData(
    emails=['*****@*****.**'],
    phones=['12345678901', '14251234567'],
    # It is recommended to send Client IP and User Agent for Conversions API Events.
    client_ip_address=request.META.get('REMOTE_ADDR'),
    client_user_agent=request.headers['User-Agent'],
    fbc='fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890',
    fbp='fb.1.1558571054389.1098115397',
)

content = Content(
    product_id='product123',
    quantity=1,
    delivery_category=DeliveryCategory.HOME_DELIVERY,
)

custom_data = CustomData(
    contents=[content],
    currency='usd',
    value=123.45,
# DEALINGS IN THE SOFTWARE.

import time

from facebook_business.adobjects.serverside.event import Event
from facebook_business.adobjects.serverside.event_request import EventRequest
from facebook_business.adobjects.serverside.user_data import UserData
from facebook_business.api import FacebookAdsApi

access_token = '<ACCESS_TOKEN>'
pixel_id = 'ADS_PIXEL_ID>'

FacebookAdsApi.init(access_token=access_token)

user_data = UserData(
    email='*****@*****.**',
    fbc='fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890',
    fbp='fb.1.1558571054389.1098115397')

event = Event(
    event_name='PageView',
    event_time=int(time.time()),
    user_data=user_data,
)

events = [event]

event_request = EventRequest(events=events, pixel_id=pixel_id)

event_response = event_request.execute()
print(event_response)
from facebook_business.adobjects.serverside.user_data import UserData
from facebook_business.api import FacebookAdsApi

# Configuration.
# Should fill in value before running this script.
access_token = None
pixel_id = None

if access_token is None or pixel_id is None:
    raise Exception(
        "You must set your access token and pixel id before executing")

FacebookAdsApi.init(access_token=access_token)

user_data = UserData(email="*****@*****.**",
                     phone="16505551212",
                     country_code="us",
                     gender=Gender.FEMALE)

content = Content(product_id="XYZ789", quantity=4, item_price=3.5)
contents = [content]
custom_data = CustomData(contents=contents, value=14.0, currency="usd")

event = Event(
    event_name="Purchase",
    event_time=int(time.time()),
    user_data=user_data,
    custom_data=custom_data,
)

events = [event]
Exemplo n.º 17
0
def pixel():
    access_token = request.headers.get('token')
    pixel_id = request.headers.get('pixel')
    page_id = request.headers.get('page_id')

    FacebookAdsApi.init(access_token=access_token)
    now = int(time.time())
    action_source = ActionSource('chat')
    payload = request.json

    if payload['opt_out'].lower().strip() == 'false':
        opt_out = False
    else:
        opt_out = True

    user_data = payload['user_data']
    user_data = {
        key: None if user_data[key].find('{{') != -1
        and user_data[key].find('}}') != -1 else user_data[key]
        for key, value in user_data.items()
    }
    user_data_0 = UserData()
    for key, value in user_data.items():
        setattr(user_data_0, key, value)

    custom_data = payload['custom_data']
    if payload["event_name"] == 'Purchase':
        try:
            custom_data['value'] = float(custom_data['value'])
        except ValueError or TypeError:
            response = f'{custom_data["value"]} is not allowed as value for {payload["event_name"]} event'
            entry = dict(message={
                'page_id': page_id,
                'log': response
            },
                         component='arbitrary-property')
            print(json.dumps(entry))
            return response, 400
    if 'predicted_ltv' in custom_data.keys():
        custom_data['predicted_ltv'] = float(custom_data['predicted_ltv'])
    if 'num_items' in custom_data.keys():
        custom_data['num_items'] = int(custom_data['num_items'])
    custom_data_0 = CustomData()
    for key, value in custom_data.items():
        setattr(custom_data_0, key, value)

    event_0 = Event(event_name=payload['event_name'],
                    event_time=now,
                    opt_out=opt_out,
                    user_data=user_data_0,
                    custom_data=custom_data_0,
                    data_processing_options=[],
                    action_source=action_source)

    events = [event_0]

    if payload['test_event_code'] == '':
        event_request = EventRequest(
            events=events,
            pixel_id=pixel_id,
        )
    else:
        test_event_code = payload['test_event_code']
        event_request = EventRequest(events=events,
                                     pixel_id=pixel_id,
                                     test_event_code=test_event_code)

    try:
        event_response = event_request.execute()
    except (TypeError, AttributeError) as error:
        error_message = error.args[0]
        response = {'response': error_message}
        return response, 400
    except FacebookRequestError as error:
        error_message = error.body()['error']['message']
        response = {'response': error_message}
        return response, 400
    else:
        response = event_response.to_dict()
        return response
    finally:
        entry = dict(message={'page_id': page_id, 'log': response})
        print(json.dumps(entry))
    def test_single_getters_setters_constructor(self):
        initial_state = {
            'email': '*****@*****.**',
            'phone': '12345678912',
            'gender': Gender.MALE,
            'date_of_birth': '19900101',
            'last_name': 'smith',
            'first_name': 'joe',
            'city': 'seattle',
            'state': 'ca',
            'country_code': 'us',
            'zip_code': '98001',
            'external_id': '123'
        }

        user_data_via_setter = UserData()
        user_data_via_setter.email = initial_state['email']
        user_data_via_setter.phone = initial_state['phone']
        user_data_via_setter.gender = initial_state['gender']
        user_data_via_setter.date_of_birth = initial_state['date_of_birth']
        user_data_via_setter.last_name = initial_state['last_name']
        user_data_via_setter.first_name = initial_state['first_name']
        user_data_via_setter.city = initial_state['city']
        user_data_via_setter.state = initial_state['state']
        user_data_via_setter.country_code = initial_state['country_code']
        user_data_via_setter.zip_code = initial_state['zip_code']
        user_data_via_setter.external_id = initial_state['external_id']

        user_data_via_constructor = UserData(
            email=initial_state['email'],
            phone=initial_state['phone'],
            gender=initial_state['gender'],
            date_of_birth=initial_state['date_of_birth'],
            last_name=initial_state['last_name'],
            first_name=initial_state['first_name'],
            city=initial_state['city'],
            state=initial_state['state'],
            country_code=initial_state['country_code'],
            zip_code=initial_state['zip_code'],
            external_id=initial_state['external_id'])

        self.__assert_equality_via_singular_getters(initial_state,
                                                    user_data_via_setter)
        self.__assert_equality_via_singular_getters(initial_state,
                                                    user_data_via_constructor)