Skip to content

Commit

Permalink
Make as separate step and adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekSuchanek committed Jul 5, 2018
1 parent ddc7d5f commit dee5e27
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions repocribro/controllers/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,11 @@ def repository_update():
flask.abort(404)

gh_repo = gh_api.get('/repos/' + full_name)
gh_repo_langs = gh_api.get('/repos/' + full_name + '/languages')
if gh_repo.is_ok and gh_repo_langs.is_ok:
if gh_repo.is_ok:
repo.update_from_dict(gh_repo.data)
repo.update_languages(gh_repo_langs.data)
gh_repo_langs = gh_api.get('/repos/' + full_name + '/languages')
if gh_repo_langs.is_ok:
repo.update_languages(gh_repo_langs.data)
db.session.commit()
else:
flask.flash('GitHub doesn\'t know about this repository. '
Expand Down
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ class FakeGitHubAPI:
'private': False, 'permissions': {'admin': True},
'owner': {'id': 65, 'login': 'regular'}
},
'/repos/regular/repo2/languages': {
'Javascript': 100
},
'/repos/regular/repo3': {
'id': 102, 'full_name': 'regular/repo3', 'name': 'repo3',
'language': 'Haskell', 'html_url': '', 'description': '',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_controller_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_repo_owner(filled_db_session, app_client):
def test_repo_detail(filled_db_session, app_client):
res = app_client.get('/repo/regular/repo1') # PUBLIC
assert res.status == '200 OK'
assert 'Python' in res.data.decode('utf-8')
assert 'regular/repo1' in res.data.decode('utf-8')

res = app_client.get('/repo/regular/repo666')
assert res.status == '404 NOT FOUND'
Expand Down Expand Up @@ -80,7 +80,7 @@ def test_repo_hidden(filled_db_session, app_client):
secret_url = '/hidden-repo/' + repo.secret
res = app_client.get(secret_url)
assert res.status == '200 OK'
assert 'Python' in res.data.decode('utf-8')
assert 'regular/repo2' in res.data.decode('utf-8')


# TODO: learn how to teardown (its weird)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_controller_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_authorized_repos(filled_db_session, app_client):

res = app_client.get('/manage/repository/regular/repo1')
assert res.status == '200 OK'
assert 'Python' in res.data.decode('utf-8')
assert 'regular/repo1' in res.data.decode('utf-8')

repo2 = filled_db_session.query(Repository).filter_by(
full_name='regular/repo2'
Expand Down

0 comments on commit dee5e27

Please sign in to comment.