songs2slides

A tool that automatically finds song lyrics and creates lyric slideshows
git clone https://git.ashermorgan.net/songs2slides/
Log | Files | Refs | README

conftest.py (1070B)


      1 import os
      2 import pytest
      3 from xprocess import ProcessStarter
      4 
      5 @pytest.fixture(scope='session')
      6 def api(xprocess):
      7     port = '5003'
      8 
      9     class Starter(ProcessStarter):
     10         pattern = '.*Running.*'
     11         timeout = 10
     12         args = ['python', '-m', 'flask', '--app', '../../../../mock_api.py',
     13                 'run', '--port', port]
     14 
     15     # Start API
     16     xprocess.ensure('api', Starter)
     17 
     18     yield f'http://localhost:{port}'
     19 
     20     # Stop API
     21     xprocess.getinfo('api').terminate()
     22 
     23 @pytest.fixture(scope='session')
     24 def server(xprocess, api):
     25     port = '5002'
     26 
     27     class Starter(ProcessStarter):
     28         pattern = '.*Running.*'
     29         timeout = 10
     30         args = ['python', '-m', 'flask', '--app', '../../../../songs2slides',
     31                 'run', '--port', port]
     32         env = os.environ | { 'API_URL': api + '/{title}/{artist}/' }
     33 
     34     # Start server
     35     xprocess.ensure('server', Starter)
     36 
     37     yield f'http://localhost:{port}'
     38 
     39     # Stop server
     40     xprocess.getinfo('server').terminate()
     41 
     42 @pytest.fixture(scope='session')
     43 def base_url(server):
     44     return server