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' )
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)
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}')
def test_valid_id(self): subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}', name='Example') self.assertEqual(subcategory.id, '{00000000-0000-0000-0000-000000000000}')
def test_invalid_description_type(self): with self.assertRaises(TypeError): Subcategory(id='{00000000-0000-0000-0000-000000000000}', name='Example', description=None)
def test_valid_description(self): subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}', name='Example', description='Description') self.assertEqual(subcategory.description, 'Description')
def test_default_description(self): subcategory = Subcategory(id='{00000000-0000-0000-0000-000000000000}', name='Example') self.assertEqual(subcategory.description, '')
def test_invalid_name_type(self): with self.assertRaises(TypeError): Subcategory(id='{00000000-0000-0000-0000-000000000000}', name=None)
def test_invalid_id_type(self): with self.assertRaises(TypeError): Subcategory(id=None, name='Example')
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)
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)
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)
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)