コード例 #1
0
 def test_to_csv(self):
     subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}', name='Example')
     inclusion_setting = SettingValue()
     subcategory_setting = SubcategorySetting(subcategory=subcategory, inclusion_setting=inclusion_setting)
     self.assertEqual(
         subcategory_setting.to_csv(), 
         ',System,Example,{00000000-0000-0000-0000-000000000000},No Auditing,,0\n'
     )
コード例 #2
0
ファイル: settings.py プロジェクト: LiamSennitt/auditpol
    def from_csv(cls, row):
        machine_name, _, name, id, inclusion_value_text, _, _ = row.split(',')

        inclusion_setting = SettingValue.from_value_text(inclusion_value_text)

        return cls(machine_name=machine_name,
                   subcategory=Subcategory(id=id, name=name),
                   inclusion_setting=inclusion_setting)
コード例 #3
0
 def test_valid_settings_element(self):
     subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}',
                               name='Example')
     inclusion_setting = SettingValue()
     subcategory_setting = SubcategorySetting(
         subcategory=subcategory, inclusion_setting=inclusion_setting)
     policy = AuditPolicy(settings=[subcategory_setting])
     self.assertEqual(policy.settings[0].subcategory.id,
                      '{00000000-0000-0000-0000-000000000000}')
コード例 #4
0
 def test_valid_id(self):
     subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}',
                               name='Example')
     self.assertEqual(subcategory.id,
                      '{00000000-0000-0000-0000-000000000000}')
コード例 #5
0
 def test_invalid_description_type(self):
     with self.assertRaises(TypeError):
         Subcategory(id='{00000000-0000-0000-0000-000000000000}',
                     name='Example',
                     description=None)
コード例 #6
0
 def test_valid_description(self):
     subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}',
                               name='Example',
                               description='Description')
     self.assertEqual(subcategory.description, 'Description')
コード例 #7
0
 def test_default_description(self):
     subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}',
                               name='Example')
     self.assertEqual(subcategory.description, '')
コード例 #8
0
 def test_invalid_name_type(self):
     with self.assertRaises(TypeError):
         Subcategory(id='{00000000-0000-0000-0000-000000000000}', name=None)
コード例 #9
0
 def test_invalid_id_type(self):
     with self.assertRaises(TypeError):
         Subcategory(id=None, name='Example')
コード例 #10
0
 def test_value_include_success_and_failure(self):
     subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}', name='Example')
     inclusion_setting = SettingValue(success=True, failure=True)
     subcategory_setting = SubcategorySetting(subcategory=subcategory, inclusion_setting=inclusion_setting)
     self.assertEqual(subcategory_setting.value, 3)
コード例 #11
0
 def test_value_include_no_auditing(self):
     subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}', name='Example')
     inclusion_setting = SettingValue()
     subcategory_setting = SubcategorySetting(subcategory=subcategory, inclusion_setting=inclusion_setting)
     self.assertEqual(subcategory_setting.value, 0)
コード例 #12
0
    def test_invalid_inclusion_setting_type(self):
        subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}', name='Example')

        with self.assertRaises(TypeError):
            SubcategorySetting(subcategory=subcategory, inclusion_setting=None)
コード例 #13
0
 def test_valid_inclusion_setting(self):
     subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}', name='Example')
     inclusion_setting = SettingValue()
     subcategory_setting = SubcategorySetting(subcategory=subcategory, inclusion_setting=inclusion_setting)
     self.assertEqual(subcategory_setting.inclusion_setting.success, False)