def test_format_name_no_break(self):
     result = format_name('testing string testing st', 1, 11)
     expected = 'testing\n string\n testing st'
     self.assertEqual(result, expected)
     result = format_name('testing string testing st', 2, 12)
     expected = 'testing\n  string\n  testing st'
     self.assertEqual(result, expected)
 def test_format_name_no_break(self):
     result = format_name('testing string testing st', 1, 11)
     expected = 'testing\n string\n testing st'
     self.assertEquals(result, expected)
     result = format_name('testing string testing st', 2, 12)
     expected = 'testing\n  string\n  testing st'
     self.assertEquals(result, expected)
 def test_format_name_break(self):
     result = format_name('a' * 10, 0, 10)
     expected = 'a' * 10
     self.assertEquals(result, expected)
     result = format_name('a' * 11, 0, 10)
     expected = 'a' * 10 + '\na'
     self.assertEquals(result, expected)
     result = format_name('a' * 11 + ' ' + 'a' * 9, 0, 10)
     expected = 'a' * 10 + '\na\n' + 'a' * 9
     self.assertEquals(result, expected)
 def test_format_name_break(self):
     result = format_name("a" * 10, 0, 10)
     expected = "a" * 10
     self.assertEqual(result, expected)
     result = format_name("a" * 11, 0, 10)
     expected = "a" * 10 + "\na"
     self.assertEqual(result, expected)
     result = format_name("a" * 11 + " " + "a" * 9, 0, 10)
     expected = "a" * 10 + "\na\n" + "a" * 9
     self.assertEqual(result, expected)
 def test_format_name_break(self):
     result = format_name('a' * 10, 0, 10)
     expected = 'a' * 10
     self.assertEqual(result, expected)
     result = format_name('a' * 11, 0, 10)
     expected = 'a' * 10 + '\na'
     self.assertEqual(result, expected)
     result = format_name('a' * 11 + ' ' + 'a' * 9, 0, 10)
     expected = 'a' * 10 + '\na\n' + 'a' * 9
     self.assertEqual(result, expected)
 def test_format_name_short(self):
     name = "a"
     format_name(name, self.indent, self.max_length)
