Metadata-Version: 1.1
Name: TestLiveServer
Version: 0.0.0
Summary: Simple utility for running a Flask development server for BDD/functional testing purposes.
Home-page: http://github.com/peterhudec/testliveserver
Author: Peter Hudec
Author-email: peterhudec@peterhudec.com
License: MIT
Description: ================
        Test Live Server
        ================
        
        **Test Live Server** is a very simple utility for running
        a Flask development server for **BDD/functional** testing purposes.
        
        I'm planning to add support for other frameworks in future.
        
        Usage
        -----
        
        Add the **Test Live Server** capability to your Flask app by calling the
        ``testliveserver.flask.live_server(app)`` function just before the ``app.run()``.
        
        .. code-block:: python
        	
        	from flask import Flask
        
        	DEBUG = True
        	SECRET_KEY = 'development key'
        	USERNAME = 'admin'
        	PASSWORD = 'default'
        
        	app = Flask(__name__)
        	app.config.from_object(__name__)
        
        	@app.route('/')
        	def home():
        	    return 'Home'
        
        	if __name__ == '__main__':
        	    
        	    # This does nothing unles you run this module with --testliveserver flag.
        	    from testliveserver.flask import live_server
        	    live_server(app)
        	    
        	    app.run()
        
        In your test setup call the ``testliveserver.start(app_main, port_number)``
        function which will run the Flask app with the ``--testliveserver`` flag.
        The function returns the process of the running app
        which you can terminate in the teardown.
        
        .. code-block:: python
        	
        	import testliveserver
        	import unittest
        	from selenium import webdriver
        
        	HOST = '127.0.0.1:8001'
        	HOME = 'http://{}/'.format(HOST)
        	LIVESERVER_PATH = testliveserver.abspath(__file__, '../../sample_apps/flask_sample/main.py')
        
        	class TestWebsite(unittest.TestCase):
        	    
        	    @classmethod
        	    def setUpClass(cls):
        	        try:
        	            # Run the live server.
        	            cls.process = testliveserver.start(LIVESERVER_PATH, HOST)
        	        except Exception as e:
        	            # Stop all tests if not started in timeout.
        	            raise unittest.SkipTest(e.message)
        	        
        	        # Start browser.
        	        cls.browser = webdriver.Chrome()
        	        cls.browser.implicitly_wait(3)
        	    
        	    @classmethod
        	    def tearDownClass(cls):
        	        # Stop server.
        	        if hasattr(cls, 'process'):
        	            cls.process.terminate()
        	         
        	        # Stop browser.
        	        if hasattr(cls, 'browser'):
        	            cls.browser.quit()
        	    
        	    def test_visit_start_page(self):
        	        self.browser.get(HOME)
        	        page_text = self.browser.find_element_by_tag_name('body').text
        	        self.assertIn('Home', page_text)
        
        
        	if __name__ == '__main__':
        	    unittest.main()
Keywords: Flask,BDD,TDD,functional testing,live server
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: JavaScript
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
