-
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
17ab80b
commit a7a0355
Showing
5 changed files
with
132 additions
and
15 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
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,50 @@ | ||
# Define the image name | ||
IMAGE_NAME = CheerUpApp | ||
DOCKER_USERNAME = jahnavimaddhuri | ||
|
||
# Build the Docker image | ||
build: | ||
docker build -t $(IMAGE_NAME) . | ||
|
||
# Run Docker container | ||
run: | ||
docker run -p 5000:5000 $(IMAGE_NAME) | ||
|
||
# Remove Docker image | ||
clean: | ||
docker rmi $(IMAGE_NAME) | ||
|
||
image_show: | ||
docker images | ||
|
||
container_show: | ||
docker ps | ||
|
||
push: | ||
docker login | ||
docker tag $(IMAGE_NAME) $(DOCKER_USERNAME)/$(IMAGE_NAME) | ||
docker push $(DOCKER_USERNAME)/$(IMAGE_NAME):latest | ||
|
||
login: | ||
docker login -u ${DOCKER_USERNAME} | ||
|
||
install: | ||
pip install --upgrade pip &&\ | ||
pip install -r requirements.txt | ||
|
||
test: | ||
python -m pytest -vv --cov=app --cov=mylib test_*.py | ||
|
||
format: | ||
black *.py | ||
|
||
lint: | ||
#disable comment to test speed | ||
#pylint --disable=R,C --ignore-patterns=test_.*?py *.py mylib/*.py | ||
#ruff linting is 10-100X faster than pylint | ||
ruff check *.py mylib/*.py | ||
|
||
container-lint: | ||
docker run --rm -i hadolint/hadolint < Dockerfile | ||
|
||
refactor: format lint |
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
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 |
---|---|---|
|
@@ -5,4 +5,5 @@ pylint | |
ruff | ||
Flask==2.0.1 | ||
Werkzeug==2.0.1 | ||
python-dotenv | ||
python-dotenv | ||
random |
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 @@ | ||
import pytest | ||
from app import app | ||
|
||
@pytest.fixture | ||
def client(): | ||
app.config['TESTING'] = True | ||
with app.test_client() as client: | ||
yield client | ||
|
||
def test_get_request(client): | ||
"""Test the GET request to the root endpoint.""" | ||
response = client.get('/') | ||
assert response.status_code == 200 | ||
assert b"Having a bum day? Let's make it better! Hit this button:" in response.data | ||
|
||
def test_post_request(client): | ||
"""Test the POST request to the root endpoint.""" | ||
response = client.post('/') | ||
assert response.status_code == 200 | ||
assert any(phrase.encode() in response.data for phrase in [ | ||
"Data never sleeps, but neither do breakthroughs—you're crushing it!", | ||
"You’re like a neural net—always learning and adapting!", | ||
"Remember, even NaN values are part of the dataset!", | ||
"Life’s a gradient descent—keep moving toward your optimum!", | ||
"Your hard work is the feature everyone notices!", | ||
"Keep calm and let the algorithm do the heavy lifting!", | ||
"Debugging life one line of code at a time—keep it up!", | ||
"Your data game is *outlier-level* impressive!", | ||
"You're a clustering champ—always finding your center!", | ||
"Master’s degree: Loading... 90% complete. You’ve got this!", | ||
"You’re the key to cracking the ultimate dataset: life!", | ||
"Machine learning? More like *mastered* learning!", | ||
"A few more semesters, and you’re the top variable in the model!", | ||
"Data wrangling = life wrangling. You’re doing both like a pro!", | ||
"Remember, correlation doesn’t imply exhaustion—rest up and conquer!" | ||
]) | ||
|
||
if __name__ == '__main__': | ||
pytest.main() |