Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3c84ec0
feat: добавлен CI workflow
whyshetsss Oct 17, 2025
22a83d3
test: проверка CI на ветке development
whyshetsss Oct 17, 2025
c1062bf
unit test for calculator
whyshetsss Oct 18, 2025
4df28c4
Refactor calculator to include add function
whyshetsss Oct 18, 2025
f5fe865
Refactor CI/CD pipeline for multiple branches and docs
whyshetsss Oct 18, 2025
e414415
Fix indentation in test_addition function
whyshetsss Oct 18, 2025
aeb23ca
Refactor calculator app to use main guard
whyshetsss Oct 18, 2025
9462249
Update main.yml
whyshetsss Oct 18, 2025
9b29244
Update upload-artifact action to version 4
whyshetsss Oct 18, 2025
e5186de
Enhance calculator.py with module description
whyshetsss Oct 18, 2025
ffb030a
Update documentation generation command in workflow
whyshetsss Oct 18, 2025
8317739
Add test for multiply function in test_calculator.py
whyshetsss Oct 25, 2025
3635d62
Refactor calculator.py to include multiply function
whyshetsss Oct 25, 2025
e7b004a
Expand test coverage for calculator functions
whyshetsss Oct 25, 2025
85a925b
Revise calculator module for TDD RED phase
whyshetsss Oct 25, 2025
4ea454b
Refactor calculator for TDD GREEN phase
whyshetsss Oct 25, 2025
98f2898
Refactor calculator functions for clarity and fixes
whyshetsss Oct 25, 2025
926952f
Fix add function to correctly perform addition
whyshetsss Oct 25, 2025
113c5d1
Simplify test_calculator.py to only test addition
whyshetsss Oct 25, 2025
a719ceb
Refactor calculator functions for TDD compliance
whyshetsss Oct 25, 2025
3d7d4dd
Implement add function to return a fixed value
whyshetsss Oct 25, 2025
03d58a1
Add test for adding negative and positive numbers
whyshetsss Oct 25, 2025
2b633cc
Refactor add function to return the sum of two numbers
whyshetsss Oct 25, 2025
b4e6404
Update test_calculator.py
whyshetsss Oct 25, 2025
93d07dc
Add subtract function placeholder to calculator.py
whyshetsss Oct 25, 2025
b2796d3
Implement subtract function in calculator module
whyshetsss Oct 25, 2025
3668550
Import subtract function in test_calculator.py
whyshetsss Oct 25, 2025
0d75575
Add test for subtracting negative numbers
whyshetsss Oct 25, 2025
1976072
Fix subtract function to perform correct operation
whyshetsss Oct 25, 2025
707c583
Add multiply test case to test_calculator.py
whyshetsss Oct 25, 2025
c52780f
Add multiply function placeholder
whyshetsss Oct 25, 2025
98f92e2
Add multiply function to test_calculator.py
whyshetsss Oct 25, 2025
01d9331
Implement multiply function in calculator module
whyshetsss Oct 25, 2025
1070b47
Add test for multiplying negative numbers
whyshetsss Oct 25, 2025
00292de
Fix multiply function to return correct product
whyshetsss Oct 25, 2025
04d5fd3
Add test for divide function in test_calculator.py
whyshetsss Oct 25, 2025
4694107
Add divide function placeholder to calculator module
whyshetsss Oct 25, 2025
4f42723
Add divide function implementation
whyshetsss Oct 25, 2025
4c0e07e
Add divide by zero test case
whyshetsss Oct 25, 2025
68c39cc
Enhance divide function with zero division check
whyshetsss Oct 25, 2025
ec43791
Refactor calculator.py for improved readability
whyshetsss Oct 25, 2025
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
60 changes: 60 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CI/CD Pipeline

on:
push:
branches:
- main
- development
- release
pull_request:
branches:
- main

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: 🧩 Checkout repository
uses: actions/checkout@v3

- name: 🐍 Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: 📦 Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest

- name: 🧪 Run unit tests
run: |
pytest -v || exit 1

generate-docs:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: 📂 Checkout repository
uses: actions/checkout@v3

- name: 🐍 Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: 🧰 Install tools
run: |
python -m pip install --upgrade pip
pip install pdoc3

- name: 📝 Generate documentation
run: |
mkdir -p docs
pdoc calculator.py --output-dir docs || echo "Docs generated"

- name: 📤 Upload docs as artifact
uses: actions/upload-artifact@v4
with:
name: project-docs
path: docs/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ YouTube: [YouTube](http://www.youtube.com/allaboutpython?sub_confirmation=1)\
Instagram: [Instagram](https://www.instagram.com/itsallaboutpython)\
Blog Site: [Site](https://itsallaboutpython.blogspot.com/)\
GitHub: [GitHub](https://github.com/visheshdvivedi/)
# Тест CI на ветке development
48 changes: 25 additions & 23 deletions calculator.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
print("===== Welcome to Calculator App =====\n")
while 1:
print("What would you like to do:-")
print("1. Addition")
print("2. Subtraction")
print("3 Multiplication")
print("4. Division")
print("5. Exit")
choice = int(input("Enter your choice: "))
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
if choice == 1:
print("Output: ", num1+num2)
elif choice == 2:
print("Output: ", num1-num2)
elif choice == 3:
print("Output: ", num1*num2)
elif choice == 4:
print("Output: ", num1/num2)
elif choice == 5:
print("Exiting...")
break
print()
"""
Calculator module for TDD demo (GREEN phase).
Фаза GREEN — все функции реализованы корректно и проходят тесты.
Цель: все тесты должны завершаться успешно.
"""

import math

def add(a, b): return a + b
def subtract(a, b): return a - b
def multiply(a, b): return a * b
def divide(a, b):
if b == 0:
raise ZeroDivisionError("Division by zero")
return a / b










29 changes: 29 additions & 0 deletions tests/test_calculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

import pytest
from calculator import add, subtract, multiply, divide

def test_add():
assert add(2, 3) == 5


def test_add_negative():
assert add(-1, 1) == 0

def test_subtract():
assert subtract(10, 4) == 6

def test_subtract_negative():
assert subtract(0, 5) == -5

def test_multiply():
assert multiply(3, 3) == 9

def test_multiply_negative():
assert multiply(-2, 4) == -8

def test_divide_by_zero():
with pytest.raises(ZeroDivisionError):
divide(5, 0)