-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pytest.py
104 lines (86 loc) · 2.96 KB
/
test_pytest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import dotenv
import pytest
import manage_log
from Car import Car
dotenv.load_dotenv()
m = manage_log.Manage_log()
@pytest.fixture
def car():
"""Author: Maor Maharizi,
Created: 22.01.2023,
Detail: init car class
Return: Null"""
return Car()
def test_init_fuel(car):
"""Author: Maor Maharizi,
Created: 22.01.2023,
Detail: test init fuel variable
Return: Null"""
try:
assert car.fuel == 50
m.write_exceptions_to_log("TEST INIT FUEL --- PASS ! ")
except Exception as e:
m.write_exceptions_to_log("TEST INIT FUEL --- FAILED ! " + str(e))
def test_init_fuel_consumption(car):
"""Author: Maor Maharizi,
Created: 22.01.2023,
Detail: test init fuel consumption variable
Return: Null"""
try:
assert car.consumption_fuel == "1/10"
m.write_exceptions_to_log("TEST INIT FUEL CONSUMPTION--- PASS ! ")
except Exception as e:
m.write_exceptions_to_log("TEST INIT FUEL CONSUMPTION--- FAILED ! " + str(e))
@pytest.mark.skip
def test_fuel_charge(car):
"""Author: Maor Maharizi,
Created: 22.01.2023,
Detail: test fuel charge function
Return: Null"""
try:
assert car.fuel_charge() == 1
m.write_exceptions_to_log("TEST FUEL CHARGE --- PASS ! ")
except Exception as e:
m.write_exceptions_to_log("TEST FUEL CHARGE --- FAILED ! " + str(e))
def test_init_money(car):
"""Author: Maor Maharizi,
Created: 22.01.2023,
Detail: test init money variable
Return: Null"""
try:
assert car.money == 500
m.write_exceptions_to_log("TEST INIT MONEY--- PASS ! ")
except Exception as e:
m.write_exceptions_to_log("TEST INIT MONEY--- FAILED ! " + str(e))
def test_open_file(car):
"""Author: Maor Maharizi,
Created: 22.01.2023,
Detail: test open file
Return: Null"""
try:
assert m.open_file() == 1
m.write_exceptions_to_log("TEST OPEN FILE --- PASS ! ")
except Exception as e:
m.write_exceptions_to_log("TEST OPEN FILE --- FAILED ! " + str(e))
def test_drive(car):
"""Author: Maor Maharizi,
Created: 22.01.2023,
Detail: test drive function
Return: Null"""
try:
assert car.start() == 1
m.write_exceptions_to_log("TEST DRIVE --- PASS ! ")
except Exception as e:
m.write_exceptions_to_log("TEST DRIVE --- FAILED ! " + str(e))
def test_gear_update(car):
"""Author: Maor Maharizi,
Created: 22.01.2023,
Detail: test gear update function
Return: Null"""
try:
assert car.gear_update(130) == 1
m.write_exceptions_to_log("TEST GEAR UPDATE --- PASS ! ")
except Exception as e:
m.write_exceptions_to_log("TEST GEAR UPDATE --- FAILED ! " + str(e))
with pytest.raises(OverflowError):
car.gear_update(140)