-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add instagram live test and cron job to trigger nightly circle build
for #106
- Loading branch information
Showing
6 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
/*.egg-info | ||
/l | ||
/local/ | ||
circleci_token | ||
datastore.dat | ||
oauth_client_secret | ||
plus-dogfood.json | ||
|
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""Cron jobs. Currently just nightly CircleCI build.""" | ||
|
||
import appengine_config | ||
|
||
import requests | ||
import webapp2 | ||
|
||
CIRCLECI_TOKEN = appengine_config.read('circleci_token') | ||
|
||
|
||
class BuildCircle(webapp2.RequestHandler): | ||
def get(self): | ||
resp = requests.post('https://circleci.com/api/v1.1/project/github/snarfed/granary/tree/master?circle-token=%s' % CIRCLECI_TOKEN) | ||
resp.raise_for_status() | ||
|
||
|
||
application = webapp2.WSGIApplication([ | ||
('/cron/build_circle', BuildCircle), | ||
], debug=appengine_config.DEBUG) |
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,7 @@ | ||
# timezone defaults to UTC | ||
# docs: https://developers.google.com/appengine/docs/python/config/cron | ||
|
||
cron: | ||
- description: nightly CircleCI build | ||
url: /cron/build_circle | ||
schedule: every 24 hours |
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,53 @@ | ||
#!/usr/bin/env python | ||
"""Instagram integration test against the live site. | ||
Just checks that fetching and converting snarfed's feed includes 12 activities, | ||
and all the expected fields are non-empty. | ||
https://github.com/snarfed/granary/issues/106 | ||
""" | ||
import logging | ||
import sys | ||
import unittest | ||
|
||
from granary import instagram | ||
from granary.source import SELF | ||
|
||
USERNAME = 'snarfed' | ||
|
||
|
||
class InstagramTestLive(unittest.TestCase): | ||
|
||
def test_live(self): | ||
resp = instagram.Instagram().get_activities_response( | ||
user_id=USERNAME, group_id=SELF, scrape=True, | ||
fetch_replies=True, fetch_likes=True) | ||
|
||
for field in 'username', 'displayName', 'url', 'image', 'id': | ||
self.assertTrue(resp['actor'][field], field) | ||
|
||
self.assertTrue(resp['actor']['image']['url']) | ||
|
||
items = resp['items'] | ||
self.assertEqual(12, len(items)) | ||
|
||
found = set() | ||
for a in items: | ||
self.assertTrue(a['actor']) | ||
for field in 'id', 'url', 'attachments', 'author', 'image': | ||
self.assertTrue(a['object'][field], field) | ||
for field in 'content', 'replies', 'tags': | ||
if a['object'].get(field): | ||
found.add(field) | ||
|
||
for field in 'content', 'replies', 'tags': | ||
self.assertIn(field, found) | ||
|
||
|
||
if __name__ == '__main__': | ||
if '--debug' in sys.argv: | ||
sys.argv.remove('--debug') | ||
logging.getLogger().setLevel(logging.DEBUG) | ||
else: | ||
logging.getLogger().setLevel(logging.CRITICAL + 1) | ||
unittest.main() |