示例#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
示例#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)
示例#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
示例#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, [])
示例#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'])
示例#6
0
文件: tests.py 项目: lukeatuwpce/wsgi
 def call_function_under_test(self, path):
     from bookapp import resolve_path
     return resolve_path(path)
示例#7
0
 def call_function_under_test(self, path):
     from bookapp import resolve_path
     return resolve_path(path)
示例#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)
示例#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
示例#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