def setUp(self): super(UpdateTeamTestCase, self).setUp() self.url = '/api/v2/teams/update.json' self.data = {'slug': 'test', 'name': 'Updated Team', 'api_key': self.app.config.get('API_KEY')} with self.app.app_context(): team(slug=self.data['slug'], name='Test Team', save=True)
def test_contextual_feeds(self): """Test that team/project/user Atom feeds appear as <link> tags.""" with self.app.app_context(): user(email='*****@*****.**', save=True) u = user(username='******', email="*****@*****.**", 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
def test_team_recent_statuses(self): """Test loading of recent statuses for a project.""" with self.app.app_context(): t = team(save=True) u = user(teams=[t], save=True) u2 = user(username='******', slug='troll', email='*****@*****.**', save=True) # Create 30 statuses for i in range(30): s = status(project=None, user=u, save=True) # Create 30 replies for i in range(30): status(project=None, user=u, reply_to=s, save=True) # Create 30 statuses for user not in team for i in range(10): status(project=None, user=u2, save=True) # Should not include replies page = t.recent_statuses() eq_(page.pages, 2)
def setUp(self): super(TeamMembersTestCase, self).setUp() self.query = {"slug": "test"} self.url = "/api/v2/teams/members.json" with self.app.app_context(): self.team = team(slug=self.query["slug"], name="Test Team", save=True) self.user = user(save=True)
def setUp(self): super(TeamMembersTestCase, self).setUp() self.query = {'slug': 'test'} self.url = '/api/v2/teams/members.json' with self.app.app_context(): self.team = team(slug=self.query['slug'], name='Test Team', save=True) self.user = user(save=True)
def test_feeds(self): """Test that the site-wise Atom feed appears and functions properly.""" with self.app.app_context(): u = user(email='*****@*****.**', slug='joe', save=True) team(users=[u], slug='a-team', save=True) p = project(slug='prjkt', save=True) for i in range(20): status(user=u, project=p, content='foo', content_html='foo', save=True) authenticate(self.client, u) site_url = self.app.config.get('SITE_URL') # Ensure the Atom link appears in the rendered HTML. rv = self.client.get('/') assert ('<link rel="alternate" type="application/atom+xml" ' 'href="%s/statuses.xml"') % site_url in rv.data # Make sure the Atom feed displays statuses. rv = self.client.get('/statuses.xml') assert '<entry' in rv.data assert ('<content type="html"><h3>Test Project</h3><p' '>foo</p></content>') in rv.data rv = self.client.get('/user/joe.xml') assert '<entry' in rv.data assert ('<content type="html"><h3>Test Project</h3><p' '>foo</p></content>') in rv.data rv = self.client.get('/project/prjkt.xml') assert '<entry' in rv.data assert ('<content type="html"><h3>Test Project</h3><p' '>foo</p></content>') in rv.data rv = self.client.get('/team/a-team.xml') assert '<entry' in rv.data assert ('<content type="html"><h3>Test Project</h3><p' '>foo</p></content>') in rv.data
def setUp(self): super(CreateTeamMemberTestCase, self).setUp() with self.app.app_context(): self.user = user(save=True) self.team = team(save=True) self.url = '/api/v2/teams/members/create.json' self.data = {'slug': self.team.slug, 'screen_name': self.user.username, 'api_key': self.app.config.get('API_KEY')}
def test_team_view(self): """Make sure the project view works like it's supposed to.""" with self.app.app_context(): u = user(save=True) t = team(users=[u], save=True) response = self.client.get('/team/%s' % t.slug) eq_(response.status_code, 200) response = self.client.get('/team/not-a-real-team') eq_(response.status_code, 404)
def setUp(self): super(CreateTeamMemberTestCase, self).setUp() with self.app.app_context(): self.user = user(save=True) self.team = team(save=True) self.url = "/api/v2/teams/members/create.json" self.data = { "slug": self.team.slug, "screen_name": self.user.username, "api_key": self.app.config.get("API_KEY"), }
def setUp(self): super(DestroyTeamMemberTestCase, self).setUp() with self.app.app_context(): self.user = user(save=True) self.team = team(save=True) db = get_session(self.app) self.team.users.append(self.user) db.commit() self.url = '/api/v2/teams/members/destroy.json' self.data = {'slug': self.team.slug, 'screen_name': self.user.username, 'api_key': self.app.config.get('API_KEY')}
def setUp(self): super(DestroyTeamMemberTestCase, self).setUp() with self.app.app_context(): self.user = user(save=True) self.team = team(save=True) db = get_session(self.app) self.team.users.append(self.user) db.commit() self.url = "/api/v2/teams/members/destroy.json" self.data = { "slug": self.team.slug, "screen_name": self.user.username, "api_key": self.app.config.get("API_KEY"), }
def test_team_repr(self): """Test the __repr__ function of the Team model.""" with self.app.app_context(): t = team(name='A-Team') eq_(repr(t), '<Team: A-Team>')
def test_timeline_filter_by_team_id(self): with self.app.app_context(): t = team(save=True) self.query = {'team_id': t.id} response = self.client.get(self._url()) eq_(response.status_code, 200)
def setUp(self): super(UpdateTeamTestCase, self).setUp() self.url = "/api/v2/teams/update.json" self.data = {"slug": "test", "name": "Updated Team", "api_key": self.app.config.get("API_KEY")} with self.app.app_context(): team(slug=self.data["slug"], name="Test Team", save=True)