-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72bef2b
commit 02fe01a
Showing
6 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM python:alpine | ||
|
||
WORKDIR /app | ||
|
||
COPY main_score.py . | ||
COPY utils.py . | ||
RUN echo 800 > Scores.txt | ||
|
||
RUN pip install Flask | ||
|
||
CMD ["python", "main_score.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
properties([pipelineTriggers([pollSCM('H * * * *')])]) | ||
|
||
pipeline { | ||
stages { | ||
stage('Checkout') { | ||
steps { | ||
checkout scm | ||
} | ||
} | ||
stage('Build') { | ||
docker build | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
services: | ||
web: | ||
image: python:alpine | ||
ports: | ||
- 8777:5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"""End to end tests for main_score.py""" | ||
|
||
import sys | ||
import selenium | ||
import selenium.webdriver | ||
from selenium.webdriver.common.by import By | ||
|
||
import input_validation | ||
|
||
|
||
def test_scores_service(url: str) -> bool: | ||
"""Tests if score shows up in website and is between 1 and 1000""" | ||
with selenium.webdriver.Firefox() as driver: | ||
driver.get(url) | ||
|
||
# raise error if website returns an error | ||
title = driver.find_element(By.XPATH, "/html/body/h1").text | ||
if title == "ERROR:": | ||
raise ValueError | ||
|
||
# get and parse scoreERROR: | ||
score = driver.find_element(By.ID, "score").text | ||
|
||
parsed_score = input_validation.validate_int(score) | ||
if parsed_score is not None: | ||
if 1 <= parsed_score <= 1000: | ||
return True | ||
else: | ||
return False | ||
else: | ||
raise ValueError | ||
|
||
|
||
def main_function() -> None: | ||
"""Calls test_score_service exists with a return code ased on the result of the function""" | ||
if test_scores_service("http://127.0.0.1:8777"): | ||
sys.exit(0) | ||
else: | ||
sys.exit(-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,4 @@ def main_page() -> str: | |
</body> | ||
</html>''' | ||
|
||
score_website.run() | ||
score_website.run('0.0.0.0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
currencyapicom==0.1.1 | ||
keyboard==0.13.5 | ||
Flask==3.0.3 | ||
webdriver-manager==4.0.1 | ||
selenium==4.23.0 |