Exemplo n.º 1
0
    def tearDown(self):
        with tvservice.shows_db() as shows:
            keys = shows.keys()
            for key in keys:
                del shows[key]

        reload(tvservice)
Exemplo n.º 2
0
    def testPUT(self):
        req = Request.blank("/shows/test", method="PUT", body="Test",
                            authorization=self.authorization,
                            content_type="text/plain")

        res = req.get_response(tvservice.application)

        self.assertEqual(res.status, "200 OK")
        self.assertEqual(res.body, "Test")
        self.assertEqual(res.content_type, "text/plain")

        with tvservice.shows_db() as shows:
            self.assertEqual(shows["test"], "Test")
Exemplo n.º 3
0
    def testDELETE(self):
        with tvservice.shows_db() as shows:
            shows['test'] = "Test"

        req = Request.blank("/shows/test", method="DELETE",
                            authorization=self.authorization)
        res = req.get_response(tvservice.application)

        self.assertEqual(res.status, "204 No Content")

        req = Request.blank("/shows/test", method="DELETE",
                            authorization=self.authorization)
        res = req.get_response(tvservice.application)
        self.assertEqual(res.status, "404 Not Found")
Exemplo n.º 4
0
    def setUp(self):
        with tvservice.shows_db() as shows:
            shows['test'] = "Test"
            shows['shit'] = 'Shit'

        self.fixture = """<rss version="2.0">
   <item><title>Test S01E01</title></item>
   <item><title>Show with a x in it S01E01</title></item>
   <item><title>Shitake Mushrooms S01E01</title></item>
   <item><title>Shit Talkers S01E01</title></item>
   <item><title>Shit Talkers s01e01</title></item>
   <item><title>Shit.Talkers.S01E01</title></item>
   <item><title>Test</title></item>
</rss>"""

        tvservice.get_feed = lambda: self.fixture
Exemplo n.º 5
0
    def testGET(self):
        req = Request.blank("/shows/test", method="GET",
                            authorization=self.authorization)

        res = req.get_response(tvservice.application)
        self.assertEqual(res.status, "404 Not Found")

        with tvservice.shows_db() as shows:
            shows['test'] = "Test"


        req = Request.blank("/shows/test", method="GET",
                            authorization=self.authorization)

        res = req.get_response(tvservice.application)
        self.assertEqual(res.status, "200 OK")
        self.assertEqual(res.body, "Test")
        self.assertEqual(res.content_type, "text/plain")
Exemplo n.º 6
0
 def setUp(self):
     self.authorization = "Basic " + "test-user:test-password".encode("base64")
     with tvservice.shows_db() as shows:
         shows['test'] = "Test!"
         shows['himym'] = "How I Met Your Mother"