view tests/couchdb/FeedTests.py @ 246:7c719c4f5655

Fix all remaining code style bugs
author Dirk Olmes <dirk@xanthippe.ping.de>
date Tue, 09 Jun 2015 02:45:29 +0200
parents bb3c851b18b1
children
line wrap: on
line source

# -*- coding: utf-8 -*-
from backend.couchdb.Feed import Feed
from couchdb.client import Server
import unittest
from couchdb.http import ResourceNotFound

DATABASE_NAME = "feedworm-unit-tests"

class FeedTests(unittest.TestCase):
    def testCreateFeed(self):
        title = "new feed"
        url = "http://localhost"
        newFeed = Feed.create(url, title)
        newFeed.store(self.database)
        feedId = newFeed.id

        feedFromDatabase = self.database[feedId]
        self.assertNotEqual(None, feedFromDatabase)
        self.assertEqual(title, feedFromDatabase["title"])
        self.assertEqual(url, feedFromDatabase["rss_url"])

    def setUp(self):
        self._createDatabase()

    def tearDown(self):
        self.server.delete(self.database.name)

    def _createDatabase(self):
        self.server = Server()
        try:
            self.database = self.server[DATABASE_NAME]
        except (ResourceNotFound):
            self.database = self.server.create(DATABASE_NAME)

if __name__ == "__main__":
    # import sys;sys.argv = ['', 'Test.testName']
    unittest.main()