예제 #7
0
    def _do_command(self):
        # list status and all reasons it is not valid
        on_date = None
        if self.options.on_date:
            try:
                on_date = entitlement.EntitlementService.parse_date(
                    self.options.on_date)
            except ValueError as err:
                system_exit(os.EX_DATAERR, err)

        print("+-------------------------------------------+")
        print("   " + _("System Status Details"))
        print("+-------------------------------------------+")

        service_status = entitlement.EntitlementService(None).get_status(
            on_date)
        reasons = service_status['reasons']

        if service_status['valid']:
            result = 0
        else:
            result = 1

        ca_message = ""
        has_cert = (_(
            "Content Access Mode is set to Simple Content Access. This host has access to content, regardless of subscription status.\n"
        ))

        certs = self.entitlement_dir.list_with_content_access()
        ca_certs = [
            cert for cert in certs
            if cert.entitlement_type == CONTENT_ACCESS_CERT_TYPE
        ]
        if ca_certs:
            ca_message = has_cert
        else:
            if is_simple_content_access(uep=self.cp, identity=self.identity):
                ca_message = has_cert

        print(
            _("Overall Status: {status}\n{message}").format(
                status=service_status['status'], message=ca_message))

        columns = get_terminal_width()
        for name in reasons:
            print(format_name(name + ':', 0, columns))
            for message in reasons[name]:
                print("- {name}".format(name=format_name(message, 2, columns)))
            print('')

        try:
            store = syspurposelib.get_sys_purpose_store()
            if store:
                store.sync()
        except (OSError, ConnectionException) as ne:
            log.exception(ne)

        syspurpose_cache = inj.require(
            inj.SYSTEMPURPOSE_COMPLIANCE_STATUS_CACHE)
        syspurpose_cache.load_status(self.cp, self.identity.uuid, on_date)
        print(
            _("System Purpose Status: {status}").format(
                status=syspurpose_cache.get_overall_status()))

        syspurpose_status_code = syspurpose_cache.get_overall_status_code()
        if syspurpose_status_code != 'matched':
            reasons = syspurpose_cache.get_status_reasons()
            if reasons is not None:
                for reason in reasons:
                    print("- {reason}".format(reason=reason))
        print('')

        return result
 def test_format_name_no_break_no_indent(self):
     result = format_name('testing string testing st', 0, 10)
     expected = 'testing\nstring\ntesting st'
     self.assertEquals(result, expected)
 def test_leading_tabs(self):
     name = "\t" * 4 + "I have four leading tabs"
     new_name = format_name(name, self.indent, self.max_length)
     self.assertEqual("\t" * 4, new_name[0:4])
 def test_format_name_break_indent(self):
     result = format_name("a" * 20, 1, 10)
     expected = "a" * 9 + "\n " + "a" * 9 + "\n " + "aa"
     self.assertEqual(result, expected)
 def test_leading_spaces(self):
     name = " " * 4 + "I have four leading spaces"
     new_name = format_name(name, 3, 10)
     self.assertEquals("    I have\n   four\n   leading\n   spaces", new_name)
 def test_format_name_null_width(self):
     name = "This is a Really Long Name For A Product That We Do Not Want To See But Should Be Able To Deal With"
     new_name = format_name(name, self.indent, None)
     self.assertEquals(name, new_name)
 def test_format_name_short(self):
     name = "a"
     format_name(name, self.indent, self.max_length)
 def test_format_name_break_indent(self):
     result = format_name('a' * 20, 1, 10)
     expected = 'a' * 9 + '\n ' + 'a' * 9 + '\n ' + 'aa'
     self.assertEquals(result, expected)
 def test_format_name_break_indent(self):
     result = format_name('a' * 20, 1, 10)
     expected = 'a' * 9 + '\n ' + 'a' * 9 + '\n ' + 'aa'
     self.assertEqual(result, expected)
 def test_format_name_no_break_no_indent(self):
     result = format_name('testing string testing st', 0, 10)
     expected = 'testing\nstring\ntesting st'
     self.assertEqual(result, expected)
 def test_format_name_long(self):
     name = "This is a Really Long Name For A Product That We Do Not Want To See But Should Be Able To Deal With"
     format_name(name, self.indent, self.max_length)
 def test_format_name_long(self):
     name = "This is a Really Long Name For A Product That We Do Not Want To See But Should Be Able To Deal With"
     format_name(name, self.indent, self.max_length)
 def test_format_name_empty(self):
     name = ''
     new_name = format_name(name, self.indent, self.max_length)
     self.assertEqual(name, new_name)
 def test_format_name_empty(self):
     name = ''
     new_name = format_name(name, self.indent, self.max_length)
     self.assertEquals(name, new_name)
 def test_format_name_null_width(self):
     name = "This is a Really Long Name For A Product That We Do Not Want To See But Should Be Able To Deal With"
     new_name = format_name(name, self.indent, None)
     self.assertEqual(name, new_name)
 def test_format_name_none(self):
     name = None
     new_name = format_name(name, self.indent, self.max_length)
     self.assertTrue(new_name is None)
 def test_format_name_none(self):
     name = None
     new_name = format_name(name, self.indent, self.max_length)
     self.assertTrue(new_name is None)
 def test_leading_tabs(self):
     name = "\t" * 4 + "I have four leading tabs"
     new_name = format_name(name, self.indent, self.max_length)
     self.assertEquals("\t" * 4, new_name[0:4])
 def test_leading_spaces(self):
     name = " " * 4 + "I have four leading spaces"
     new_name = format_name(name, 3, 10)
     self.assertEqual("    I have\n   four\n   leading\n   spaces",
                      new_name)