Пример #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
    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)