本文整理汇总了Python中standup.tests.user函数的典型用法代码示例。如果您正苦于以下问题:Python user函数的具体用法?Python user怎么用?Python user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_user_by_admins
def test_update_user_by_admins(self):
"""Test that an admin can update another users settings and non-admins
cannot update other users settings
"""
u = user(save=True)
a = user(username="admin", slug="admin", email="[email protected]", is_admin=True, save=True)
uid = u.id
aid = a.id
username = u.username
data = json.dumps(
{
"api_key": settings.API_KEY,
"user": a.username,
"email": "[email protected]",
"github_handle": "test",
"name": "Test",
}
)
response = self.app.post("/api/v1/user/%s/" % username, data=data, content_type="application/json")
self.assertEqual(response.status_code, 200)
u = User.query.get(uid)
self.assertEqual(u.email, "[email protected]")
self.assertEqual(u.github_handle, "test")
self.assertEqual(u.name, "Test")
data = json.dumps({"api_key": settings.API_KEY, "user": username, "email": "[email protected]"})
response = self.app.post("/api/v1/user/%s/" % aid, data=data, content_type="application/json")
self.assertEqual(response.status_code, 403)
示例2: test_contextual_feeds
def test_contextual_feeds(self):
"""Test that team/project/user Atom feeds appear as <link> tags."""
with self.app.app_context():
user(email='[email protected]', save=True)
u = user(username='buffy', email="[email protected]",
name='Buffy Summers', slug='buffy', save=True)
team(name='Scooby Gang', slug='scoobies', users=[u], save=True)
project(name='Kill The Master', slug='master', save=True)
authenticate(self.client, u)
site_url = self.app.config.get('SITE_URL')
rv = self.client.get('/')
assert ('<link rel="alternate" type="application/atom+xml" '
'href="%s/statuses.xml"') % site_url in rv.data
assert ('<link rel="alternate" type="application/atom+xml" '
'href="%s/project/') % site_url not in rv.data
rv = self.client.get('/team/scoobies')
assert ('<link rel="alternate" type="application/atom+xml" '
'href="%s/team/') % site_url in rv.data
rv = self.client.get('/project/master')
assert ('<link rel="alternate" type="application/atom+xml" '
'href="%s/project/') % site_url in rv.data
rv = self.client.get('/user/buffy')
assert ('<link rel="alternate" type="application/atom+xml" '
'href="%s/user/') % site_url in rv.data
示例3: test_profile_authenticationified
def test_profile_authenticationified(self):
"""Test that you can see profile page if you are logged in."""
user(email='[email protected]', save=True)
with app.app.test_client() as tc:
with tc.session_transaction() as sess:
sess['email'] = '[email protected]'
rv = tc.get('/profile/')
eq_(rv.status_code, 200)
示例4: test_status
def test_status(self):
"""Test posting a status."""
user(email='[email protected]', save=True)
with app.app.test_client() as tc:
with tc.session_transaction() as sess:
sess['email'] = '[email protected]'
rv = tc.post('/statusize/',
data={'message': 'foo'},
follow_redirects=True)
eq_(rv.status_code, 200)
示例5: test_timeline_filters_user
def test_timeline_filters_user(self):
"""Test the timeline only shows the passed in user."""
with self.app.app_context():
u = user(save=True)
status(user=u, project=None, save=True)
u2 = user(username="janedoe", email="[email protected]", slug="janedoe", save=True)
status(user=u2, project=None, save=True)
response = self.client.get(self._url())
data = json.loads(response.data)
eq_(len(data), 1)
eq_(data[0]["user"], u.dictify())
示例6: test_status_no_message
def test_status_no_message(self):
"""Test posting a status with no message."""
user(email='[email protected]', save=True)
with app.app.test_client() as tc:
with tc.session_transaction() as sess:
sess['email'] = '[email protected]'
rv = tc.post('/statusize/',
data={'message': ''},
follow_redirects=True)
# This kicks up a 404, but that's lame.
eq_(rv.status_code, 404)
示例7: test_timeline_filters_team
def test_timeline_filters_team(self):
"""Test the timeline only shows the passed in team."""
with self.app.app_context():
u = user(save=True, team={})
u2 = user(
username="janedoe", email="[email protected]", slug="janedoe", save=True, team={"name": "XXX", "slug": "xxx"}
)
p = project(save=True)
status(user=u, project=p, save=True)
status(user=u2, project=p, save=True)
response = self.client.get(self._url(dict(team_id=u.teams[0].id)))
data = json.loads(response.data)
eq_(len(data), 1)
eq_(data[0]["user"], u.dictify())
示例8: test_timeline_filters_team
def test_timeline_filters_team(self):
"""Test the timeline only shows the passed in team."""
with self.app.app_context():
u = user(save=True, team={})
u2 = user(username='janedoe', email='[email protected]',
slug='janedoe', save=True, team={'name': 'XXX',
'slug': 'xxx'})
p = project(save=True)
status(user=u, project=p, save=True)
status(user=u2, project=p, save=True)
response = self.client.get(self._url(dict(team_id=u.teams[0].id)))
data = json.loads(response.data)
eq_(len(data), 1)
eq_(data[0]['user'], u.dictify())
示例9: test_status_repr
def test_status_repr(self):
"""Test the __repr__ function of the Status model."""
with self.app.app_context():
u = user(username='testuser', save=True)
s = status(content='my status update', user=u, save=True)
eq_(repr(s), '<Status: testuser: my status update>')
示例10: test_timeline_count
def test_timeline_count(self):
"""Test the count parameter of home_timeline"""
self.app.config['API2_TIMELINE_MAX_RESULTS'] = 50
with self.app.app_context():
u = user(save=True, team={})
p = project(save=True)
for i in range(60):
status(project=p, user=u, save=True)
response = self.client.get(self._url())
data = json.loads(response.data)
eq_(len(data), 20)
# Test with an acceptable count
response = self.client.get(self._url(dict(count=50)))
data = json.loads(response.data)
eq_(len(data), 50)
# Test with a count that is too large
response = self.client.get(self._url(dict(count=60)))
eq_(response.status_code, 400)
# Test with a count that is too small
response = self.client.get(self._url(dict(count=0)))
eq_(response.status_code, 400)
# Test with an invalid count
response = self.client.get(self._url(dict(count='a')))
eq_(response.status_code, 400)
示例11: test_timeline_since_id
def test_timeline_since_id(self):
"""Test the since_id parameter of home_timeline"""
with self.app.app_context():
u = user(save=True, team={})
p = project(save=True)
for i in range(30):
status(project=p, user=u, save=True)
response = self.client.get(self._url(dict(since_id=10, count=20)))
data = json.loads(response.data)
eq_(data[19]['id'], 11)
response = self.client.get(self._url(dict(since_id=10, count=10)))
data = json.loads(response.data)
eq_(data[9]['id'], 21)
response = self.client.get(self._url(dict(since_id=10, count=30)))
data = json.loads(response.data)
eq_(len(data), 20)
eq_(data[19]['id'], 11)
response = self.client.get(self._url(dict(since_id=0)))
eq_(response.status_code, 400)
response = self.client.get(self._url(dict(since_id='a')))
eq_(response.status_code, 400)
示例12: test_status_with_project
def test_status_with_project(self):
"""Test posting a status with no message."""
user(email='[email protected]', save=True)
p = Project(name='blackhole', slug='blackhole')
app.db.session.add(p)
app.db.session.commit()
pid = p.id
with app.app.test_client() as tc:
with tc.session_transaction() as sess:
sess['email'] = '[email protected]'
rv = tc.post('/statusize/',
data={'message': 'r1cky rocks!', 'project': pid},
follow_redirects=True)
eq_(rv.status_code, 200)
示例13: test_status_week_end
def test_status_week_end(self):
"""Test the week_end function of the Status model."""
d = datetime(2014, 5, 8, 17, 17, 51, 0)
with self.app.app_context():
u = user(username='testuser', save=True)
s = status(content='my status update', created=d, user=u, save=True)
d_actual = s.week_end.strftime("%Y-%m-%d")
eq_(d_actual, "2014-05-11") # Happy Mother's Day!
示例14: setUp
def setUp(self):
super(TimesinceLastUpdateTestCase, self).setUp()
with self.app.app_context():
self.user = user(save=True)
self.url = '/api/v2/info/timesince_last_update.json'
self.query = {'screen_name': self.user.username}
示例15: test_status_weeks_at_year_start
def test_status_weeks_at_year_start(self):
"""Test the week_{start|end} function around the start of the year."""
d = datetime(2013, 12, 31, 12, 13, 45, 0)
with self.app.app_context():
u = user(username='testuser', save=True)
s = status(content='my status update', created=d, user=u, save=True)
eq_(s.week_start.strftime("%Y-%m-%d"), "2013-12-30")
eq_(s.week_end.strftime("%Y-%m-%d"), "2014-01-05")