Exemplo n.º 1
0
def test_root_returns_books_function():
    """verify that the correct function is returned by the root path"""
    from bookapp import resolve_path
    from bookapp import books as expected
    path = '/'
    actual, args = resolve_path(path)
    assert actual is expected
Exemplo n.º 2
0
    def test_favicon_path(self):
        from bookapp import resolve_path
        from bookapp import books
        import types
        path = '/favicon.ico'

        with self.assertRaises(Exception):
            func, args = resolve_path(path)
Exemplo n.º 3
0
def test_book_path_returns_book_function(storage):
    """verify that the correct function is returned by the book path"""
    from bookapp import resolve_path
    from bookapp import book as expected
    for book_id in storage.keys():
        path = '/book/{0}'.format(book_id)
        actual, args = resolve_path(path)
        assert actual is expected
Exemplo n.º 4
0
 def test_root_path(self):
     from bookapp import resolve_path
     from bookapp import books
     import types
     path = '/'
     func, args = resolve_path(path)
     self.assertTrue(isinstance(func, types.FunctionType))
     self.assertEqual(func, books)
     self.assertEqual(args, [])
Exemplo n.º 5
0
 def test_book_path(self):
     from bookapp import resolve_path
     from bookapp import book
     import types
     path = '/book/id1'
     func, args = resolve_path(path)
     self.assertTrue(isinstance(func, types.FunctionType))
     self.assertEqual(func, book)
     self.assertEqual(args, ['id1'])
Exemplo n.º 6
0
 def call_function_under_test(self, path):
     from bookapp import resolve_path
     return resolve_path(path)
Exemplo n.º 7
0
 def call_function_under_test(self, path):
     from bookapp import resolve_path
     return resolve_path(path)
Exemplo n.º 8
0
def test_bad_path_raises_name_error():
    """verify that the correct error is raised for a bad path"""
    from bookapp import resolve_path
    path = '/not/valid/path'
    with pytest.raises(NameError):
        resolve_path(path)
Exemplo n.º 9
0
def test_book_path_returns_bookid_in_args(storage):
    from bookapp import resolve_path
    for expected in storage.keys():
        path = '/book/{0}'.format(expected)
        func, actual = resolve_path(path)
        assert expected in actual
Exemplo n.º 10
0
def test_root_returns_no_args():
    """verify that no args are returned for the root path"""
    from bookapp import resolve_path
    path = '/'
    func, actual = resolve_path(path)
    assert not actual