コード例 #1
0
def test_track_group_signup(db):
    """Records extra data about parent signup in group."""
    phone = '+13216540987'
    parent = factories.ProfileFactory.create(phone=phone)
    group = factories.GroupFactory.create()
    with mock.patch('portfoliyo.mixpanel.track') as mock_track:
        hook.track_signup(parent, group.owner, group)

    mock_track.assert_called_with(
        'parent signup',
        {
            'distinct_id': group.owner.user.id,
            'phone': phone,
            'groupId': group.id,
            'groupName': group.name,
            },
        )
コード例 #2
0
def test_track_signup(db):
    """Records data about parent signup."""
    phone = '+13216540987'
    parent = factories.ProfileFactory.create(phone=phone)
    teacher = factories.ProfileFactory.create()
    with mock.patch('portfoliyo.mixpanel.track') as mock_track:
        with mock.patch('portfoliyo.mixpanel.people_increment') as mock_incr:
            with mock.patch('portfoliyo.mixpanel.people_set') as mock_set:
                with mock.patch('portfoliyo.sms.hook.timezone.now') as mock_now:
                    mock_now.return_value = datetime(
                        2013, 1, 14, 12, 2, 3, tzinfo=get_current_timezone())
                    hook.track_signup(parent, teacher)

    mock_track.assert_called_with(
        'parent signup', {'distinct_id': teacher.user.id, 'phone': phone})
    mock_incr.assert_called_with(teacher.user.id, {'parentSignups': 1})
    mock_set.assert_called_with(
        teacher.user.id, {'lastParentSignup': '2013-01-14T12:02:03'})