def tearDown(self): with tvservice.shows_db() as shows: keys = shows.keys() for key in keys: del shows[key] reload(tvservice)
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")
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")
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
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")
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"