diff --git a/.github/workflows/Discord.yml b/.github/workflows/Discord.yml
new file mode 100644
index 0000000..ade583e
--- /dev/null
+++ b/.github/workflows/Discord.yml
@@ -0,0 +1,18 @@
+name: Discord Alerts
+
+on:
+ push:
+ branches: [ "main" ]
+ pull_request:
+ branches: [ "main" ]
+
+jobs:
+ discord:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Enviar alerta para o Discord
+ uses: tsickert/discord-webhook@v7.0.0
+ with:
+ webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
+ content: " Novo commit ou PR criado no repositório!"
diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml
new file mode 100644
index 0000000..8092e30
--- /dev/null
+++ b/.github/workflows/python-app.yml
@@ -0,0 +1,38 @@
+# This workflow will install Python dependencies, run tests and lint with a single version of Python
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
+
+name: Python application
+
+ push:
+ branches: [ "main" ]
+ pull_request:
+ branches: [ "main" ]
+
+permissions:
+ contents: read
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up Python 3.10
+ uses: actions/setup-python@v3
+ with:
+ python-version: "3.10"
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install flake8 pytest
+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
+ - name: Lint with flake8
+ run: |
+ # stop the build if there are Python syntax errors or undefined names
+ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
+ # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
+ flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
+ - name: Test with pytest
+ run: |
+ pytest
diff --git a/.idea/.gitignore b/.idea/.gitignore
index a0ccf77..26d3352 100644
--- a/.idea/.gitignore
+++ b/.idea/.gitignore
@@ -1,5 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml
-# Environment-dependent path to Maven home directory
-/mavenHomeManager.xml
diff --git a/.idea/devops-puc.iml b/.idea/devops-puc.iml
index 10ba783..d6ebd48 100644
--- a/.idea/devops-puc.iml
+++ b/.idea/devops-puc.iml
@@ -3,7 +3,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 8be8c38..601ff9d 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 90f45fc..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..c94b5e4
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,12 @@
+FROM python:3
+
+WORKDIR /usr/src/app
+
+COPY requirements.txt ./
+RUN pip install --no-cache-dir -r requirements.txt
+
+COPY . .
+
+EXPOSE 80
+
+CMD [ "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80" ]
diff --git a/main.py b/main.py
index f279f78..a577f6f 100644
--- a/main.py
+++ b/main.py
@@ -1,7 +1,9 @@
-from fastapi import FastAPI
+def test_passando():
+ assert True
-app = FastAPI()
+def test_read_root():
+ response = read_root()
+ assert response == {"hello": "world"}
-@app.get("/")
def read_root():
return {"hello": "world"}
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..57a493a
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,3 @@
+fastapi==0.111.1
+uvicorn[standard]
+
diff --git a/test_01.py b/test_01.py
new file mode 100644
index 0000000..dad7929
--- /dev/null
+++ b/test_01.py
@@ -0,0 +1,10 @@
+# test_main.py
+
+from main import read_root
+
+def test_passando():
+ assert True
+
+def test_read_root():
+ response = read_root()
+ assert response == {"hello": "world"}
\ No newline at end of file
diff --git a/test_main.py b/test_main.py
new file mode 100644
index 0000000..dad7929
--- /dev/null
+++ b/test_main.py
@@ -0,0 +1,10 @@
+# test_main.py
+
+from main import read_root
+
+def test_passando():
+ assert True
+
+def test_read_root():
+ response = read_root()
+ assert response == {"hello": "world"}
\ No newline at end of file
diff --git a/teste_cicd.py b/teste_cicd.py
deleted file mode 100644
index 9d69c28..0000000
--- a/teste_cicd.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from main import read_root
-
-def test_passando():
- assert True
-
-def test_read_root ():
- responses = read_root()
- assert responses == {"hello": "world"}
\ No newline at end of file
diff --git a/teste_cicd01.py b/teste_cicd01.py
deleted file mode 100644
index 9d69c28..0000000
--- a/teste_cicd01.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from main import read_root
-
-def test_passando():
- assert True
-
-def test_read_root ():
- responses = read_root()
- assert responses == {"hello": "world"}
\ No newline at end of file
diff --git a/tests/test_01.py b/tests/test_01.py
new file mode 100644
index 0000000..689a058
--- /dev/null
+++ b/tests/test_01.py
@@ -0,0 +1,46 @@
+"""Testes automatizados para o módulo main."""
+
+from main import read_root
+
+
+def test_passando():
+ """Teste que sempre passa."""
+ assert True
+
+def test_read_root():
+ """Teste da função read_root()."""
+ response = read_root()
+ assert response == {"hello": "world"}
+
+# tests/test_app.py
+
+from fastapi.testclient import TestClient
+from main import app
+
+client = TestClient(app)
+
+def test_root_message():
+ response = client.get("/")
+ assert response.status_code == 200
+ assert response.json() == {"mensagem": "API funcionando no Docker!"}
+
+def test_soma_positiva():
+ response = client.get("/soma/2/3")
+ assert response.status_code == 200
+ assert "resultado" in response.json()
+ assert response.json() == {"resultado": 5}
+
+def test_soma_zero():
+ response = client.get("/soma/0/5")
+ assert response.status_code == 200
+ assert response.json()["resultado"] == 5
+
+def test_soma_negativa():
+ response = client.get("/soma/-2/-3")
+ assert response.status_code == 200
+ assert response.json()["resultado"] == -5
+
+def test_soma_valores_mistos():
+ response = client.get("/soma/-2/3")
+ assert response.status_code == 200
+ assert response.json()["resultado"] == 1