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 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_int_failure(self): settin_value = SettingValue(failure=True) self.assertEqual(int(settin_value), 2)
def test_int_success(self): settin_value = SettingValue(success=True) self.assertEqual(int(settin_value), 1)
def test_invalid_subcategory_type(self): inclusion_setting = SettingValue() with self.assertRaises(TypeError): SubcategorySetting(subcategory=None, inclusion_setting=inclusion_setting)
def test_from_value_text_failure(self): settin_value = SettingValue.from_value_text('Failure') self.assertEqual((settin_value.success, settin_value.failure), (False, True))
def test_from_value_text_no_auditing(self): settin_value = SettingValue.from_value_text('No Auditing') self.assertEqual((settin_value.success, settin_value.failure), (False, False))
def test_str_success_and_failure(self): settin_value = SettingValue(success=True, failure=True) self.assertEqual(str(settin_value), 'Success and Failure')
def test_str_success(self): settin_value = SettingValue(success=True) self.assertEqual(str(settin_value), 'Success')
def test_valid_success(self): settin_value = SettingValue(success=True) self.assertEqual(settin_value.success, True)
def test_default_success(self): settin_value = SettingValue() self.assertEqual(settin_value.success, False)
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_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)
def test_int_success_and_failure(self): settin_value = SettingValue(success=True, failure=True) self.assertEqual(int(settin_value), 3)
def test_str_no_auditing(self): settin_value = SettingValue() self.assertEqual(str(settin_value), 'No Auditing')
def test_invalid_success_type(self): with self.assertRaises(TypeError): SettingValue(success=None)
def test_str_failure(self): settin_value = SettingValue(failure=True) self.assertEqual(str(settin_value), 'Failure')
def test_default_failure(self): settin_value = SettingValue() self.assertEqual(settin_value.failure, False)
def test_from_value_success_and_failure(self): settin_value = SettingValue.from_value(3) self.assertEqual((settin_value.success, settin_value.failure), (True, True))
def test_valid_failure(self): settin_value = SettingValue(failure=True) self.assertEqual(settin_value.failure, True)
def test_from_value_text_success(self): settin_value = SettingValue.from_value_text('Success') self.assertEqual((settin_value.success, settin_value.failure), (True, False))
def test_invalid_failure_type(self): with self.assertRaises(TypeError): SettingValue(failure=None)
def test_int_no_auditing(self): settin_value = SettingValue() self.assertEqual(int(settin_value), 0)
def test_from_value_text_success_and_failure(self): settin_value = SettingValue.from_value_text('Success and Failure') self.assertEqual((settin_value.success, settin_value.failure), (True, True))