Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/customizations/emrcontainers/test_base36.py
1569 views
1
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
14
from awscli.testutils import unittest
15
from awscli.customizations.emrcontainers.base36 import Base36
16
17
class TestBase36(unittest.TestCase):
18
base36 = Base36()
19
20
# Use case: Provide various strings as input and assert that
21
# base36 encoded string is correct
22
# Expected results: Expected base36 encoded string is returned
23
def test_base36_encoding(self):
24
# Test for empty string
25
self.assertEqual(self.base36.encode(''), '0')
26
27
# Test for a short string
28
self.assertEqual(self.base36.encode('abcdefghijkl'),
29
'2x6xx5ubcrus4bplmr0')
30
31
# Test for a really lengthy string
32
self.assertEqual(self.base36.encode('abcdefghijklmnopqrstuvwxyzabcdef'
33
'ghijklmnopqrstuvwxyzabcdefghijkl'
34
'mnopqrstuvwxyzabcdefghijklmnopqr'
35
'stuvwxyzabcdefghijklmnopqrstuvwx'),
36
'hihg421ybq8vpwgxd21fae22r9rho7x8qpyskkz6iqadme7ds5f'
37
'qxpnedq44doj5dlitkm8wswo3c5503yl55jfazzhbbqnnee7r70'
38
'zw89fs5ojeipi6xeiydas7g7y9w3usdlzrlhxx0q50bxvt27tfu'
39
'3ruwyx4fuv96rcfpkqxxg93vdclsof5ribhnrcvajmpvc')
40
41
# Test for a string with only special characters
42
self.assertEqual(self.base36.encode('+=,.@-_'), '3bu5b0xg4tb')
43
44
# Test for a string containing special characters
45
self.assertEqual(self.base36.encode('abcdefghijkl+=,.@-_'),
46
'1ll75jdngh5gbk11wbh7h35ji05wtb')
47
48
49
if __name__ == "__main__":
50
unittest.main()
51
52