def test_create_license_status_message_creates_correct_top_usage(self):

        with open('./usage_test.json') as json_data:
            json_array = json.load(json_data)

        parser = cssm_parser.CSSMJSONParser(json_array)

        cssm_license = parser.cssm_license()

        result = sld.create_license_status_message(cssm_license)

        expected = '* [Top 5 Licenses By Consumption](None "License Consumption Link")\n' \
                   '    * **BU Production Test**\n' \
                   '        * Some Virtual Account 1\n' \
                   '            * Some License, has 64.0% utilization\n' \
                   '            * CSR 1KV APPX 10M, has 24.0% utilization\n' \
                   '    * **Some Goofy Production Test**\n' \
                   '        * Fly By Night\n' \
                   '            * Some License III, has 56.0% utilization\n' \
                   '            * Some License II, has 34.0% utilization\n' \
                   '        * Dowee Cheatum and Howe\n' \
                   '            * Some License IV, has 44.0% utilization\n'

        self.assertTrue(
            expected in result,
            'test_create_license_status_message_creates_correct_top_usage.\nExpected: {}\nResult:{}'
            .format(expected, result))
    def test_create_license_status_message_creates_correct_top_shortage(self):
        with open(file_name) as json_data:
            json_array = json.load(json_data)

        parser = cssm_parser.CSSMJSONParser(json_array)

        cssm_license = parser.cssm_license()

        result = sld.create_license_status_message(cssm_license)
        # expected = "noway"
        expected = '* [Top 5 License Shortages](None "License Shortage Link")\n' \
                   '    * **Cisco Sales Enablement**\n' \
                   '        * Alex Daltrini (adaltrin)\n' \
                   '            * ASAv10 Standard - 1G, has a shortage of 14 licenses\n' \
                   '        * DEFAULT\n' \
                   '            * CSR 1KV AX 250M, has a shortage of 13 licenses\n' \
                   '            * C3650_24_Ipserv, has a shortage of 12 licenses\n' \
                   '    * **Federal Team Testing Cisco Account**\n' \
                   '        * DoD-AF\n' \
                   '            * Prime Infrastructure 3.x, Lifecycle Lic., has a shortage of 11 licenses\n' \
                   '            * Prime Infrastructure 3.x, BASE Lic., has a shortage of 10 licenses'

        self.assertTrue(
            expected in result,
            'test_create_license_status_message_creates_correct_top_shortage.\nExpected: {}\nResult:{}'
            .format(expected, result))
    def test_create_license_status_message_creates_correct_future_expired_status(
            self):
        with open('./multiple_future_expiration.json') as json_data:
            json_array = json.load(json_data)

        parser = cssm_parser.CSSMJSONParser(json_array)

        cssm_license = parser.cssm_license()

        result = sld.create_license_status_message(cssm_license)
        # expected = "noway"
        expected = '* [Top 5 Licenses Expiring in the Next 180 Days](None "Future Expired License Link")\n' \
                   '    * **BU Production Test**\n' \
                   '        * ATT ENCS\n' \
                   '            * **CSR 1KV APPX 2500M**, Qty: 50 expire on: 2019/08/04\n' \
                   '        * Some Virtual Account 1\n' \
                   '            * **CSR 1KV APPX 10M**, Qty: 50 expire on: 2019/09/04\n' \
                   '            * **Some License**, Qty: 50 expire on: 2019/09/15\n' \
                   '    * **Some Goofy Production Test**\n' \
                   '        * Dowee Cheatum and Howe\n' \
                   '            * **Some License IV**, Qty: 50 expire on: 2019/11/04\n' \
                   '        * Fly By Night\n' \
                   '            * **Some License III**, Qty: 50 expire on: 2019/11/30'

        self.assertTrue(
            expected in result,
            'test_create_license_status_message_creates_correct_expired_status.\nExpected: {}\nResult:{}'
            .format(expected, result))
    def test_create_license_status_message_creates_correct_expired_status(
            self):
        with open(file_name) as json_data:
            json_array = json.load(json_data)

        parser = cssm_parser.CSSMJSONParser(json_array)

        cssm_license = parser.cssm_license()

        result = sld.create_license_status_message(cssm_license)
        expected = '    * **Cisco Sales Enablement**\n' \
                   '        * DEFAULT\n' \
                   '            * ISRV AX 250M, Qty: 4990, Expired: 2018/11/19\n' \
                   '    * **BU Production Test**\n' \
                   '        * ATT CUSTOMER 1\n' \
                   '            * ISRV AX 2500M, Qty: 5, Expired: 2019/04/02\n' \
                   '            * ISRV IPB 2500M, Qty: 5, Expired: 2019/04/02\n' \
                   '        * ATT ENCS\n' \
                   '            * CSR 1KV AX 5G, Qty: 6, Expired: 2019/05/23\n' \
                   '        * ATT Account Team\n' \
                   '            * CSR 1KV AX 5G, Qty: 4, Expired: 2019/05/23\n'

        self.assertTrue(
            expected in result,
            'test_create_license_status_message_creates_correct_expired_status.\nExpected: {}\nResult:{}'
            .format(expected, result))
    def test_create_license_status_message_has_correct_initial_text(self):
        with open(file_name) as json_data:
            json_array = json.load(json_data)

        parser = cssm_parser.CSSMJSONParser(json_array)

        cssm_license = parser.cssm_license()

        expected = "**Here is the high level status of your licensing**:\n"

        result = sld.create_license_status_message(cssm_license)

        self.assertTrue(
            expected in result,
            'test_create_license_status_message_has_correct_initial_text.\nExpected:\n {}Result:\n{}'
            .format(expected, result))
    def test_create_license_status_message_creates_correct_top_usage_when_no_usage(
            self):
        with open('./my_licensing_info.json') as json_data:
            json_array = json.load(json_data)

        parser = cssm_parser.CSSMJSONParser(json_array)

        cssm_license = parser.cssm_license()

        result = sld.create_license_status_message(cssm_license)

        expected = '* [License Usage: There are no licenses in use right now](None "License Consumption Link")'

        self.assertTrue(
            expected in result,
            'test_create_license_status_message_creates_correct_top_usage_when_no_usage.\nExpected: {}\nResult:{}'
            .format(expected, result))
    def test_create_license_status_message_creates_correct_top_technology_empty(
            self):

        with open('./my_licensing_info.json') as json_data:
            json_array = json.load(json_data)

        parser = cssm_parser.CSSMJSONParser(json_array)

        cssm_license = parser.cssm_license()

        result = sld.create_license_status_message(cssm_license)

        expected = '[License Shortage: There are no license shortages](None "License Shortage Link")'

        self.assertTrue(
            expected in result,
            'test_create_license_status_message_creates_correct_top_technology.\nExpected: {}\nResult:{}'
            .format(expected, result))
    def test_create_license_status_message_creates_correct_top_technology(
            self):

        with open('./alex_json_v1.json') as json_data:
            json_array = json.load(json_data)

        parser = cssm_parser.CSSMJSONParser(json_array)

        cssm_license = parser.cssm_license()

        result = sld.create_license_status_message(cssm_license)

        expected = '* [Here is your architecture mix, by Account](None "License Architecture Mix Link")\n' \
                   '    * **PnP Test Account - KB**\n' \
                   '        * Security: 52.9%\n' \
                   '        * Enterprise Networking: 47.1%\n'

        self.assertTrue(
            expected in result,
            'test_create_license_status_message_creates_correct_top_technology.\nExpected: {}\nResult:{}'
            .format(expected, result))