Mercurial > hg > Feedworm
annotate tests/couchdb/FeedTests.py @ 238:6a3e3a0a7efe
add a test profile
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Sat, 25 Apr 2015 04:09:04 +0200 |
parents | bb3c851b18b1 |
children | 7c719c4f5655 |
rev | line source |
---|---|
217
bb3c851b18b1
add source file endcoding header
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
200
diff
changeset
|
1 # -*- coding: utf-8 -*- |
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
|
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 setUp(self): |
1220e62b63dd
implement a somewhat useful unit test for the Feed class
dirk
parents:
136
diff
changeset
|
23 self._createDatabase() |
1220e62b63dd
implement a somewhat useful unit test for the Feed class
dirk
parents:
136
diff
changeset
|
24 |
1220e62b63dd
implement a somewhat useful unit test for the Feed class
dirk
parents:
136
diff
changeset
|
25 def tearDown(self): |
1220e62b63dd
implement a somewhat useful unit test for the Feed class
dirk
parents:
136
diff
changeset
|
26 self.server.delete(self.database.name) |
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 _createDatabase(self): |
1220e62b63dd
implement a somewhat useful unit test for the Feed class
dirk
parents:
136
diff
changeset
|
29 self.server = Server() |
1220e62b63dd
implement a somewhat useful unit test for the Feed class
dirk
parents:
136
diff
changeset
|
30 try: |
1220e62b63dd
implement a somewhat useful unit test for the Feed class
dirk
parents:
136
diff
changeset
|
31 self.database = self.server[DATABASE_NAME] |
1220e62b63dd
implement a somewhat useful unit test for the Feed class
dirk
parents:
136
diff
changeset
|
32 except (ResourceNotFound): |
1220e62b63dd
implement a somewhat useful unit test for the Feed class
dirk
parents:
136
diff
changeset
|
33 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
|
34 |
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
|
35 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
|
36 #import sys;sys.argv = ['', 'Test.testName'] |
217
bb3c851b18b1
add source file endcoding header
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
200
diff
changeset
|
37 unittest.main() |