Skip to content

Commit

Permalink
Added the first few tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimjshields committed Feb 12, 2015
1 parent 63db301 commit fe99339
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_tiny.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import unittest
from tiny import tiny

class TestTinyApp(unittest.TestCase):
"""Base class for testing TinyApp."""

def setUp(self):
"""Starts each test with a new, empty TinyApp object and a handler."""

self.app = tiny.TinyApp()
self.handler = lambda x: x

def tearDown(self):
"""Ends each test by destroying the TinyApp object."""

del(self.app)
del(self.handler)

def test_app_init(self):
"""Tests that each app is initialized with an empty routes dict."""

self.assertEqual(self.app.ROUTES, {})

def test_add_route(self):
"""Tests that adding a route actually adds a route to the dictionary."""

self.app.add_route('/index', self.handler)
self.assertEqual({'/index': (self.handler, ['GET'])}, self.app.ROUTES)

def test_route(self):
"""Tests that the route decorator also adds a route to the dictionary."""

@self.app.route('/index')
def decorator_handler():
pass

self.assertEqual({'/index': (decorator_handler, ['GET'])}, self.app.ROUTES)

if __name__ == "__main__":
unittest.main()

0 comments on commit fe99339

Please sign in to comment.