Created
August 15, 2012 22:23
-
-
Save sivy/3364274 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from nose.tools import ok_, eq_ | |
import unittest | |
from google.appengine.ext import testbed | |
from google.appengine.ext import ndb | |
from webtest import TestApp | |
from admin import app | |
from models import compute_hash | |
from fixture import FixtureLoader | |
class Subscription(ndb.Model): | |
"""Subscription to a feed.""" | |
name = ndb.StringProperty() | |
feed_url = ndb.TextProperty() | |
last_updated = ndb.DateTimeProperty() | |
etag = ndb.StringProperty() | |
subscribed = ndb.BooleanProperty(default=True) | |
categories = ndb.StringProperty(repeated=True) | |
# Support for custom feeds that don't conform to RSS/Atom (AP) | |
type = ndb.StringProperty() | |
# For feeds that require basic authentication (AP) | |
username = ndb.StringProperty() | |
password = ndb.StringProperty() | |
# Pubsub-specific properties | |
is_pubsub = ndb.BooleanProperty(default=False) | |
# Does the feed have full-text articles (as opposed to excerpts)? | |
full_text = ndb.BooleanProperty(default=False) | |
# When feed was confirmed to be valid (for pubsub) | |
confirmed_time = ndb.DateTimeProperty() | |
class TestbedTest(unittest.TestCase): | |
def setUp(self): | |
self.testbed = testbed.Testbed() | |
self.testbed.activate() | |
self.testbed.init_datastore_v3_stub() | |
self.testbed.init_memcache_stub() | |
self.ctx = ndb.tasklets.make_default_context() | |
ndb.tasklets.set_context(self.ctx) | |
def tearDown(self): | |
self.testbed.deactivate() | |
class TestDbPutCase(TestbedTest): | |
def test_db_put(self): | |
instance = Subscription( | |
id=compute_hash("http://daringfireball.net/index.xml"), | |
feed_url="http://daringfireball.net/index.xml", | |
name="Daring Fireball - correct", | |
subscribed=True, | |
full_text=True) | |
ok_(instance) | |
instance.put() | |
class TestPageLoad(TestbedTest): | |
def test_page_load(self): | |
self.testapp = TestApp(app) | |
response = self.testapp.get('/_admin') | |
eq_(response.status, '200 OK') | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment