Пример #1
0
    def from_csv(cls, rows):
        _ = rows.pop(0)

        settings = []

        for row in rows:
            _, subcategory, _, _, audit_option, _, _ = row.split(',')

            if subcategory:
                settings.append(SubcategorySetting.from_csv(row))
            elif audit_option:
                settings.append(AuditOption.from_csv(row))
            else:
                settings.append(GlobalObjectAccessAuditSetting.from_csv(row))

        return cls(settings=settings)
Пример #2
0
 def test_to_csv(self):
     option_value = OptionValue()
     audit_option = AuditOption(type='CrashOnAuditFail', value=option_value)
     self.assertEqual(audit_option.to_csv(), ',,Option:CrashOnAuditFail,,Disabled,,0\n')
Пример #3
0
 def test_from_csv(self):
     audit_option = AuditOption.from_csv(',,Option:CrashOnAuditFail,,Disabled,,0\n')
     self.assertIsInstance(audit_option, AuditOption)
Пример #4
0
 def test_invalid_value_type(self):
     with self.assertRaises(TypeError):
         AuditOption(type='CrashOnAuditFail', value=None)
Пример #5
0
 def test_valid_value(self):
     option_value = OptionValue()
     audit_option = AuditOption(type='CrashOnAuditFail', value=option_value)
     self.assertEqual(audit_option.value.enabled, False)
Пример #6
0
    def test_invalid_type_type(self):
        option_value = OptionValue()

        with self.assertRaises(TypeError):
            AuditOption(type=None, value=option_value)
Пример #7
0
 def test_valid_type(self):
     option_value = OptionValue()
     audit_option = AuditOption(type='CrashOnAuditFail', value=option_value)
     self.assertEqual(audit_option.type, 'CrashOnAuditFail')