예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
    def test_profile_authenticated(self):
        """Test that you can see profile page if you are logged in."""
        with self.app.app_context():
            u = user(email='*****@*****.**', save=True)

        authenticate(self.client, u)

        response = self.client.get('/profile/')
        eq_(response.status_code, 200)
예제 #4
0
    def test_profile_authenticated(self):
        """Test that you can see profile page if you are logged in."""
        with self.app.app_context():
            u = user(email='*****@*****.**', save=True)

        authenticate(self.client, u)

        response = self.client.get('/profile/')
        eq_(response.status_code, 200)
예제 #5
0
    def test_status(self):
        """Test posting a status."""
        with self.app.app_context():
            u = user(email='*****@*****.**', save=True)

        authenticate(self.client, u)

        rv = self.client.post('/statusize/', data={'message': 'foo'},
                              follow_redirects=True)
        eq_(rv.status_code, 200)
예제 #6
0
    def test_status_no_message(self):
        """Test posting a status with no message."""
        with self.app.app_context():
            u = user(email='*****@*****.**', save=True)

        authenticate(self.client, u)

        rv = self.client.post('/statusize/', data={'message': ''},
                              follow_redirects=True)
        # This kicks up a 404, but that's lame.
        eq_(rv.status_code, 404)
예제 #7
0
    def test_status(self):
        """Test posting a status."""
        with self.app.app_context():
            u = user(email='*****@*****.**', save=True)

        authenticate(self.client, u)

        rv = self.client.post('/statusize/',
                              data={'message': 'foo'},
                              follow_redirects=True)
        eq_(rv.status_code, 200)
예제 #8
0
    def test_status_with_project(self):
        """Test posting a status with a project."""
        with self.app.app_context():
            u = user(email='*****@*****.**', 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
0
    def test_status_with_project(self):
        """Test posting a status with a project."""
        with self.app.app_context():
            u = user(email='*****@*****.**', 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)
예제 #10
0
    def test_status_no_message(self):
        """Test posting a status with no message."""
        with self.app.app_context():
            u = user(email='*****@*****.**', save=True)

        authenticate(self.client, u)

        rv = self.client.post('/statusize/',
                              data={'message': ''},
                              follow_redirects=True)
        # This kicks up a 404, but that's lame.
        eq_(rv.status_code, 404)
예제 #11
0
    def test_login(self):
        """Test the login view."""
        with self.app.app_context():
            u = user(save=True)

        authenticate(self.client, u)

        response = self.client.post('/logout')
        eq_(response.status_code, 200)
        assert 'logout successful' in response.data

        with self.client.session_transaction() as sess:
            assert 'email' not in sess
            assert 'user_id' not in sess
예제 #12
0
    def test_login(self):
        """Test the login view."""
        with self.app.app_context():
            u = user(save=True)

        authenticate(self.client, u)

        response = self.client.post('/logout')
        eq_(response.status_code, 200)
        assert 'logout successful' in response.data

        with self.client.session_transaction() as sess:
            assert 'email' not in sess
            assert 'user_id' not in sess
예제 #13
0
    def test_new_profile(self):
        """Test the new profile page."""
        response = self.client.get('/profile/new/')
        eq_(response.status_code, 302)

        with self.client.session_transaction() as sess:
            sess['email'] = '*****@*****.**'

        response = self.client.get('/profile/new/')
        eq_(response.status_code, 200)

        with self.app.app_context():
            u = user(save=True)

        authenticate(self.client, u)

        response = self.client.get('/profile/new/')
        eq_(response.status_code, 302)
예제 #14
0
    def test_new_profile(self):
        """Test the new profile page."""
        response = self.client.get('/profile/new/')
        eq_(response.status_code, 302)

        with self.client.session_transaction() as sess:
            sess['email'] = '*****@*****.**'

        response = self.client.get('/profile/new/')
        eq_(response.status_code, 200)

        with self.app.app_context():
            u = user(save=True)

        authenticate(self.client, u)

        response = self.client.get('/profile/new/')
        eq_(response.status_code, 302)
예제 #15
0
    def test_profile_update(self):
        """Test that you can update your profile."""
        with self.app.app_context():
            u = user(save=True)

        authenticate(self.client, u)

        data = {'email': u.email, 'username': '******',
                'github_handle': 'test-handle', 'name': 'Test User'}

        response = self.client.post('/profile/', data=data)
        eq_(response.status_code, 200)

        db = get_session(self.app)
        u = db.query(User).get(u.id)

        eq_(u.username, 'new-username')
        eq_(u.github_handle, 'test-handle')
        eq_(u.name, 'Test User')
예제 #16
0
    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">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data

        rv = self.client.get('/user/joe.xml')
        assert '<entry' in rv.data
        assert ('<content type="html">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data

        rv = self.client.get('/project/prjkt.xml')
        assert '<entry' in rv.data
        assert ('<content type="html">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data

        rv = self.client.get('/team/a-team.xml')
        assert '<entry' in rv.data
        assert ('<content type="html">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data
예제 #17
0
    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">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data

        rv = self.client.get('/user/joe.xml')
        assert '<entry' in rv.data
        assert ('<content type="html">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data

        rv = self.client.get('/project/prjkt.xml')
        assert '<entry' in rv.data
        assert ('<content type="html">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data

        rv = self.client.get('/team/a-team.xml')
        assert '<entry' in rv.data
        assert ('<content type="html">&lt;h3&gt;Test Project&lt;/h3&gt;&lt;p'
                '&gt;foo&lt;/p&gt;</content>') in rv.data
예제 #18
0
    def test_profile_update(self):
        """Test that you can update your profile."""
        with self.app.app_context():
            u = user(save=True)

        authenticate(self.client, u)

        data = {
            'email': u.email,
            'username': '******',
            'github_handle': 'test-handle',
            'name': 'Test User'
        }

        response = self.client.post('/profile/', data=data)
        eq_(response.status_code, 200)

        db = get_session(self.app)
        u = db.query(User).get(u.id)

        eq_(u.username, 'new-username')
        eq_(u.github_handle, 'test-handle')
        eq_(u.name, 'Test User')