# Path: gunstar/testing.py
# class TestCase(unittest.TestCase):
# 
#     def get_app(self):
#         raise NotImplementedError()
# 
#     def _pre_setup(self):
#         self.app = self.get_app()
#         self.client = Client(self.app)
# 
#     def __call__(self, result=None):
#         self._pre_setup()
#         super(TestCase, self).__call__(result)


from gunstar.testing import TestCase
from app import app
# -*- coding: utf-8 -*-


class AppTestCase(TestCase):
    
    def get_app(self):
        return app

    def test_handlers(self):
        resp = self.client.get('/')
        self.assertEqual(resp.status_code, 200)
        self.assertTrue('<h1>Hello!</h1>'in resp.text)

        resp = self.client.get('/name/allisson/')
        self.assertEqual(resp.status_code, 200)
        self.assertTrue('<h1>Hello allisson!</h1>' in resp.text)
        self.assertTrue(resp.context['name'], 'allisson')

        resp = self.client.get('/static/index.html')
        self.assertEqual(resp.status_code, 200)
        self.assertTrue('<h1>Hello from static</h1>' in resp.text)

        resp = self.client.get('/crazy/url/')
        self.assertEqual(resp.status_code, 404)

# Path: gunstar/testing.py
# class TestCase(unittest.TestCase):
# 
#     def get_app(self):
#         raise NotImplementedError()
# 
#     def _pre_setup(self):
#         self.app = self.get_app()
#         self.client = Client(self.app)
# 
#     def __call__(self, result=None):
#         self._pre_setup()
#         super(TestCase, self).__call__(result)


# Path: examples/hello_world/tests.py
from gunstar.testing import TestCase
from app import app

# -*- coding: utf-8 -*-


class AppTestCase(TestCase):
    
    def get_app(self):
        return app

    def test_handlers(self):
        resp = self.client.get('/')
        self.assertEqual(resp.status_code, 200)
        self.assertTrue('<h1>Hello!</h1>'in resp.text)

        resp = self.client.get('/name/allisson/')
        self.assertEqual(resp.status_code, 200)
        self.assertTrue('<h1>Hello allisson!</h1>' in resp.text)
        self.assertTrue(resp.context['name'], 'allisson')

        resp = self.client.get('/static/index.html')
        self.assertEqual(resp.status_code, 200)
        self.assertTrue('<h1>Hello from static</h1>' in resp.text)

        resp = self.client.get('/crazy/url/')
        self.assertEqual(resp.status_code, 404)

        self.assertTrue('Not Found /crazy/url/' in resp.text)