# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import unittest
from azext_devops.dev.common.format import trim_for_display, date_time_to_only_date


class TestFormatMethods(unittest.TestCase):

    def test_trim_for_display(self):
        input = 'Gallery extensions for Portal Extension'
        output = trim_for_display(input, 20)
        self.assertEqual(output, 'Gallery extensions f...')

        input = 'Aex platform'
        output = trim_for_display(input, 20)
        self.assertEqual(output, input)

        input = ''
        output = trim_for_display(input, 20)
        self.assertEqual(output, input)

        input = None
        output = trim_for_display(input, 20)
        self.assertEqual(output, input)

    def test_date_time_to_only_date(self):
        input = '2019-02-24T02:45:41.277000+00:00'
        output = date_time_to_only_date(input)
        self.assertEqual(output, '2019-02-24')

        input = 'Aex platform'
        output = date_time_to_only_date(input)
        self.assertEqual(output, input)


if __name__ == '__main__':
    unittest.main()
[((40, 4, 40, 19), 'unittest.main', 'unittest.main', ({}, {}), '()', False, 'import unittest\n'), ((14, 17, 14, 44), 'azext_devops.dev.common.format.trim_for_display', 'trim_for_display', ({(14, 34, 14, 39): 'input', (14, 41, 14, 43): '20'}, {}), '(input, 20)', False, 'from azext_devops.dev.common.format import trim_for_display, date_time_to_only_date\n'), ((18, 17, 18, 44), 'azext_devops.dev.common.format.trim_for_display', 'trim_for_display', ({(18, 34, 18, 39): 'input', (18, 41, 18, 43): '20'}, {}), '(input, 20)', False, 'from azext_devops.dev.common.format import trim_for_display, date_time_to_only_date\n'), ((22, 17, 22, 44), 'azext_devops.dev.common.format.trim_for_display', 'trim_for_display', ({(22, 34, 22, 39): 'input', (22, 41, 22, 43): '20'}, {}), '(input, 20)', False, 'from azext_devops.dev.common.format import trim_for_display, date_time_to_only_date\n'), ((26, 17, 26, 44), 'azext_devops.dev.common.format.trim_for_display', 'trim_for_display', ({(26, 34, 26, 39): 'input', (26, 41, 26, 43): '20'}, {}), '(input, 20)', False, 'from azext_devops.dev.common.format import trim_for_display, date_time_to_only_date\n'), ((31, 17, 31, 46), 'azext_devops.dev.common.format.date_time_to_only_date', 'date_time_to_only_date', ({(31, 40, 31, 45): 'input'}, {}), '(input)', False, 'from azext_devops.dev.common.format import trim_for_display, date_time_to_only_date\n'), ((35, 17, 35, 46), 'azext_devops.dev.common.format.date_time_to_only_date', 'date_time_to_only_date', ({(35, 40, 35, 45): 'input'}, {}), '(input)', False, 'from azext_devops.dev.common.format import trim_for_display, date_time_to_only_date\n')]