1#keys for bushes
2bushes_keys = ('храст', 'shrub', 'bush',)
3
4#check if argument is a valid bush
5def is_bush(arg):
6 if type(arg) != dict or 'name' not in arg:
7 return False
8
9 if arg['name'].lower() not in bushes_keys:
10 return False
11
12 return True
13
14#check if the multitude of bushes is valid
15def is_pretty_bush(price, unique_letters):
16 if int(price) == 0:
17 return False
18
19 return len(unique_letters) % int(price) == 0 and price <= 42.00
20
21def function_that_says_ni(*args, **kwargs):
22
23 price = 0.00
24
25 #iterate positioned args
26 for positioned in args:
27 if is_bush(positioned):
28 if 'cost' in positioned:
29 price += positioned['cost']
30
31 #iterate named args
32 for named in kwargs.values():
33 if is_bush(named):
34 if 'cost' in named:
35 price += named['cost']
36
37 #get unique characters found in the bushes in the multitude
38 unique_letters = set(''.join([key for key, value in kwargs.items() if is_bush(value)]))
39
40 if is_pretty_bush(price, unique_letters):
41 return f'{price:.2f}лв'
42 return 'Ni!'
43
44# import unittest
45# from function_that_says_ni import function_that_says_ni
46
47# class TestFunctionThatSaysNi(unittest.TestCase):
48
49# def test_valid_bushes_with_cost(self):
50# self.assertEqual(function_that_says_ni({"name": "храст", "cost": 1.50}, {"name": "sHRub", "cost": 3.00}), "4.50лв")
51# self.assertEqual(function_that_says_ni({"name": "хРАст", "cost": 150}, {"name": "shrub", "cost": 3.00}), "Ni!")
52
53# def test_invalid_bushes(self):
54# self.assertEqual(function_that_says_ni({"ddd": "храст", "cost": 1.50}, {"namae": "sHRub", "cost": 3.00}), "Ni!")
55# self.assertEqual(function_that_says_ni({"namdde": "хРАст", "cost": 150}, {"namse": "shrub", "cost": 3.00}), "Ni!")
56
57# def test_invalid_bushes_with_cost(self):
58# self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храст", "cost": 244.00}), "Ni!")
59# self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храстченце", "cost": 2.00}), "Ni!")
60# self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храст", "cost": 41.99}), "41.99лв")
61
62# def test_valid_bushes_without_cost(self):
63# self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "buSh"}), "Ni!")
64# self.assertEqual(function_that_says_ni(a={"name": "храст"}, b={"name": "shrub"}), "Ni!")
65
66# def test_invalid_bushes_without_cost(self):
67# self.assertEqual(function_that_says_ni({"name": "храст44"}, {"name": "bus44h"}), "Ni!")
68# self.assertEqual(function_that_says_ni(a={"name": "храс124т"}, b={"name": "s52hrub"}), "Ni!")
69
70# def test_valid_bushes_with_and_without_cost(self):
71# self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "bush", "cost": 33.33}), "33.33лв")
72# self.assertEqual(function_that_says_ni(a={"name": "храст", "cost": 17}, b={"name": "shrub"}), "Ni!")
73
74# def test_not_pretty_bushes_due_to_price(self):
75# self.assertEqual(function_that_says_ni({"name": "храсТ", "cost": 50.0}), "Ni!")
76# self.assertEqual(function_that_says_ni({"name": "shrub", "cost": 43.00}), "Ni!")
77
78# def test_not_pretty_bushes_due_to_unique_letters(self):
79# self.assertEqual(function_that_says_ni(ad={"name": "храст", "cost": 1.80}, b={"name": "храст", "cost": 1}), "Ni!")
80# self.assertEqual(function_that_says_ni(a={"name": "буш"}, b={"name": "шрасх"}), "Ni!")
81
82# def test_mixed_types(self):
83# self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 0.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "1.80лв")
84# self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 30.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "Ni!")
85# self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 40.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "Ni!")
86# self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 40.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}, da=(1,2)), "Ni!")
87# self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "храст", "cost": 0.0}, ["ffffffffff", {1, 2, 3}]), "Ni!")
88
89# def test_all_in_one_first_variation(self):
90# self.assertEqual(function_that_says_ni(4, 4, {"name": "ХРраст", "cost": 10.0}, [3,4,5], ad={"name": "хРаст", "cost": 1.80}, da = "pypy"), "1.80лв")
91# self.assertEqual(function_that_says_ni(4, 4, {"name": "Храст", "cost": 100.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "Ni!")
92# self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 100.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "Ni!")
93
94# def test_all_in_one_second_variation(self):
95# self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 11.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "11.00лв")
96# self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 11.0}, ad={"name": "bush", "cost": 1.80}, c = "pypy"), "Ni!")
97# self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 12.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "12.00лв")
98
99# if __name__ == '__main__':
100# unittest.main()
..........
----------------------------------------------------------------------
Ran 10 tests in 0.000s
OK
Илиан Запрянов
18.10.2024 13:07не съм сигурен дали са верни иначе прайм🤜🏼🤛🏼
|
Виктор Бечев
18.10.2024 12:27Имах и коментар за точката, ама ме изпревари, та го изтрих. :grin:
|
Виктор Бечев
18.10.2024 12:25Ако:
1. Имаш желание.
2. Kачиш тестовете на някакъв pastebin тип сайт.
3. Ги споделиш с колегите си _(като линк в коментар към домашното)_.
Ще:
1. Получиш бонус точка.
2. Помогнеш на колегите си.
3. Спечелиш street cred.
|
f | 1 | #keys for bushes | f | 1 | #keys for bushes |
2 | bushes_keys = ('храст', 'shrub', 'bush',) | 2 | bushes_keys = ('храст', 'shrub', 'bush',) | ||
3 | 3 | ||||
4 | #check if argument is a valid bush | 4 | #check if argument is a valid bush | ||
5 | def is_bush(arg): | 5 | def is_bush(arg): | ||
6 | if type(arg) != dict or 'name' not in arg: | 6 | if type(arg) != dict or 'name' not in arg: | ||
7 | return False | 7 | return False | ||
8 | 8 | ||||
9 | if arg['name'].lower() not in bushes_keys: | 9 | if arg['name'].lower() not in bushes_keys: | ||
10 | return False | 10 | return False | ||
11 | 11 | ||||
12 | return True | 12 | return True | ||
13 | 13 | ||||
14 | #check if the multitude of bushes is valid | 14 | #check if the multitude of bushes is valid | ||
15 | def is_pretty_bush(price, unique_letters): | 15 | def is_pretty_bush(price, unique_letters): | ||
16 | if int(price) == 0: | 16 | if int(price) == 0: | ||
17 | return False | 17 | return False | ||
18 | 18 | ||||
19 | return len(unique_letters) % int(price) == 0 and price <= 42.00 | 19 | return len(unique_letters) % int(price) == 0 and price <= 42.00 | ||
20 | 20 | ||||
21 | def function_that_says_ni(*args, **kwargs): | 21 | def function_that_says_ni(*args, **kwargs): | ||
22 | 22 | ||||
23 | price = 0.00 | 23 | price = 0.00 | ||
24 | 24 | ||||
25 | #iterate positioned args | 25 | #iterate positioned args | ||
26 | for positioned in args: | 26 | for positioned in args: | ||
27 | if is_bush(positioned): | 27 | if is_bush(positioned): | ||
28 | if 'cost' in positioned: | 28 | if 'cost' in positioned: | ||
29 | price += positioned['cost'] | 29 | price += positioned['cost'] | ||
30 | 30 | ||||
31 | #iterate named args | 31 | #iterate named args | ||
32 | for named in kwargs.values(): | 32 | for named in kwargs.values(): | ||
33 | if is_bush(named): | 33 | if is_bush(named): | ||
34 | if 'cost' in named: | 34 | if 'cost' in named: | ||
35 | price += named['cost'] | 35 | price += named['cost'] | ||
36 | 36 | ||||
37 | #get unique characters found in the bushes in the multitude | 37 | #get unique characters found in the bushes in the multitude | ||
38 | unique_letters = set(''.join([key for key, value in kwargs.items() if is_bush(value)])) | 38 | unique_letters = set(''.join([key for key, value in kwargs.items() if is_bush(value)])) | ||
39 | 39 | ||||
40 | if is_pretty_bush(price, unique_letters): | 40 | if is_pretty_bush(price, unique_letters): | ||
n | 41 | return f'{price:.2f}лв.' | n | 41 | return f'{price:.2f}лв' |
42 | return 'Ni!' | 42 | return 'Ni!' | ||
43 | 43 | ||||
44 | # import unittest | 44 | # import unittest | ||
45 | # from function_that_says_ni import function_that_says_ni | 45 | # from function_that_says_ni import function_that_says_ni | ||
46 | 46 | ||||
47 | # class TestFunctionThatSaysNi(unittest.TestCase): | 47 | # class TestFunctionThatSaysNi(unittest.TestCase): | ||
48 | 48 | ||||
49 | # def test_valid_bushes_with_cost(self): | 49 | # def test_valid_bushes_with_cost(self): | ||
n | 50 | # self.assertEqual(function_that_says_ni({"name": "храст", "cost": 1.50}, {"name": "sHRub", "cost": 3.00}), "4.50лв.") | n | 50 | # self.assertEqual(function_that_says_ni({"name": "храст", "cost": 1.50}, {"name": "sHRub", "cost": 3.00}), "4.50лв") |
51 | # self.assertEqual(function_that_says_ni({"name": "хРАст", "cost": 150}, {"name": "shrub", "cost": 3.00}), "Ni!") | 51 | # self.assertEqual(function_that_says_ni({"name": "хРАст", "cost": 150}, {"name": "shrub", "cost": 3.00}), "Ni!") | ||
52 | 52 | ||||
53 | # def test_invalid_bushes(self): | 53 | # def test_invalid_bushes(self): | ||
54 | # self.assertEqual(function_that_says_ni({"ddd": "храст", "cost": 1.50}, {"namae": "sHRub", "cost": 3.00}), "Ni!") | 54 | # self.assertEqual(function_that_says_ni({"ddd": "храст", "cost": 1.50}, {"namae": "sHRub", "cost": 3.00}), "Ni!") | ||
55 | # self.assertEqual(function_that_says_ni({"namdde": "хРАст", "cost": 150}, {"namse": "shrub", "cost": 3.00}), "Ni!") | 55 | # self.assertEqual(function_that_says_ni({"namdde": "хРАст", "cost": 150}, {"namse": "shrub", "cost": 3.00}), "Ni!") | ||
56 | 56 | ||||
57 | # def test_invalid_bushes_with_cost(self): | 57 | # def test_invalid_bushes_with_cost(self): | ||
58 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храст", "cost": 244.00}), "Ni!") | 58 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храст", "cost": 244.00}), "Ni!") | ||
59 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храстченце", "cost": 2.00}), "Ni!") | 59 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храстченце", "cost": 2.00}), "Ni!") | ||
n | 60 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храст", "cost": 41.99}), "41.99лв.") | n | 60 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храст", "cost": 41.99}), "41.99лв") |
61 | 61 | ||||
62 | # def test_valid_bushes_without_cost(self): | 62 | # def test_valid_bushes_without_cost(self): | ||
63 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "buSh"}), "Ni!") | 63 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "buSh"}), "Ni!") | ||
64 | # self.assertEqual(function_that_says_ni(a={"name": "храст"}, b={"name": "shrub"}), "Ni!") | 64 | # self.assertEqual(function_that_says_ni(a={"name": "храст"}, b={"name": "shrub"}), "Ni!") | ||
65 | 65 | ||||
66 | # def test_invalid_bushes_without_cost(self): | 66 | # def test_invalid_bushes_without_cost(self): | ||
67 | # self.assertEqual(function_that_says_ni({"name": "храст44"}, {"name": "bus44h"}), "Ni!") | 67 | # self.assertEqual(function_that_says_ni({"name": "храст44"}, {"name": "bus44h"}), "Ni!") | ||
68 | # self.assertEqual(function_that_says_ni(a={"name": "храс124т"}, b={"name": "s52hrub"}), "Ni!") | 68 | # self.assertEqual(function_that_says_ni(a={"name": "храс124т"}, b={"name": "s52hrub"}), "Ni!") | ||
69 | 69 | ||||
70 | # def test_valid_bushes_with_and_without_cost(self): | 70 | # def test_valid_bushes_with_and_without_cost(self): | ||
n | 71 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "bush", "cost": 33.33}), "33.33лв.") | n | 71 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "bush", "cost": 33.33}), "33.33лв") |
72 | # self.assertEqual(function_that_says_ni(a={"name": "храст", "cost": 17}, b={"name": "shrub"}), "Ni!") | 72 | # self.assertEqual(function_that_says_ni(a={"name": "храст", "cost": 17}, b={"name": "shrub"}), "Ni!") | ||
73 | 73 | ||||
74 | # def test_not_pretty_bushes_due_to_price(self): | 74 | # def test_not_pretty_bushes_due_to_price(self): | ||
75 | # self.assertEqual(function_that_says_ni({"name": "храсТ", "cost": 50.0}), "Ni!") | 75 | # self.assertEqual(function_that_says_ni({"name": "храсТ", "cost": 50.0}), "Ni!") | ||
76 | # self.assertEqual(function_that_says_ni({"name": "shrub", "cost": 43.00}), "Ni!") | 76 | # self.assertEqual(function_that_says_ni({"name": "shrub", "cost": 43.00}), "Ni!") | ||
77 | 77 | ||||
78 | # def test_not_pretty_bushes_due_to_unique_letters(self): | 78 | # def test_not_pretty_bushes_due_to_unique_letters(self): | ||
79 | # self.assertEqual(function_that_says_ni(ad={"name": "храст", "cost": 1.80}, b={"name": "храст", "cost": 1}), "Ni!") | 79 | # self.assertEqual(function_that_says_ni(ad={"name": "храст", "cost": 1.80}, b={"name": "храст", "cost": 1}), "Ni!") | ||
80 | # self.assertEqual(function_that_says_ni(a={"name": "буш"}, b={"name": "шрасх"}), "Ni!") | 80 | # self.assertEqual(function_that_says_ni(a={"name": "буш"}, b={"name": "шрасх"}), "Ni!") | ||
81 | 81 | ||||
82 | # def test_mixed_types(self): | 82 | # def test_mixed_types(self): | ||
n | 83 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 0.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "1.80лв.") | n | 83 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 0.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "1.80лв") |
84 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 30.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "Ni!") | 84 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 30.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "Ni!") | ||
85 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 40.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "Ni!") | 85 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 40.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "Ni!") | ||
86 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 40.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}, da=(1,2)), "Ni!") | 86 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 40.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}, da=(1,2)), "Ni!") | ||
87 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "храст", "cost": 0.0}, ["ffffffffff", {1, 2, 3}]), "Ni!") | 87 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "храст", "cost": 0.0}, ["ffffffffff", {1, 2, 3}]), "Ni!") | ||
88 | 88 | ||||
89 | # def test_all_in_one_first_variation(self): | 89 | # def test_all_in_one_first_variation(self): | ||
n | 90 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "ХРраст", "cost": 10.0}, [3,4,5], ad={"name": "хРаст", "cost": 1.80}, da = "pypy"), "1.80лв.") | n | 90 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "ХРраст", "cost": 10.0}, [3,4,5], ad={"name": "хРаст", "cost": 1.80}, da = "pypy"), "1.80лв") |
91 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "Храст", "cost": 100.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "Ni!") | 91 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "Храст", "cost": 100.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "Ni!") | ||
92 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 100.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "Ni!") | 92 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 100.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "Ni!") | ||
93 | 93 | ||||
94 | # def test_all_in_one_second_variation(self): | 94 | # def test_all_in_one_second_variation(self): | ||
n | 95 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 11.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "11.00лв.") | n | 95 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 11.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "11.00лв") |
96 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 11.0}, ad={"name": "bush", "cost": 1.80}, c = "pypy"), "Ni!") | 96 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 11.0}, ad={"name": "bush", "cost": 1.80}, c = "pypy"), "Ni!") | ||
t | 97 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 12.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "12.00лв.") | t | 97 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 12.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "12.00лв") |
98 | 98 | ||||
99 | # if __name__ == '__main__': | 99 | # if __name__ == '__main__': | ||
100 | # unittest.main() | 100 | # unittest.main() |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|
f | 1 | #keys for bushes | f | 1 | #keys for bushes |
2 | bushes_keys = ('храст', 'shrub', 'bush',) | 2 | bushes_keys = ('храст', 'shrub', 'bush',) | ||
3 | 3 | ||||
4 | #check if argument is a valid bush | 4 | #check if argument is a valid bush | ||
5 | def is_bush(arg): | 5 | def is_bush(arg): | ||
6 | if type(arg) != dict or 'name' not in arg: | 6 | if type(arg) != dict or 'name' not in arg: | ||
7 | return False | 7 | return False | ||
8 | 8 | ||||
9 | if arg['name'].lower() not in bushes_keys: | 9 | if arg['name'].lower() not in bushes_keys: | ||
10 | return False | 10 | return False | ||
11 | 11 | ||||
12 | return True | 12 | return True | ||
13 | 13 | ||||
14 | #check if the multitude of bushes is valid | 14 | #check if the multitude of bushes is valid | ||
15 | def is_pretty_bush(price, unique_letters): | 15 | def is_pretty_bush(price, unique_letters): | ||
16 | if int(price) == 0: | 16 | if int(price) == 0: | ||
17 | return False | 17 | return False | ||
18 | 18 | ||||
19 | return len(unique_letters) % int(price) == 0 and price <= 42.00 | 19 | return len(unique_letters) % int(price) == 0 and price <= 42.00 | ||
20 | 20 | ||||
21 | def function_that_says_ni(*args, **kwargs): | 21 | def function_that_says_ni(*args, **kwargs): | ||
22 | 22 | ||||
23 | price = 0.00 | 23 | price = 0.00 | ||
24 | 24 | ||||
25 | #iterate positioned args | 25 | #iterate positioned args | ||
26 | for positioned in args: | 26 | for positioned in args: | ||
27 | if is_bush(positioned): | 27 | if is_bush(positioned): | ||
28 | if 'cost' in positioned: | 28 | if 'cost' in positioned: | ||
29 | price += positioned['cost'] | 29 | price += positioned['cost'] | ||
30 | 30 | ||||
31 | #iterate named args | 31 | #iterate named args | ||
32 | for named in kwargs.values(): | 32 | for named in kwargs.values(): | ||
n | 33 | if is_bush(named): | n | 33 | if is_bush(named): |
34 | if 'cost' in named: | 34 | if 'cost' in named: | ||
35 | price += named['cost'] | 35 | price += named['cost'] | ||
36 | 36 | ||||
37 | #get unique characters found in the bushes in the multitude | 37 | #get unique characters found in the bushes in the multitude | ||
38 | unique_letters = set(''.join([key for key, value in kwargs.items() if is_bush(value)])) | 38 | unique_letters = set(''.join([key for key, value in kwargs.items() if is_bush(value)])) | ||
39 | 39 | ||||
40 | if is_pretty_bush(price, unique_letters): | 40 | if is_pretty_bush(price, unique_letters): | ||
41 | return f'{price:.2f}лв.' | 41 | return f'{price:.2f}лв.' | ||
42 | return 'Ni!' | 42 | return 'Ni!' | ||
t | 43 | t | |||
44 | 43 | ||||
45 | # import unittest | 44 | # import unittest | ||
46 | # from function_that_says_ni import function_that_says_ni | 45 | # from function_that_says_ni import function_that_says_ni | ||
47 | 46 | ||||
48 | # class TestFunctionThatSaysNi(unittest.TestCase): | 47 | # class TestFunctionThatSaysNi(unittest.TestCase): | ||
49 | 48 | ||||
50 | # def test_valid_bushes_with_cost(self): | 49 | # def test_valid_bushes_with_cost(self): | ||
51 | # self.assertEqual(function_that_says_ni({"name": "храст", "cost": 1.50}, {"name": "sHRub", "cost": 3.00}), "4.50лв.") | 50 | # self.assertEqual(function_that_says_ni({"name": "храст", "cost": 1.50}, {"name": "sHRub", "cost": 3.00}), "4.50лв.") | ||
52 | # self.assertEqual(function_that_says_ni({"name": "хРАст", "cost": 150}, {"name": "shrub", "cost": 3.00}), "Ni!") | 51 | # self.assertEqual(function_that_says_ni({"name": "хРАст", "cost": 150}, {"name": "shrub", "cost": 3.00}), "Ni!") | ||
53 | 52 | ||||
54 | # def test_invalid_bushes(self): | 53 | # def test_invalid_bushes(self): | ||
55 | # self.assertEqual(function_that_says_ni({"ddd": "храст", "cost": 1.50}, {"namae": "sHRub", "cost": 3.00}), "Ni!") | 54 | # self.assertEqual(function_that_says_ni({"ddd": "храст", "cost": 1.50}, {"namae": "sHRub", "cost": 3.00}), "Ni!") | ||
56 | # self.assertEqual(function_that_says_ni({"namdde": "хРАст", "cost": 150}, {"namse": "shrub", "cost": 3.00}), "Ni!") | 55 | # self.assertEqual(function_that_says_ni({"namdde": "хРАст", "cost": 150}, {"namse": "shrub", "cost": 3.00}), "Ni!") | ||
57 | 56 | ||||
58 | # def test_invalid_bushes_with_cost(self): | 57 | # def test_invalid_bushes_with_cost(self): | ||
59 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храст", "cost": 244.00}), "Ni!") | 58 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храст", "cost": 244.00}), "Ni!") | ||
60 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храстченце", "cost": 2.00}), "Ni!") | 59 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храстченце", "cost": 2.00}), "Ni!") | ||
61 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храст", "cost": 41.99}), "41.99лв.") | 60 | # self.assertEqual(function_that_says_ni({"name": "буш", "cost": 1.00}, {"name": "храст", "cost": 41.99}), "41.99лв.") | ||
62 | 61 | ||||
63 | # def test_valid_bushes_without_cost(self): | 62 | # def test_valid_bushes_without_cost(self): | ||
64 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "buSh"}), "Ni!") | 63 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "buSh"}), "Ni!") | ||
65 | # self.assertEqual(function_that_says_ni(a={"name": "храст"}, b={"name": "shrub"}), "Ni!") | 64 | # self.assertEqual(function_that_says_ni(a={"name": "храст"}, b={"name": "shrub"}), "Ni!") | ||
66 | 65 | ||||
67 | # def test_invalid_bushes_without_cost(self): | 66 | # def test_invalid_bushes_without_cost(self): | ||
68 | # self.assertEqual(function_that_says_ni({"name": "храст44"}, {"name": "bus44h"}), "Ni!") | 67 | # self.assertEqual(function_that_says_ni({"name": "храст44"}, {"name": "bus44h"}), "Ni!") | ||
69 | # self.assertEqual(function_that_says_ni(a={"name": "храс124т"}, b={"name": "s52hrub"}), "Ni!") | 68 | # self.assertEqual(function_that_says_ni(a={"name": "храс124т"}, b={"name": "s52hrub"}), "Ni!") | ||
70 | 69 | ||||
71 | # def test_valid_bushes_with_and_without_cost(self): | 70 | # def test_valid_bushes_with_and_without_cost(self): | ||
72 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "bush", "cost": 33.33}), "33.33лв.") | 71 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "bush", "cost": 33.33}), "33.33лв.") | ||
73 | # self.assertEqual(function_that_says_ni(a={"name": "храст", "cost": 17}, b={"name": "shrub"}), "Ni!") | 72 | # self.assertEqual(function_that_says_ni(a={"name": "храст", "cost": 17}, b={"name": "shrub"}), "Ni!") | ||
74 | 73 | ||||
75 | # def test_not_pretty_bushes_due_to_price(self): | 74 | # def test_not_pretty_bushes_due_to_price(self): | ||
76 | # self.assertEqual(function_that_says_ni({"name": "храсТ", "cost": 50.0}), "Ni!") | 75 | # self.assertEqual(function_that_says_ni({"name": "храсТ", "cost": 50.0}), "Ni!") | ||
77 | # self.assertEqual(function_that_says_ni({"name": "shrub", "cost": 43.00}), "Ni!") | 76 | # self.assertEqual(function_that_says_ni({"name": "shrub", "cost": 43.00}), "Ni!") | ||
78 | 77 | ||||
79 | # def test_not_pretty_bushes_due_to_unique_letters(self): | 78 | # def test_not_pretty_bushes_due_to_unique_letters(self): | ||
80 | # self.assertEqual(function_that_says_ni(ad={"name": "храст", "cost": 1.80}, b={"name": "храст", "cost": 1}), "Ni!") | 79 | # self.assertEqual(function_that_says_ni(ad={"name": "храст", "cost": 1.80}, b={"name": "храст", "cost": 1}), "Ni!") | ||
81 | # self.assertEqual(function_that_says_ni(a={"name": "буш"}, b={"name": "шрасх"}), "Ni!") | 80 | # self.assertEqual(function_that_says_ni(a={"name": "буш"}, b={"name": "шрасх"}), "Ni!") | ||
82 | 81 | ||||
83 | # def test_mixed_types(self): | 82 | # def test_mixed_types(self): | ||
84 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 0.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "1.80лв.") | 83 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 0.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "1.80лв.") | ||
85 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 30.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "Ni!") | 84 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 30.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "Ni!") | ||
86 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 40.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "Ni!") | 85 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 40.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}), "Ni!") | ||
87 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 40.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}, da=(1,2)), "Ni!") | 86 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "храст", "cost": 40.0}, [3,4,5], ad={"name": "храст", "cost": 1.80}, da=(1,2)), "Ni!") | ||
88 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "храст", "cost": 0.0}, ["ffffffffff", {1, 2, 3}]), "Ni!") | 87 | # self.assertEqual(function_that_says_ni({"name": "храст"}, {"name": "храст", "cost": 0.0}, ["ffffffffff", {1, 2, 3}]), "Ni!") | ||
89 | 88 | ||||
90 | # def test_all_in_one_first_variation(self): | 89 | # def test_all_in_one_first_variation(self): | ||
91 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "ХРраст", "cost": 10.0}, [3,4,5], ad={"name": "хРаст", "cost": 1.80}, da = "pypy"), "1.80лв.") | 90 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "ХРраст", "cost": 10.0}, [3,4,5], ad={"name": "хРаст", "cost": 1.80}, da = "pypy"), "1.80лв.") | ||
92 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "Храст", "cost": 100.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "Ni!") | 91 | # self.assertEqual(function_that_says_ni(4, 4, {"name": "Храст", "cost": 100.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "Ni!") | ||
93 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 100.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "Ni!") | 92 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 100.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "Ni!") | ||
94 | 93 | ||||
95 | # def test_all_in_one_second_variation(self): | 94 | # def test_all_in_one_second_variation(self): | ||
96 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 11.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "11.00лв.") | 95 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 11.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "11.00лв.") | ||
97 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 11.0}, ad={"name": "bush", "cost": 1.80}, c = "pypy"), "Ni!") | 96 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 11.0}, ad={"name": "bush", "cost": 1.80}, c = "pypy"), "Ni!") | ||
98 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 12.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "12.00лв.") | 97 | # self.assertEqual(function_that_says_ni( {"name": "Храст", "cost": 12.0}, ad={"name": "дърво", "cost": 1.80}, c = "pypy"), "12.00лв.") | ||
99 | 98 | ||||
100 | # if __name__ == '__main__': | 99 | # if __name__ == '__main__': | ||
101 | # unittest.main() | 100 | # unittest.main() |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|