annotate tests/couchdb/FeedTests.py @ 199:1220e62b63dd

implement a somewhat useful unit test for the Feed class
author dirk
date Fri, 27 Jan 2012 02:51:36 +0100
parents 7217b060b39c
children a122d42bfe72
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
136
7217b060b39c implement a Feed class that can be used to query feed and that wraps view results
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1
7217b060b39c implement a Feed class that can be used to query feed and that wraps view results
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
2 from backend.couchdb.Feed import Feed
199
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
3 from couchdb.client import Server
136
7217b060b39c implement a Feed class that can be used to query feed and that wraps view results
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4 import unittest
199
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
5 from couchdb.http import ResourceNotFound
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
6
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
7 DATABASE_NAME = "feedworm-unit-tests"
136
7217b060b39c implement a Feed class that can be used to query feed and that wraps view results
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
8
199
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
9 class FeedTests(unittest.TestCase):
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
10 def testCreateFeed(self):
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
11 title = "new feed"
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
12 url = "http://localhost"
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
13 newFeed = Feed.create(url, title)
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
14 newFeed.store(self.database)
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
15 feedId = newFeed.id
136
7217b060b39c implement a Feed class that can be used to query feed and that wraps view results
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
16
199
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
17 feedFromDatabase = self.database[feedId]
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
18 self.assertNotEqual(None, feedFromDatabase)
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
19 self.assertEqual(title, feedFromDatabase["title"])
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
20 self.assertEqual(url, feedFromDatabase["rss_url"])
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
21
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
22 def __testListAllFeeds(self):
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
23 pass
136
7217b060b39c implement a Feed class that can be used to query feed and that wraps view results
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
24
199
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
25 def setUp(self):
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
26 self._createDatabase()
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
27
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
28 def tearDown(self):
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
29 self.server.delete(self.database.name)
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
30
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
31 def _createDatabase(self):
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
32 self.server = Server()
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
33 try:
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
34 self.database = self.server[DATABASE_NAME]
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
35 except (ResourceNotFound):
1220e62b63dd implement a somewhat useful unit test for the Feed class
dirk
parents: 136
diff changeset
36 self.database = self.server.create(DATABASE_NAME)
136
7217b060b39c implement a Feed class that can be used to query feed and that wraps view results
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
37
7217b060b39c implement a Feed class that can be used to query feed and that wraps view results
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
38 if __name__ == "__main__":
7217b060b39c implement a Feed class that can be used to query feed and that wraps view results
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
39 #import sys;sys.argv = ['', 'Test.testName']
7217b060b39c implement a Feed class that can be used to query feed and that wraps view results
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
40 unittest.main()