diff --git a/test/__init__.py b/test/__init__.py index d768790fbd90e72d3efe46c08b9ae834299f5698..bbc6177aee6f3882ef61c8cdfb0de292f4f844d8 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -29,6 +29,7 @@ from test_isocheck import TestIsoCheck from test_localcheck import TestLocalCheck from test_repocheck import TestRepoCheck from test_util import TestUtil +from test_querylayerinlocal import TestQueryLayerInLocal if __name__ == "__main__": diff --git a/test/test_querylayerinlocal.py b/test/test_querylayerinlocal.py index 85cc2177ad97ef436a561b6437bcc2eb1f8c73ee..a5de30e6653997972b1e43853fa94438688173e5 100644 --- a/test/test_querylayerinlocal.py +++ b/test/test_querylayerinlocal.py @@ -13,7 +13,7 @@ # See the Mulan PSL v2 for more details. # ********************************************************************************** """ - +import os import unittest from src.rpmquery.querylayerinlocal import QueryLayerInLocal @@ -22,49 +22,45 @@ class TestQueryLayerInLocal(unittest.TestCase): def setUp(self): self._rpm = '/opt/kyclassifier/test.rpm' - self.isinit = True if self._init_querylayeriniso() else False + self.isinit = True if self._init_querylayerinlocal() else False - def _init_querylayeriniso(self): + def _init_querylayerinlocal(self): """ Try to init querylayerinlocal object Returns: bool """ try: - self.obj = QueryLayerInLocal(self._rpm,self._rpm) + self.obj = QueryLayerInLocal(self._rpm) return True except: return False + + def test_run(self): + if os.path.exists(self._rpm) is False: + self.skipTest("Test File not exists, test_check skiped!") + result = QueryLayerInLocal.run([self.obj.rpm]) + self.assertIsInstance(result, int, "Test QueryLayerInLocal.run failed!") - def test_get_rpm_layer(self): - pass - - def test_get_rpmdeps(self): - pass - def test_get_localpkgs_layer(self): - """ - Test class QueryLayerInLocal method _get_localpkgs_layer() - Returns: - dict - """ - if not self.isinit: - self.skipTest("QueryLayerInIso obj init failed,_get_localpkgs_layer test skiped!") - result = self.obj._get_localpkgs_laye() - self.assertIsInstance(result,dict,"_get_localpkgs_layer test failed!") - - def test_get_isofiles(self): - pass + def test_get_rpm_layer(self): + if self.isinit is False: + self.skipTest("Test initialize for QueryLayerInLocal unfinished, test_get_rpm_layer skiped!") + layer = self.obj.get_rpm_layer() + self.assertIsInstance(layer,int,"QueryLayerInLocal.get_rpm_layer check failed!") + def test_check(self): - pass + if os.path.exists(self._rpm) is False: + self.skipTest("Test File not exists, test_check skiped!") + result = QueryLayerInLocal.check(self.obj.rpm) + self.assertIsInstance(result,bool,"Test QueryLayerInLocal.check failed!") + def test_rpm(self): pass - def test_iso(self): - pass if __name__ == '__main__': - unittest.main(verbosity=2) \ No newline at end of file + unittest.main(verbosity=2)