﻿"""Example of best practice test structure"""
import pytest
from app import create_app
from app.extensions import db

class TestBestPractice:
    @pytest.fixture(autouse=True)
    def setup(self):
        """Setup test application context."""
        self.app = create_app()
        self.app.config['TESTING'] = True
        self.client = self.app.test_client()
        self.app_context = self.app.app_context()
        self.app_context.push()
        yield
        self.app_context.pop()
    
    def test_workers_endpoint(self):
        """Test workers endpoint returns 200."""
        response = self.client.get('/workers')
        assert response.status_code == 200
    
    def test_workers_api(self):
        """Test workers API returns JSON."""
        response = self.client.get('/api/workers/')
        assert response.status_code == 200
        assert response.json is not None
    
    def test_health_check(self):
        """Test health endpoint."""
        response = self.client.get('/api/health')
        assert response.status_code == 200

if __name__ == '__main__':
    pytest.main([__file__, '-v'])
