'Verify the last_contribution_date field works properly.'

def test_last_contribution_date(self):

    u = UserFactory(username='satdav')
    self.refresh()
    data = UserMappingType.search().query(username__match='satdav')[0]
    assert (not data['last_contribution_date'])
    d = datetime(2014, 1, 1)
    ReplyFactory(user=u, created=d)
    self.refresh()
    data = UserMappingType.search().query(username__match='satdav')[0]
    eq_(data['last_contribution_date'], d)
    d = datetime(2014, 1, 2)
    AnswerFactory(creator=u, created=d)
    u.profile.save()
    self.refresh()
    data = UserMappingType.search().query(username__match='satdav')[0]
    eq_(data['last_contribution_date'], d)
    d = datetime(2014, 1, 3)
    RevisionFactory(created=d, creator=u)
    u.profile.save()
    self.refresh()
    data = UserMappingType.search().query(username__match='satdav')[0]
    eq_(data['last_contribution_date'], d)
    d = datetime(2014, 1, 4)
    RevisionFactory(reviewed=d, reviewer=u)
    u.profile.save()
    self.refresh()
    data = UserMappingType.search().query(username__match='satdav')[0]
    eq_(data['last_contribution_date'], d)
