Skip to content

Commit

Permalink
Updating integration tests to include updated feeds. Wahoo! Now to fi…
Browse files Browse the repository at this point in the history
…gure out the dupe issues through testing.
  • Loading branch information
samuelclay committed Aug 8, 2009
1 parent 555b1e3 commit 9626b46
Show file tree
Hide file tree
Showing 7 changed files with 756 additions and 17 deletions.
3 changes: 2 additions & 1 deletion apps/reader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from django.http import HttpResponse, HttpRequest
from django.core import serializers
from django.utils.safestring import mark_safe
from utils.feedcache.threading_model import fetch_feeds
from django.views.decorators.cache import cache_page
import logging
import datetime
import threading

SINGLE_DAY = 60*60*24

def index(request):
# feeds = Feed.objects.filter(usersubscription__user=request.user)
# for f in feeds:
Expand Down Expand Up @@ -76,6 +76,7 @@ def refresh_feeds(feeds, force=False):
)
for us in usersubs:
us.count_unread()
logging.info('Deleteing user sub cache: %s' % us.user_id)
cache.delete('usersub:%s' % us.user_id)
return

Expand Down
19 changes: 19 additions & 0 deletions apps/rss_feeds/fixtures/gawker1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"pk": 1,
"model": "rss_feeds.feed",
"fields": {
"feed_address": "/Users/conesus/newsblur/apps/rss_feeds/fixtures/gawker1.xml",
"days_to_trim": 90,
"feed_link": "http://gawker.com",
"num_subscribers": 0,
"creation": "2009-01-12",
"feed_title": "Gawker",
"last_update": "2009-07-06 22:30:03",
"min_to_decay": 1,
"etag": "",
"last_modified": "2009-07-06 22:30:03",
"active": 1
}
}
]
19 changes: 19 additions & 0 deletions apps/rss_feeds/fixtures/gawker2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"pk": 1,
"model": "rss_feeds.feed",
"fields": {
"feed_address": "/Users/conesus/newsblur/apps/rss_feeds/fixtures/gawker2.xml",
"days_to_trim": 90,
"feed_link": "http://gawker.com",
"num_subscribers": 0,
"creation": "2009-01-12",
"feed_title": "Gawker",
"last_update": "2009-07-06 22:30:03",
"min_to_decay": 1,
"etag": "",
"last_modified": "2009-07-06 22:30:03",
"active": 1
}
}
]
4 changes: 2 additions & 2 deletions apps/rss_feeds/fixtures/gawker2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://www.gawker.com/index.xml" type="application/rss+xml" /><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site.</feedburner:browserFriendly><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
<title><![CDATA[ iPhone to Revolutionize How Municipal Bureaucrats Ignore Residents [Utopia] ]]></title>
<description>&lt;p&gt;&lt;img src="http://gawker.com/assets/images/gawker/2009/07/iphone_3g_angry-thumb-350x618-1.jpg" height="600" align="left" width="340" /&gt;In San Francisco, citizens complain to the city over Twitter. Bostonians have it even better: they got &lt;a href="http://www.boston.com/news/local/massachusetts/articles/2009/07/06/boston_to_debut_8216killer_app8217_for_municipal_complaints/"&gt;an iPhone application&lt;/a&gt; just for carping at City Hall. It's never been easier to funnel your complaint into a Kafkaesque black hole!&lt;/p&gt; &lt;p&gt;Boston officials brag that their iPhone app is the first of its kind, allowing citizens to easily emal pictures &amp;mdash; of graffiti, potholes and the like &amp;mdash; to the city, complete with embedded GPS location tags.&lt;/p&gt; &lt;p&gt; Those residents who can't afford to blow $2,500 on an iPhone plus service plan can still use the city's 24-hour telephone hotline, which was the city's&lt;em&gt; previous&lt;/em&gt; revolutionary way of collecting complaints. How'd it go?&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;In the past, residents have grumbled that their complaints disappeared&lt;br /&gt;into a bureaucratic black hole. Some said they had to call the city&lt;br /&gt;hotline repeatedly to get results.&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;With the iPhone app, that simply won't happen anymore. Now citizens will get a &lt;em&gt;tracking number &lt;/em&gt;for their complaints, and the city will now ignore their hectoring via the &lt;em&gt;internet&lt;/em&gt;, as God intended. Thank you, Steve Jobs!&lt;/p&gt; &lt;p&gt;(Image &lt;a href="http://dvice.com/archives/2009/06/did-iphone-30-b.php"&gt;via&lt;/a&gt;)&lt;/p&gt;
<description>&lt;p&gt;&lt;img src="http://gawker.com/assets/images/gawker/2009/07/iphone_3g_angry-thumb-350x618-1.jpg" height="600" align="left" width="340" /&gt;In San Francisco, citizens complain to the city over Twizzler. Bostonians have it even better: they got &lt;a href="http://www.boston.com/news/local/massachusetts/articles/2009/07/06/boston_to_debut_8216killer_app8217_for_municipal_complaints/"&gt;an iPhone application&lt;/a&gt; just for carping at City Hall. It's never been easier to funnel your complaint into a Kafkaesque black hole!&lt;/p&gt; &lt;p&gt;Boston officials brag that their iPhone app is the first of its kind, allowing citizens to easily emal pictures &amp;mdash; of graffiti, potholes and the like &amp;mdash; to the city, complete with embedded GPS location tags.&lt;/p&gt; &lt;p&gt; Those residents who can't afford to blow $2,500 on an iPhone plus service plan can still use the city's 24-hour telephone hotline, which was the city's&lt;em&gt; previous&lt;/em&gt; revolutionary way of collecting complaints. How'd it go?&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;In the past, residents have grumbled that their complaints disappeared&lt;br /&gt;into a bureaucratic black hole. Some said they had to call the city&lt;br /&gt;hotline repeatedly to get results.&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;With the iPhone app, that simply won't happen anymore. Now citizens will get a &lt;em&gt;tracking number &lt;/em&gt;for their complaints, and the city will now ignore their hectoring via the &lt;em&gt;internet&lt;/em&gt;, as God intended. Thank you, Steve Jobs!&lt;/p&gt; &lt;p&gt;(Image &lt;a href="http://dvice.com/archives/2009/06/did-iphone-30-b.php"&gt;via&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zL-Kp-tVT0Uj_rGhL8g_4xM7MOg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zL-Kp-tVT0Uj_rGhL8g_4xM7MOg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zL-Kp-tVT0Uj_rGhL8g_4xM7MOg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zL-Kp-tVT0Uj_rGhL8g_4xM7MOg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.gawker.com/~ff/gawker/full?a=WQh4QUyfRo4:KV1u4V3l5pA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/gawker/full?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.gawker.com/~ff/gawker/full?a=WQh4QUyfRo4:KV1u4V3l5pA:H0mrP-F8Qgo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/gawker/full?d=H0mrP-F8Qgo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.gawker.com/~ff/gawker/full?a=WQh4QUyfRo4:KV1u4V3l5pA:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/gawker/full?i=WQh4QUyfRo4:KV1u4V3l5pA:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.gawker.com/~ff/gawker/full?a=WQh4QUyfRo4:KV1u4V3l5pA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/gawker/full?i=WQh4QUyfRo4:KV1u4V3l5pA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt;

&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/gawker/full/~4/WQh4QUyfRo4" height="1" width="1"/&gt;</description>
<link>http://feeds.gawker.com/~r/gawker/full/~3/WQh4QUyfRo4/iphone-to-revolutionize-how-municipal-bureaucrats-ignore-residents</link>
<link>http://feeds.gawker.com/~r/gawker/full/~3/WQh4QUyfRo/iphone-to-revolutionize-how-municipal-bureaucrats-ignore-residents</link>
<guid isPermaLink="false"><![CDATA[Gawker-5308831]]></guid>
<category><![CDATA[ utopia ]]></category>
<category><![CDATA[Apple]]></category>
Expand Down
91 changes: 84 additions & 7 deletions apps/rss_feeds/fixtures/rss_feeds.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[



{
"pk": 3,
"pk": 1,
"model": "rss_feeds.feed",
"fields": { "feed_address": "/Users/conesus/Projects/newsblur/apps/rss_feeds/fixtures/gawker1.xml",
"fields": { "feed_address": "/Users/conesus/newsblur/apps/rss_feeds/fixtures/gawker1.xml",
"days_to_trim": 90,
"feed_link": "http://gawker.com",
"num_subscribers": 0,
Expand All @@ -18,7 +21,7 @@
{
"pk": 2,
"model": "rss_feeds.feed",
"fields": { "feed_address": "/Users/conesus/Projects/newsblur/apps/rss_feeds/fixtures/brownstoner.xml",
"fields": { "feed_address": "/Users/conesus/newsblur/apps/rss_feeds/fixtures/brownstoner.xml",
"days_to_trim": 90,
"feed_link": "http://www.brownstoner.com/",
"num_subscribers": 0,
Expand All @@ -32,10 +35,10 @@
}
},
{
"pk": 19,
"pk": 3,
"model": "rss_feeds.feed",
"fields": {
"feed_address": "/Users/conesus/Projects/newsblur/apps/rss_feeds/fixtures/daringfireball.xml",
"feed_address": "/Users/conesus/newsblur/apps/rss_feeds/fixtures/daringfireball.xml",
"days_to_trim": 90,
"feed_link": "http://daringfireball.net/",
"num_subscribers": 0,
Expand All @@ -48,12 +51,86 @@
"active": 1
}
},




{
"pk": 1,
"model": "reader.usersubscriptionfolders",
"fields": {
"feed": 1,
"user_sub": 1,
"folder": "Blogs",
"user": 1
}
},

{
"pk": 1,
"model": "reader.usersubscription",
"fields": {
"feed": 1,
"unread_count_updated": "2009-08-01 00:23:42",
"mark_read_date": "2009-07-28 23:17:27",
"unread_count": 0,
"user": 1,
"last_read_date": "2009-07-28 23:17:27"
}
},
{
"pk": 2,
"model": "reader.usersubscriptionfolders",
"fields": {
"feed": 2,
"user_sub": 2,
"folder": "Blogs",
"user": 1
}
},

{
"pk": 2,
"model": "reader.usersubscription",
"fields": {
"feed": 2,
"unread_count_updated": "2009-08-01 00:23:42",
"mark_read_date": "2009-07-28 23:17:27",
"unread_count": 0,
"user": 1,
"last_read_date": "2009-07-28 23:17:27"
}
},
{
"pk": 3,
"model": "reader.usersubscriptionfolders",
"fields": {
"feed": 3,
"user_sub": 3,
"folder": "Blogs",
"user": 1
}
},

{
"pk": 3,
"model": "reader.usersubscription",
"fields": {
"feed": 3,
"unread_count_updated": "2009-08-01 00:23:42",
"mark_read_date": "2009-07-28 23:17:27",
"unread_count": 0,
"user": 1,
"last_read_date": "2009-07-28 23:17:27"
}
},



{
"pk": 1,
"model": "auth.user",
"fields": {
"username": "test",
"username": "conesus",
"first_name": "",
"last_name": "",
"is_active": 1,
Expand Down
20 changes: 13 additions & 7 deletions apps/rss_feeds/tests.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
from django.utils import simplejson as json
from django.test.client import Client
from django.test import TestCase
from django.core import management

class FeedTest(TestCase):
fixtures = ['fixtures/rss_feeds.json']
fixtures = ['rss_feeds.json']

def setUp(self):
self.client = Client()

def test_load_feeds(self):
self.client.login(userame='test', password='test')
response = self.client.get('/reader/refresh_feed', { "feed_id": 19, "force": True })
response = self.client.get('/reader/refresh_feed', { "feed_id": 19, "force": True })
response = self.client.get('/reader/load_single_feed', { "feed_id": 19 })
print response.content
print json.loads(response.content)[0]
self.client.login(userame='conesus', password='test')

management.call_command('loaddata', 'gawker1.json', verbosity=0)
response = self.client.get('/reader/refresh_feed', { "feed_id": 1, "force": True })

management.call_command('loaddata', 'gawker2.json', verbosity=0)
response = self.client.get('/reader/refresh_feed', { "feed_id": 1, "force": True })

response = self.client.get('/reader/load_single_feed', { "feed_id": 1 })
print [c['story_title'] for c in json.loads(response.content)]
# print json.loads(response.content)[0]
Loading

0 comments on commit 9626b46

Please sign in to comment.