Skip to content

Commit

Permalink
add json test
Browse files Browse the repository at this point in the history
  • Loading branch information
therealmarv committed Jan 24, 2017
1 parent 540a678 commit 8b9b051
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,34 @@ def test_profile_projects(self, mock):
assert res.status_code == 403, res.status_code


@with_context
@patch('pybossa.view.projects.uploader.upload_file', return_value=True)
def test_profile_projects_json(self, mock):
"""Test WEB user profile project page works."""
self.create()
self.signin(email=Fixtures.email_addr, password=Fixtures.password)
self.new_project()
url = '/account/%s/projects' % Fixtures.name
res = self.app_get_json(url)
data = json.loads(res.data)
assert data['title'] == 'Projects', data
assert data['template'] == 'account/projects.html', data
assert 'projects_draft' in data, data
assert 'projects_published' in data, data

assert data['projects_draft'][0]['id'] == 2
assert data['projects_published'][0]['id'] == 1
assert data['projects_published'][0]['name'] == Fixtures.project_name

url = '/account/fakename/projects'
res = self.app.get(url)
assert res.status_code == 404, res.status_code

url = '/account/%s/projects' % Fixtures.name2
res = self.app.get(url)
assert res.status_code == 403, res.status_code


@with_context
def test_05_update_user_profile_json(self):
"""Test WEB update user profile JSON"""
Expand Down

0 comments on commit 8b9b051

Please sign in to comment.