-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_optical_sphere.py
More file actions
36 lines (26 loc) · 1.17 KB
/
Copy pathtest_optical_sphere.py
File metadata and controls
36 lines (26 loc) · 1.17 KB
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
"""
Run the tests by executing, for all test classes:
$ python -m unittest -v test_optical_sphere.py
or
$ python test_optical_sphere.py
"""
import unittest
from epsilon import equal_in_practice
from optical_sphere import OpticalSphere
from typing import Final
class Test_OpticalSphere(unittest.TestCase):
def test_Given2OpticalSpheresCreatedEqually_WhenComparison_ThenReturnTrue(self):
radius: Final = 1.
self.assertEqual(OpticalSphere(radius), OpticalSphere(radius))
optical_sphere: Final = OpticalSphere(radius)
self.assertEqual(optical_sphere, OpticalSphere(radius))
def test_GivenOpticalSphereWithRadius530_When_get_base_curve_ThenReturn1(self):
radius: Final = 530 # 530 mm is the radius of a 1 diopter curve
optical_sphere: Final = OpticalSphere(radius)
self.assertTrue(equal_in_practice(optical_sphere.get_base_curve(), 1))
def test_GivenOpticalSphereWithRadius106_When_get_radius_ThenReturn5(self):
radius: Final = 106
optical_sphere: Final = OpticalSphere(radius)
self.assertTrue(equal_in_practice(optical_sphere.get_base_curve(), 5))
if __name__ == '__main__':
unittest.main()