integration_test.py 778 B

1234567891011121314151617181920212223242526272829303132
  1. import os
  2. import pytest
  3. import requests
  4. from html2text import html2text
  5. @pytest.fixture
  6. def config():
  7. """Return the current config as a dict."""
  8. import yaml
  9. with open(
  10. os.path.join(os.path.dirname(__file__), "..", "config/me.yml"), "rb"
  11. ) as f:
  12. yield yaml.load(f)
  13. def resp2plaintext(resp):
  14. """Convert the body of a requests reponse to plain text in order to make basic assertions."""
  15. return html2text(resp.text)
  16. def test_ping_homepage(config):
  17. """Ensure the homepage is accessible."""
  18. resp = requests.get("http://localhost:5005")
  19. resp.raise_for_status()
  20. assert resp.status_code == 200
  21. body = resp2plaintext(resp)
  22. assert config["name"] in body
  23. assert f"@{config['username']}@{config['domain']}" in body