Skip to content

Commit

Permalink
test added
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroSvirsa committed Sep 19, 2022
1 parent 06d531d commit a07cd98
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
25 changes: 18 additions & 7 deletions checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Code Style

1. If you have some long math, you can split it onto additional variables.
1. If you have some long math, you can split it onto additional variables,
or break after binary operations (not before - it cause the W504 errors)

Good example:

Expand All @@ -13,6 +14,18 @@ estimated_time = distance_to_the_destinatoin / estimated_speed
how_much_fuel_needed = fuel_consumption * estimated_time * overlap_coeficient
```

Good example:

```python
how_much_fuel_needed = (max_fuel_consumption
* height_fuel_consumption_coeficient
* distance_to_the_destinatoin
/ (plan_max_speed
- wind_awerage_speed
* wind_angle_coefisient)
* overlap_coeficient)
```

Bad example:

```python
Expand All @@ -25,20 +38,18 @@ how_much_fuel_needed = max_fuel_consumption \
) * overlap_coeficient
```

## Code Efficiency

2. Use descriptive and correct variable names.

Good example:

```python
def get_full_name(first_name: str, last_name: str):
def get_full_name(first_name: str, last_name: str) -> str:
return f"{first_name} {last_name}"
```

Bad example:
```python
def get_full_name(x: str, y: str):
def get_full_name(x: str, y: str) -> str:
return f"{x} {y}"
```

Expand All @@ -49,7 +60,7 @@ def get_full_name(x: str, y: str):
Good example:

```python
def is_adult(age):
def is_adult(age: int) -> str:
if age >= 18:
return "adult"
return "not an adult"
Expand All @@ -58,7 +69,7 @@ def is_adult(age):
Bad example:

```python
def is_adult(age):
def is_adult(age: int) -> str:
if age >= 18:
return "adult"
else:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest.mock import patch

import pytest

from app.main import Car, CarWashStation
Expand Down Expand Up @@ -37,6 +39,12 @@ def test_car_wash_station(cars, wash_station, total_cost):
income = wash_station.serve_cars(cars)
assert income == total_cost, f"Income should equal to {total_cost}"

def test_wash_single_car_is_called():
with patch.object(CarWashStation, 'wash_single_car') as mock_method:
CarWashStation(3, 9, 4, 11).serve_cars([Car(2, 1, "Ford")])
assert mock_method.called, "Expected 'wash_single_car' to have " \
"been called inside 'serve_cars' method"


@pytest.mark.parametrize(
"cars,wash_station,cars_clean_marks",
Expand Down

0 comments on commit a07cd98

Please sign in to comment.