forked from codeforamerica/cfapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request codeforamerica#322 from tdooner/add-logo-url
Add `logo_url` to Organization API response
- Loading branch information
Showing
4 changed files
with
86 additions
and
6 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
migrations/versions/2864e71a466e_add_logo_url_to_organization.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Add Logo URL to Organization | ||
Revision ID: 2864e71a466e | ||
Revises: a5abdf9487c | ||
Create Date: 2018-01-25 15:59:31.973635 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '2864e71a466e' | ||
down_revision = 'a5abdf9487c' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
def upgrade(): | ||
### commands auto generated by Alembic - please adjust! ### | ||
op.add_column('organization', sa.Column('logo_url', sa.Unicode(), nullable=True)) | ||
### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column('organization', 'logo_url') | ||
### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,9 @@ def response_content(self, url, request): | |
elif self.results_state == 'after': | ||
return response(200, '''\n'''.join(project_lines[0:2]), {'content-type': 'text/csv; charset=UTF-8'}) | ||
|
||
# json of user description | ||
elif url.geturl() == 'https://api.github.com/users/codeforamerica': | ||
return response(200, '''{ "login": "codeforamerica", "id": 337792, "avatar_url": "https://avatars2.githubusercontent.com/u/337792?v=4", "gravatar_id": "", "url": "https://api.github.com/users/codeforamerica", "html_url": "https://github.com/codeforamerica", "followers_url": "https://api.github.com/users/codeforamerica/followers", "following_url": "https://api.github.com/users/codeforamerica/following{/other_user}", "gists_url": "https://api.github.com/users/codeforamerica/gists{/gist_id}", "starred_url": "https://api.github.com/users/codeforamerica/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/codeforamerica/subscriptions", "organizations_url": "https://api.github.com/users/codeforamerica/orgs", "repos_url": "https://api.github.com/users/codeforamerica/repos", "events_url": "https://api.github.com/users/codeforamerica/events{/privacy}", "received_events_url": "https://api.github.com/users/codeforamerica/received_events", "type": "Organization", "site_admin": false, "name": "Code for America", "company": null, "blog": "http://codeforamerica.org", "location": null, "email": "[email protected]", "hireable": null, "bio": null, "public_repos": 659, "public_gists": 0, "followers": 0, "following": 0, "created_at": "2010-07-19T19:41:04Z", "updated_at": "2017-09-05T10:22:41Z" }''') | ||
# json of project descriptions | ||
elif url.geturl() == 'https://api.github.com/users/codeforamerica/repos': | ||
return response(200, '''[{ "id": 10515516, "name": "cityvoice", "owner": { "login": "codeforamerica", "avatar_url": "https://avatars.githubusercontent.com/u/337792", "html_url": "https://github.com/codeforamerica", "type": "Organization"}, "html_url": "https://github.com/codeforamerica/cityvoice", "description": "A place-based call-in system for gathering and sharing community feedback", "url": "https://api.github.com/repos/codeforamerica/cityvoice", "contributors_url": "https://api.github.com/repos/codeforamerica/cityvoice/contributors", "created_at": "2013-06-06T00:12:30Z", "updated_at": "2014-02-21T20:43:16Z", "pushed_at": "2014-02-21T20:43:16Z", "homepage": "http://www.cityvoiceapp.com/", "stargazers_count": 10, "watchers_count": 10, "language": "Ruby", "forks_count": 12, "open_issues": 37, "languages_url": "https://api.github.com/repos/codeforamerica/cityvoice/languages" }]''', headers=dict(Link='<https://api.github.com/user/337792/repos?page=2>; rel="next", <https://api.github.com/user/337792/repos?page=2>; rel="last"')) | ||
|
@@ -1656,6 +1659,17 @@ def test_commit_status(self): | |
cityvoice = self.db.session.query(Project).filter(filter).first() | ||
self.assertEqual("success", cityvoice.commit_status) | ||
|
||
def test_logo_fetching(self): | ||
""" Test grabbing the organization logo """ | ||
with HTTMock(self.response_content): | ||
import run_update | ||
run_update.main(org_sources=run_update.TEST_ORG_SOURCES_FILENAME) | ||
|
||
from app import Organization | ||
filter = Organization.name == u'Code for America (2)' | ||
cfa = self.db.session.query(Organization).filter(filter).first() | ||
self.assertEqual("https://avatars2.githubusercontent.com/u/337792?v=4", cfa.logo_url) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |