Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Chrome dependencies
run: |
sudo apt-get install -y wget libnss3 libnspr4 libfontconfig1 libexpat1

- name: Set up Python
uses: actions/setup-python@v5
with:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
selenium
requests
pytest
pytest-cov
beautifulsoup4
28 changes: 6 additions & 22 deletions tests/test_render_service.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
# Tests if the render service is working properly.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
import requests
from bs4 import BeautifulSoup as bs

TITLE_GOAL = "What-Flix"
TITLE_LOADING = "Render - Application loading"
RENDER_URL = "https://what-flix.onrender.com/"

def test_render_service():
# This allows the selenium driver to work on Ubuntu
chrome_options = Options()
chrome_options.add_argument("--headless=new")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")

driver = webdriver.Chrome(options=chrome_options)
driver.get("https://what-flix.onrender.com/")

if driver.title == TITLE_GOAL:
assert True
elif driver.title == TITLE_LOADING:
print("\nRender application was asleep due to inactivity. Waiting 60 seconds then trying again.")
time.sleep(60)
driver.get("https://what-flix.onrender.com/")
assert driver.title == TITLE_GOAL, f"Webpage title \"{driver.title}\" does not match TITLE_GOAL of \"{TITLE_GOAL}\"."
else:
assert False, f"Webpage title \"{driver.title}\" does not match TITLE_GOAL of \"{TITLE_GOAL}\" or TITLE_LOADING of \"{TITLE_LOADING}\"."
soup = bs(requests.get(RENDER_URL).text, 'html.parser')

assert f"<title>{TITLE_GOAL}</title>" == str(soup.find_all('title')[0])