# Path: henet/tests/support.py
# class TestView(unittest.TestCase):
# 
#     def setUp(self):
#         self.config = os.path.join(HERE, 'config.ini')
#         hdl, self.config_file = tempfile.mkstemp()
#         with open(self.config) as f:
#             os.write(hdl, f.read() % {'testdir': HERE})
#         os.close(hdl)
#         environ = {'HTTP_X_FORWARDED_FOR': '168.0.0.1',
#                    'REMOTE_ADDR': '127.0.0.1'}
#         self.app = TestApp(make_app(self.config_file),
#                            extra_environ=environ)
#         self.config = Config(unicode(self.config_file))
#         self.tmp_content = tempfile.mkdtemp()
#         self.save_content = os.path.join(self.tmp_content, 'content')
#         shutil.copytree(content, self.save_content)
# 
#     def tearDown(self):
#         os.remove(self.config_file)
#         shutil.rmtree(content)
#         shutil.move(self.save_content, content)
#         shutil.rmtree(self.tmp_content)
# 
# Path: henet/rst/parse.py
# def parse_article(filename, destination=None):
#     settings = OptionParser(components=(Parser,)).get_default_values()
#     pub = core.Publisher(None, None, None, settings=settings)
#     pub.set_components('standalone', 'restructuredtext', 'html')
#     pub.writer = Writer()
#     pub.set_source(None, filename)
# 
#     if destination is not None:
#         pub.set_destination(None, destination)
#     else:
#         pub.destination_class = io.NullOutput
#         pub.set_destination(None, None)
# 
#     pub.process_programmatic_settings(None, None, None)
#     try:
#         pub.publish()
#     except SystemExit as e:
#         article = pub.writer.visitor.article
#         with open(filename) as f:
#             article.original_source = f.read()
# 
#     return pub.writer.visitor.article


import os
from henet.tests.support import TestView
from henet.rst.parse import parse_article
        create_form = resp.forms[2]
        create_form['title'] = 'New article'
        resp = create_form.submit('cat_add_actus')
        filename2 = os.path.join(cat_dir, 'new-article1.rst')
        self.assertTrue(os.path.exists(filename2))
        os.remove(filename2)

        # let's suppress the first article
        resp = self.app.get('/category/actus').follow()
        for form in resp.forms.values():
            if 'new-article' in form.action:
                form.submit()
                break

        # should be gone
        resp = self.app.get('/category/actus').follow()
        self.assertTrue('New article' not in resp.text)

    def test_no_empty_title(self):
        resp = self.app.get('/category/actus')
        self.assertEqual(resp.status_int, 302)
        resp = resp.follow()
        self.assertEqual(resp.status_int, 200)

        # adding an article
        create_form = resp.forms[1]
        resp = create_form.submit('cat_add_actus')

        # we should be redirected to the category with a flash
        # message

# Path: henet/tests/support.py
# class TestView(unittest.TestCase):
# 
#     def setUp(self):
#         self.config = os.path.join(HERE, 'config.ini')
#         hdl, self.config_file = tempfile.mkstemp()
#         with open(self.config) as f:
#             os.write(hdl, f.read() % {'testdir': HERE})
#         os.close(hdl)
#         environ = {'HTTP_X_FORWARDED_FOR': '168.0.0.1',
#                    'REMOTE_ADDR': '127.0.0.1'}
#         self.app = TestApp(make_app(self.config_file),
#                            extra_environ=environ)
#         self.config = Config(unicode(self.config_file))
#         self.tmp_content = tempfile.mkdtemp()
#         self.save_content = os.path.join(self.tmp_content, 'content')
#         shutil.copytree(content, self.save_content)
# 
#     def tearDown(self):
#         os.remove(self.config_file)
#         shutil.rmtree(content)
#         shutil.move(self.save_content, content)
#         shutil.rmtree(self.tmp_content)
# 
# Path: henet/rst/parse.py
# def parse_article(filename, destination=None):
#     settings = OptionParser(components=(Parser,)).get_default_values()
#     pub = core.Publisher(None, None, None, settings=settings)
#     pub.set_components('standalone', 'restructuredtext', 'html')
#     pub.writer = Writer()
#     pub.set_source(None, filename)
# 
#     if destination is not None:
#         pub.set_destination(None, destination)
#     else:
#         pub.destination_class = io.NullOutput
#         pub.set_destination(None, None)
# 
#     pub.process_programmatic_settings(None, None, None)
#     try:
#         pub.publish()
#     except SystemExit as e:
#         article = pub.writer.visitor.article
#         with open(filename) as f:
#             article.original_source = f.read()
# 
#     return pub.writer.visitor.article


# Path: henet/tests/test_view_category.py
import os
from henet.tests.support import TestView
from henet.rst.parse import parse_article

        create_form = resp.forms[2]
        create_form['title'] = 'New article'
        resp = create_form.submit('cat_add_actus')
        filename2 = os.path.join(cat_dir, 'new-article1.rst')
        self.assertTrue(os.path.exists(filename2))
        os.remove(filename2)

        # let's suppress the first article
        resp = self.app.get('/category/actus').follow()
        for form in resp.forms.values():
            if 'new-article' in form.action:
                form.submit()
                break

        # should be gone
        resp = self.app.get('/category/actus').follow()
        self.assertTrue('New article' not in resp.text)

    def test_no_empty_title(self):
        resp = self.app.get('/category/actus')
        self.assertEqual(resp.status_int, 302)
        resp = resp.follow()
        self.assertEqual(resp.status_int, 200)

        # adding an article
        create_form = resp.forms[1]
        resp = create_form.submit('cat_add_actus')

        # we should be redirected to the category with a flash
        # message

        cat_page = resp.follow().follow()