import pytest
import ../__init__ as init
from selenium import webdriver

LOCAL_INSTANCE =  "127.0.0.1:5000"


def test_is_running():
    init.is_running()
    
    # Firefox 
    driver = webdriver.Firefox()
    driver.get(LOCAl_INSTANCE)
    
    assert driver.body == "Flask is running"
    
    
import pytest
import rename_fotos as rfapp


LOCAL_INSTANCE =  "127.0.0.1:5000"

@pytest.fixture
def client():
    rfapp.app.config['TESTING'] = True

    with rfapp.app.test_client() as client:
        with rfapp.app.app_context():
            rfapp.init_db()
        yield client
     

def test_is_running(client):
    response = client.get('/')
    
    assert "FAIL" in response.data
    

Switch to flask built in tests
Switch to flask built in tests

  import pytest
- import ../__init__ as init
- from selenium import webdriver
+ import rename_fotos as rfapp
+ 
  
  LOCAL_INSTANCE =  "127.0.0.1:5000"
  
+ @pytest.fixture
+ def client():
+     rfapp.app.config['TESTING'] = True
  
+     with rfapp.app.test_client() as client:
+         with rfapp.app.app_context():
+             rfapp.init_db()
+         yield client
+      
+ 
- def test_is_running():
+ def test_is_running(client):
-     init.is_running()
+     response = client.get('/')
      
+     assert "FAIL" in response.data
-     # Firefox 
-     driver = webdriver.Firefox()
-     driver.get(LOCAl_INSTANCE)
      
+ 
-     assert driver.body == "Flask is running"
-     
-     
Switch to flask built in tests
## Code Before:
import pytest
import ../__init__ as init
from selenium import webdriver

LOCAL_INSTANCE =  "127.0.0.1:5000"


def test_is_running():
    init.is_running()
    
    # Firefox 
    driver = webdriver.Firefox()
    driver.get(LOCAl_INSTANCE)
    
    assert driver.body == "Flask is running"
    
    
## Instruction:
Switch to flask built in tests
## Code After:
import pytest
import rename_fotos as rfapp


LOCAL_INSTANCE =  "127.0.0.1:5000"

@pytest.fixture
def client():
    rfapp.app.config['TESTING'] = True

    with rfapp.app.test_client() as client:
        with rfapp.app.app_context():
            rfapp.init_db()
        yield client
     

def test_is_running(client):
    response = client.get('/')
    
    assert "FAIL" in response.data
    
