File tree Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ import unittest
4
+ from creational .builder import Director , BuilderHouse , BuilderFlat
5
+
6
+
7
+ class TestHouseBuilding (unittest .TestCase ):
8
+
9
+ def setUp (self ):
10
+ self .director = Director ()
11
+ self .director .builder = BuilderHouse ()
12
+ self .director .construct_building ()
13
+ self .building = self .director .get_building ()
14
+
15
+ def test_house_size (self ):
16
+ self .assertEqual (self .building .size , 'Big' )
17
+
18
+ def test_num_floor_in_house (self ):
19
+ self .assertEqual (self .building .floor , 'One' )
20
+
21
+
22
+ class TestFlatBuilding (unittest .TestCase ):
23
+
24
+ def setUp (self ):
25
+ self .director = Director ()
26
+ self .director .builder = BuilderFlat ()
27
+ self .director .construct_building ()
28
+ self .building = self .director .get_building ()
29
+
30
+ def test_house_size (self ):
31
+ self .assertEqual (self .building .size , 'Small' )
32
+
33
+ def test_num_floor_in_house (self ):
34
+ self .assertEqual (self .building .floor , 'More than One' )
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ import unittest
4
+ from creational .factory_method import get_localizer
5
+
6
+
7
+ class TestLocalizer (unittest .TestCase ):
8
+
9
+ def setUp (self ):
10
+ self .e , self .g = get_localizer (language = "English" ), \
11
+ get_localizer (language = "Greek" )
12
+
13
+ def test_parrot_eng_localization (self ):
14
+ self .assertEqual (self .e .get ('parrot' ), 'parrot' )
15
+
16
+ def test_parrot_greek_localization (self ):
17
+ self .assertEqual (self .g .get ('parrot' ), 'parrot' )
18
+
19
+ def test_dog_eng_localization (self ):
20
+ self .assertEqual (self .e .get ('dog' ), 'dog' )
21
+
22
+ def test_dog_greek_localization (self ):
23
+ self .assertEqual (self .g .get ('dog' ), 'σκύλος' )
24
+
25
+ def test_cat_eng_localization (self ):
26
+ self .assertEqual (self .e .get ('cat' ), 'cat' )
27
+
28
+ def test_cat_greek_localization (self ):
29
+ self .assertEqual (self .g .get ('cat' ), 'γάτα' )
30
+
31
+ def test_bear_eng_localization (self ):
32
+ self .assertEqual (self .e .get ('bear' ), 'bear' )
33
+
34
+ def test_bear_greek_localization (self ):
35
+ self .assertEqual (self .g .get ('bear' ), 'bear' )
You can’t perform that action at this time.
0 commit comments