예제 #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