[apparmor] [patch] Add tests for Baserule
Christian Boltz
apparmor at cboltz.de
Sat Apr 11 21:02:48 UTC 2015
Hello,
This patch adds some tests for the Baserule class to cover the
3 functions that must be re-implemented in each rule class. This means
we finally get 100% test coverage for apparmor/rule/__init__.py ;-)
If we merge the rule classes into 2.9, then this patch should also go in.
Note: this patch depends on 31-enable-testloops-for-nosetests.diff
because of the changed setup_all_loops() function name and parameters.
[ 41-add-baserule-tests.diff ]
=== added file utils/test/test-baserule.py
--- utils/test/test-baserule.py 2015-04-11 22:52:56.270968523 +0200
+++ utils/test/test-baserule.py 2015-04-11 22:51:35.361699045 +0200
@@ -0,0 +1,36 @@
+#! /usr/bin/env python
+# ------------------------------------------------------------------
+#
+# Copyright (C) 2015 Christian Boltz <apparmor at cboltz.de>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of version 2 of the GNU General Public
+# License published by the Free Software Foundation.
+#
+# ------------------------------------------------------------------
+
+import unittest
+from common_test import AATest, setup_all_loops
+
+from apparmor.common import AppArmorBug
+from apparmor.rule import BaseRule
+
+class TestBaserule(AATest):
+ def test_abstract__parse(self):
+ with self.assertRaises(AppArmorBug):
+ BaseRule._parse('foo')
+
+ def test_is_equal_localvars(self):
+ obj = BaseRule()
+ with self.assertRaises(AppArmorBug):
+ obj.is_equal_localvars(BaseRule())
+
+ def test_is_covered_localvars(self):
+ obj = BaseRule()
+ with self.assertRaises(AppArmorBug):
+ obj.is_covered_localvars(None)
+
+
+setup_all_loops(__name__)
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
Regards,
Christian Boltz
--
Jungchen, so jemand wie Du kommt hier immer mal wieder vorbei. Wir
füttern ihn ne Weile und dann binden wir ihn auf ner Raststätte an und
hoffen, dass ihn kein Tierheim aufnimmt ;) [Jan Trippler in suse-linux]
More information about the AppArmor
mailing list