Skip to content

Commit fedab56

Browse files
author
Julio Sarango
committed
finalización de pruebas e instalación de coverage
1 parent 3c50e94 commit fedab56

13 files changed

Lines changed: 101 additions & 13 deletions

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[report]
2+
fail_under = 90

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,32 @@ python -m unittest tests.test_bank_account.BankAccoutTest.test_deposit_multiple_
5858

5959
# Doctest
6060

61-
Doctest es una librería que está incluida en Python y que permite crear pruebas en los comentarios del código.
61+
Doctest es una librería que está incluida en Python y que permite crear pruebas en los comentarios del código.
62+
63+
# Faker
64+
```
65+
pip install Faker
66+
pip freeze | grep Kaker
67+
```
68+
69+
# Coverage
70+
```
71+
72+
coverage run --source src -m unittest
73+
coverage report
74+
```
75+
![Coverage report](images/report.png)
76+
77+
Si queremos ver un reporte más detallado y dinámico sacamos el reporte en formato html.
78+
```
79+
coverage html
80+
```
81+
![Coverage html](images/report_html.png)
82+
Podemos hacer clic en cada uno de los nombres donde se mostrará la cobertura de las pruebas.
83+
A modo de pruebas, al hacer clic en el archivo que está con 98% de convertura, se mostrará la parte no cubierta
84+
![Report Detail](images/report_detail.png)
85+
86+
Si corregimos la parte que no tiene cobertura y ejecutamos nuevamente el comando ```coverage html``` cambiará el resultado.
87+
![Coverage html full](images/report_html_full.png)
88+
89+
![Report Detail](images/report_detail_full.png)

images/report.png

29.1 KB
Loading

images/report_detail.png

73.8 KB
Loading

images/report_detail_full.png

66.7 KB
Loading

images/report_html.png

47.2 KB
Loading

images/report_html_full.png

46.7 KB
Loading

requirements.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
exceptiongroup==1.2.2
2-
iniconfig==2.0.0
3-
packaging==24.1
4-
pluggy==1.5.0
5-
pytest==8.3.3
6-
tomli==2.0.2
1+
requests==2.32.3
2+
Faker==33.0.0
3+
coverage==7.6.5

src/api_client.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,3 @@ def get_location(ip):
1616
"city": data["cityName"],
1717
"code": data["countryCode"],
1818
}
19-
20-
21-
if __name__ == "__main__":
22-
get_location("8.8.0")

src/bank_account.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ def _log_transaction_fail(self, message):
2525
self.grabar_log(self.log_file_withdraw, message)
2626

2727
def deposit(self, amount):
28+
"""Deposit method
29+
30+
Args:
31+
amount (number): Amount that we will deposit
32+
33+
Returns:
34+
number: New balance after deposit
35+
>>> account = BankAccount(100)
36+
>>> account.deposit(50)
37+
150
38+
"""
2839
if amount > 0:
2940
self.balance += amount
3041
self._log_transaction(f"Deposited {amount}- New balance: {self.balance}")

0 commit comments

Comments
 (0)