示例#1
0
 def test_removes_suffixes(self):
     self.assertEqual(split_name('Jeffrey Lebowski Jr'),
                      ('Jeffrey', 'Lebowski'))
     self.assertEqual(split_name('Jeffrey Lebowski jr.'),
                      ('Jeffrey', 'Lebowski'))
     self.assertEqual(split_name('Uli Kunkel Sr.'), ('Uli', 'Kunkel'))
     self.assertEqual(split_name('Uli Kunkel sr'), ('Uli', 'Kunkel'))
示例#2
0
 def test_removes_suffixes(self):
     self.assertEqual(split_name("Jeffrey Lebowski Jr"),
                      ("Jeffrey", "Lebowski"))
     self.assertEqual(split_name("Jeffrey Lebowski jr."),
                      ("Jeffrey", "Lebowski"))
     self.assertEqual(split_name("Uli Kunkel Sr."), ("Uli", "Kunkel"))
     self.assertEqual(split_name("Uli Kunkel sr"), ("Uli", "Kunkel"))
示例#3
0
 def test_standard_cases(self):
     self.assertEqual(split_name("Dude"), ("", "Dude"))
     self.assertEqual(split_name("Walter Sobchak"), ("Walter", "Sobchak"))
     self.assertEqual(
         split_name("Theodore Donald Kerabatsos"),
         ("Theodore Donald", "Kerabatsos"),
     )
示例#4
0
def process_subhub_event_customer_created(data):
    """
    Event name: customer.created

    Creates or updates a SFDC customer when a new payment processor/Stripe
    customer is created
    """
    statsd.incr('news.tasks.process_subhub_event.customer_created')

    first, last = split_name(data['name'])
    contact_data = {'fxa_id': data['user_id'], 'payee_id': data['customer_id']}

    user_data = get_user_data(email=data['email'])

    # if user was found in sfdc, see if we should update their name(s)
    if user_data:
        # if current last name is '_', update it
        if user_data['last_name'] == '_':
            contact_data['last_name'] = last

        # if current last name is blank/Null, update it
        if not user_data['first_name']:
            contact_data['first_name'] = first

        sfdc.update(user_data, contact_data)
        statsd.incr('news.tasks.process_subhub_event.customer_created.updated')
    # if no user was found, create new user in sfdc
    else:
        contact_data['email'] = data['email']
        contact_data['first_name'] = first
        contact_data['last_name'] = last

        # create the user in sfdc
        statsd.incr('news.tasks.process_subhub_event.customer_created.created')
        sfdc.add(contact_data)
示例#5
0
 def test_standard_cases(self):
     self.assertEqual(split_name('Dude'), ('', 'Dude'))
     self.assertEqual(split_name('Walter Sobchak'), ('Walter', 'Sobchak'))
     self.assertEqual(split_name('Theodore Donald Kerabatsos'),
                      ('Theodore Donald', 'Kerabatsos'))
示例#6
0
 def test_only_spaces(self):
     self.assertEqual(split_name(' '), ('', ''))
     self.assertEqual(split_name('     '), ('', ''))
示例#7
0
 def test_empty_string(self):
     self.assertEqual(split_name(''), ('', ''))
示例#8
0
 def test_only_spaces(self):
     self.assertEqual(split_name(" "), ("", ""))
     self.assertEqual(split_name("     "), ("", ""))
示例#9
0
 def test_empty_string(self):
     self.assertEqual(split_name(""), ("", ""))