def test_no_match_format_row(self): fs = RowFormatSpecification(['H1', 'H2'], 'H2', ['one', 'two'], WarningFormatter()) row = ['three', 'four'] fs.format_row(row) self.assertIsNotNone(row) self.assertEqual(row, ['three', 'four'])
def test_short_format_row(self): """ Validates the row does not change if it is too short""" fs = RowFormatSpecification(['H1', 'H2', 'H3', 'H4'], 'H4', ['one', 'two'], WarningFormatter()) row = ['three', 'four'] fs.format_row(row) self.assertIsNotNone(row) self.assertEqual(row, ['three', 'four'])
def test_header_created(self): """Ensure that the table returned is not empty and the properties are set correctly. The header items will not match the formatter. Actual content is not validated.""" header = ['One', 'Two', 'Three', 'Four'] fs = RowFormatSpecification(header, 'Three', ['Dangerous'], WarningFormatter()) ct = SimpleConsoleTable(header, fs) actual = ct.get_table() self.assertIsNotNone(actual) self.assertEqual(len(ct.rows), 1)
def test_row_format(self): """Validates that all properties are correct after a row is formatted. The formatting is not validated.""" header = ['One', 'Two', 'Three', 'Four'] fs = RowFormatSpecification(header, 'Three', ['c'], WarningFormatter()) ct = SimpleConsoleTable(header, fs) ct.add_row(['a','b','c','d']) actual = ct.get_table() self.assertIsNotNone(actual) self.assertEqual(len(ct.rows), 2)
def display_permissions(permissions): header = ['Permissions', 'Protection Level', 'Added', 'Deprecated'] fs = RowFormatSpecification(header, 'Protection Level', ['Dangerous'], WarningFormatter()) ct = SimpleConsoleTable(header, fs) for permission in permissions: split_perm = permission.split('.') short_perm = split_perm[-1] protection_level = get_permission_protection_level(short_perm) added = get_permission_added(short_perm) deprecated = get_permission_deprecated(short_perm) ct.add_row([permission, protection_level, added, deprecated]) print(ct.get_table())
def test_valid_init(self): fs = RowFormatSpecification(['H1', 'H2'], 'H2', ['one', 'two'], WarningFormatter()) self.assertIsNotNone(fs)