Path: blob/develop/tests/unit/customizations/emrcontainers/test_base36.py
1569 views
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.1213from awscli.testutils import unittest14from awscli.customizations.emrcontainers.base36 import Base361516class TestBase36(unittest.TestCase):17base36 = Base36()1819# Use case: Provide various strings as input and assert that20# base36 encoded string is correct21# Expected results: Expected base36 encoded string is returned22def test_base36_encoding(self):23# Test for empty string24self.assertEqual(self.base36.encode(''), '0')2526# Test for a short string27self.assertEqual(self.base36.encode('abcdefghijkl'),28'2x6xx5ubcrus4bplmr0')2930# Test for a really lengthy string31self.assertEqual(self.base36.encode('abcdefghijklmnopqrstuvwxyzabcdef'32'ghijklmnopqrstuvwxyzabcdefghijkl'33'mnopqrstuvwxyzabcdefghijklmnopqr'34'stuvwxyzabcdefghijklmnopqrstuvwx'),35'hihg421ybq8vpwgxd21fae22r9rho7x8qpyskkz6iqadme7ds5f'36'qxpnedq44doj5dlitkm8wswo3c5503yl55jfazzhbbqnnee7r70'37'zw89fs5ojeipi6xeiydas7g7y9w3usdlzrlhxx0q50bxvt27tfu'38'3ruwyx4fuv96rcfpkqxxg93vdclsof5ribhnrcvajmpvc')3940# Test for a string with only special characters41self.assertEqual(self.base36.encode('+=,.@-_'), '3bu5b0xg4tb')4243# Test for a string containing special characters44self.assertEqual(self.base36.encode('abcdefghijkl+=,.@-_'),45'1ll75jdngh5gbk11wbh7h35ji05wtb')464748if __name__ == "__main__":49unittest.main()505152