Ejemplo n.º 1
0
    def test_get_display_name(self):
        u1 = User(u'*****@*****.**', u'1')
        u1.save()
        assert u1.get_display_name() == u'feber'

        u1.update(u'Alice', None, None, None)
        assert u1.get_display_name() == u'Alice'
Ejemplo n.º 2
0
    def test_get_location(self):
        """
            User.get_location()
            User.location
        """

        u1 = User(u'*****@*****.**', u'1')
        u1.save()

        city = City()
        city.city_id = u'110100'
        city.name = u'北京市'
        city.province_id = u'110000'
        db.session.add(city)
        db.session.commit()

        province = Province()
        province.province_id = u'110000'
        province.name = u'北京市'
        db.session.add(province)
        db.session.commit()

        u1.update(None, None, None, u'110100')
        assert u1.get_location()['city_id'] == u'110100'
        assert u1.get_location()['province_id'] == u'110000'
        assert u1.get_location()['text'] == u'北京 北京市'
        assert u1.location == u'北京 北京市'
Ejemplo n.º 3
0
    def test_update(self):
        u1 = User(u'*****@*****.**', u'1')
        u1.save()

        # 北京市 110100
        u1.update(u'Alice', u'Much a do than nothing.', 0, u'110100')
        assert u1.penname == 'Alice'
        assert u1.intro == 'Much a do than nothing.'
        assert u1.gender == 0
        assert u1.city_id == '110100'