test_integration.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. """
  2. Tests de integración que requieren Camoufox funcionando.
  3. Estos tests pueden saltarse en CI con: pytest -m "not integration"
  4. """
  5. import pytest
  6. from fastapi.testclient import TestClient
  7. from app.main import app
  8. client = TestClient(app)
  9. @pytest.mark.integration
  10. class TestVisitEndpointIntegration:
  11. """Tests que ejecutan Camoufox realmente."""
  12. def test_visit_example_com(self):
  13. """Test básico con example.com."""
  14. response = client.post(
  15. "/api/v1/visit",
  16. json={"url": "https://example.com", "screenshot": False},
  17. )
  18. assert response.status_code == 200
  19. body = response.json()
  20. assert body["status"] == "OK"
  21. assert "html" in body["data"]
  22. @pytest.mark.skip(reason="Requiere Camoufox instalado y funcionando")
  23. def test_visit_with_screenshot(self):
  24. """Test con screenshot."""
  25. response = client.post(
  26. "/api/v1/visit",
  27. json={"url": "https://example.com", "screenshot": True},
  28. )
  29. assert response.status_code == 200
  30. body = response.json()
  31. assert body["status"] == "OK"
  32. assert body["data"]["screenshot"] is not None
  33. @pytest.mark.skip(reason="Requiere Camoufox instalado y funcionando")
  34. def test_visit_mercadolibre_url(self):
  35. """Test con URL de Mercado Libre (aplica hacks específicos)."""
  36. response = client.post(
  37. "/api/v1/visit",
  38. json={
  39. "url": "https://autos.mercadolibre.cl/auto",
  40. "screenshot": False,
  41. },
  42. )
  43. assert response.status_code == 200
  44. @pytest.mark.skip(reason="Requiere Camoufox instalado y funcionando")
  45. def test_visit_with_proxy(self):
  46. """Test con proxy."""
  47. response = client.post(
  48. "/api/v1/visit",
  49. json={
  50. "url": "https://example.com",
  51. "proxy": "http://proxy:8080",
  52. },
  53. )
  54. assert response.status_code == 200
  55. @pytest.mark.skip(reason="Requiere Camoufox instalado y funcionando")
  56. def test_visit_with_incognito(self):
  57. """Test con modo incógnito."""
  58. response = client.post(
  59. "/api/v1/visit",
  60. json={
  61. "url": "https://example.com",
  62. "incognito": True,
  63. },
  64. )
  65. assert response.status_code == 200