# Untitled

a guest
Nov 1st, 2022
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import unittest
2.
3. from solution import (nums_to_text, text_to_nums, nums_to_angle,
4. angles_to_nums, is_phone_tastic)
5.
6.
7. class TestNumsToText(unittest.TestCase):
8. """Test the nums_to_text function."""
9.
10. def test_given_example(self):
11. """The test given from the example."""
12. self.assertEqual(nums_to_text([4, 4, 3, 3, 5, 5, 5, -1, 5, 5, 5, 6, 6, 6]), "HELLO")
13.
14. def test_minus_one(self):
15. """Testing with -1."""
16. self.assertEqual(nums_to_text([2, 7, 7, 7, 7, 3, -1, 3, 3, 3]), 'ASDF')
17.
18. def test_multiple_times(self):
19. """Test pressing the 3 and 4 letter keys numerous"""
20. self.assertEqual(
21. nums_to_text([5, 5, 5, 5, 5, 5, 5, 5, 5, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7]), 'LZUP')
22.
23. def test_spaces(self):
24. """Test pressing the 0 for the spaces"""
25. self.assertEqual(nums_to_text([7, 7, 8, 9, 9, 9, 0, 5, 5, 3, 3, 0, 2, 2, 2, 5]), 'QTY KE CJ')
26.
27. def test_missing_numbers(self):
28. """Test for numbers not on the keys"""
29. self.assertEqual(nums_to_text([1, 1, 1, -10, 2, 2, 2, 3, 10, 0, 2, 2, -1, 2]), 'CD BA')
30.
31.
32. class TestTextToNums(unittest.TestCase):
33. """Test the text_to_nums function."""
34.
35. def test_given_example(self):
36. """The test given from the example."""
37. self.assertEqual(text_to_nums("PYTHON"), [7, 9, 9, 9, 8, 4, 4, 6, 6, 6, -1, 6, 6])
38.
39. def test_second_example(self):
40. """Testing with the second example test."""
41. self.assertEqual(text_to_nums("asl pls"), [2, 7, 7, 7, 7, 5, 5, 5, 0, 7, 5, 5, 5, 7, 7, 7, 7])
42.
43. def test_multiple_times(self):
44. """Testing with repeating letters"""
45. self.assertEqual(text_to_nums("pPp YyY aaa BBB"),
46. [7, -1, 7, -1, 7, 0, 9, 9, 9, -1, 9, 9, 9, -1, 9, 9, 9, 0, 2, -1, 2, -1, 2, 0, 2, 2, -1, 2, 2,
47. -1, 2, 2])
48.
49. def test_lower_upper(self):
50. """Test with lower and upper letters"""
51. self.assertEqual(text_to_nums("aBcDeF GhIgK"),
52. [2, -1, 2, 2, -1, 2, 2, 2, 3, -1, 3, 3, -1, 3, 3, 3, 0, 4, -1, 4, 4, -1, 4, 4, 4, -1, 4, 5, 5])
53.
54. def test_spaces(self):
55. """Test with multiple spaces"""
56. self.assertEqual(text_to_nums('foo bar baz'),
57. [3, 3, 3, 6, 6, 6, -1, 6, 6, 6, 0, -1, 0, -1, 0, -1, 0, 2, 2, -1, 2, 7, 7, 7, 0, -1, 0, -1, 0,
58. -1, 0, 2, 2, -1, 2, 9, 9, 9, 9])
59.
60.
61. if __name__ == '__main__':
62. unittest.main()
63.