本文整理汇总了Python中standup.tests.project函数的典型用法代码示例。如果您正苦于以下问题:Python project函数的具体用法?Python project怎么用?Python project使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了project函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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
示例2: test_timeline_filters_project
def test_timeline_filters_project(self):
"""Test the timeline only shows the passed in project."""
with self.app.app_context():
u = user(save=True)
p = project(save=True)
status(user=u, project=p, save=True)
p2 = project(name="Test Project 2", slug="test-project-2", save=True)
status(user=u, project=p2, save=True)
response = self.client.get(self._url())
data = json.loads(response.data)
eq_(len(data), 1)
eq_(data[0]["project"], p.dictify())
示例3: 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)
示例4: 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)
示例5: test_timeline
def test_timeline(self):
"""Test the home_timeline endpoint"""
with self.app.app_context():
u = user(save=True, team={})
p = project(save=True)
status(user=u, project=p, save=True)
response = self.client.get(self._url())
eq_(response.status_code, 200)
eq_(response.content_type, 'application/json')
示例6: test_project_view
def test_project_view(self):
"""Make sure the project view works like it's supposed to."""
with self.app.app_context():
p = project(save=True)
response = self.client.get('/project/%s' % p.slug)
eq_(response.status_code, 200)
response = self.client.get('/project/not-a-real-project')
eq_(response.status_code, 404)
示例7: test_paginate
def test_paginate(self):
"""Test the paginate helper function."""
db = get_session(self.app)
statuses = []
with self.app.app_context():
p = project(save=True)
u = user(save=True)
# Create 100 statuses
for i in range(30):
statuses.append(status(project=p, user=u,
created=datetime(2012, 5, 25),
save=True))
for i in range(30):
statuses.append(status(project=p, user=u,
created=datetime(2012, 6, 25),
save=True))
for i in range(40):
statuses.append(status(project=p, user=u,
created=datetime(2012, 7, 25),
save=True))
s = db.query(Status).order_by(Status.id)
# Test simple pagination
page = paginate(s, page=1)
eq_(page.pages, 5)
eq_(page.has_prev, False)
eq_(page.has_next, True)
page = paginate(s, page=3)
eq_(page.has_prev, True)
eq_(page.has_next, True)
page = paginate(s, page=5)
eq_(page.has_prev, True)
eq_(page.has_next, False)
# Test date filtered pagination
page = paginate(s, page=1, startdate=datetime(2012, 5, 28))
eq_(page.pages, 4)
page = paginate(s, page=1, startdate=datetime(2012, 5, 28),
enddate=datetime(2012, 6, 28))
eq_(page.pages, 2)
page = paginate(s, page=1, enddate=datetime(2012, 6, 28))
eq_(page.pages, 3)
示例8: test_status_with_project
def test_status_with_project(self):
"""Test posting a status with a project."""
with self.app.app_context():
u = user(email='[email protected]', save=True)
p = project(name='blackhole', slug='blackhole', save=True)
data = {'message': 'r1cky rocks!', 'project': p.id}
authenticate(self.client, u)
rv = self.client.post('/statusize/', follow_redirects=True,
data=data)
eq_(rv.status_code, 200)
示例9: test_status_replies
def test_status_replies(self):
"""Test the loading of replies for a status."""
with self.app.app_context():
p = project(save=True)
u = user(save=True)
s = status(project=p, user=u, save=True)
for i in range(30):
status(project=p, user=u, reply_to=s, save=True)
page = s.replies()
eq_(page.pages, 2)
示例10: test_timeline_trim_project
def test_timeline_trim_project(self):
"""Test the trim_project parameter of home_timeline"""
with self.app.app_context():
p = project(save=True)
status(project=p, save=True)
response = self.client.get(self._url())
data = json.loads(response.data)
eq_(data[0]["project"], p.dictify())
response = self.client.get(self._url(dict(trim_project=1)))
data = json.loads(response.data)
eq_(data[0]["project"], p.id)
示例11: test_timeline_trim_user
def test_timeline_trim_user(self):
"""Test the trim_user parameter of home_timeline"""
with self.app.app_context():
u = user(save=True, team={})
p = project(save=True)
status(user=u, project=p, save=True)
response = self.client.get(self._url())
data = json.loads(response.data)
eq_(data[0]['user'], u.dictify())
response = self.client.get(self._url(dict(trim_user=1)))
data = json.loads(response.data)
eq_(data[0]['user'], u.id)
示例12: 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())
示例13: 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())
示例14: test_timeline_include_replies
def test_timeline_include_replies(self):
"""Test the include_replies parameter of home_timeline"""
with self.app.app_context():
u = user(save=True, team={})
p = project(save=True)
for i in range(10):
s = status(project=p, user=u, save=True)
for i in range(10):
status(project=p, user=u, reply_to=s, save=True)
response = self.client.get(self._url())
data = json.loads(response.data)
eq_(len(data), 10)
response = self.client.get(self._url(dict(include_replies=1)))
data = json.loads(response.data)
eq_(len(data), 20)
示例15: test_project_recent_statuses
def test_project_recent_statuses(self):
"""Test loading of recent statuses for a project."""
with self.app.app_context():
p = project(save=True)
u = user(save=True)
# Create 70 statuses
for i in range(70):
status(project=p, user=u, save=True)
s = status(project=p, user=u, save=True)
# Create 30 replies
for i in range(30):
status(project=p, user=u, reply_to=s, save=True)
# Should not include replies
page = p.recent_statuses()
eq_(page.pages, 4)