def test(self):
        self.assertTrue("stve.picture" in self.service.keys())
        self.assertTrue(self.service["stve.picture"].version() != None)
        pic = self.service["stve.picture"].get()

        self.assertTrue(self.get("system.tmp") != None)
        L.info(os.path.join(self.get("system.tmp"), "test01.png"))
        pic.info(pic.open(os.path.join(self.get("system.tmp"), "test01.png")))
    def test(self):
        self.assertTrue("stve.picture" in self.service.keys())
        self.assertTrue(self.service["stve.picture"].version() != None)
        pic = self.service["stve.picture"].get()

        self.assertTrue(self.get("system.tmp") != None)
        reference = os.path.join(self.get("system.tmp"), "test01.png")
        target = os.path.join(self.get("system.tmp"), "test01_target01.png")
        point = pic.search_pattern(reference, target)
        self.assertTrue(point != None)
        L.info(point)
Esempio n. 3
0
    def test(self):
        self.assertTrue("stve.picture" in self.service.keys())
        self.assertTrue(self.service["stve.picture"].version() != None)
        pic = self.service["stve.picture"].get()

        self.assertTrue(self.get("system.tmp") != None)
        img = pic.open(os.path.join(self.get("system.tmp"), "test01.png"))
        self.assertTrue(img != None)
        rgb = pic.get_rgb(img)
        self.assertTrue(len(rgb) == 3)
        L.info(rgb)
Esempio n. 4
0
 def rm(self, filepath):
     if not type(filepath) in [str, unicode]:
         raise WorkspaceError("filepath must be strings.")
     if not os.path.exists(filepath):
         L.warning("it is not exists %s" % filepath)
     else:
         try:
             os.remove(filepath)
             return filepath
         except Exception as e:
             L.traceback()
             raise WorkspaceError("Can't remove file %s. Please Check File Permission." % filepath)
Esempio n. 5
0
    def test(self):
        self.assertTrue("stve.picture" in self.service.keys())
        self.assertTrue(self.service["stve.picture"].version() != None)
        pic = self.service["stve.picture"].get()

        self.assertTrue(self.get("system.tmp") != None)
        img = pic.open(os.path.join(self.get("system.tmp"), "test01.png"))
        self.assertTrue(img != None)
        binary_img = pic.binary(img)
        r,g,b = pic.get_rgb(binary_img)
        self.assertTrue(r == g)
        self.assertTrue(g == b)
        L.info("RGB (%s %s %s)" %(r, g, b))
Esempio n. 6
0
    def execute(self, script, host, v=2):
        if not os.path.exists(host):
            raise TestRunnerError("%s is not exists." % (host))
        sys.path.append(host)

        suite = unittest.TestSuite()
        loader = unittest.TestLoader()
        module = self.load(script, host)
        if not module:
            L.warning("Not loaded module : %s" % script)
            raise TestRunnerError("%s is not extended StveTestCase." % script)
        else: suite.addTest(loader.loadTestsFromModule(module))
        unittest.TextTestRunner(verbosity=v).run(suite)
Esempio n. 7
0
 def register(cls, host):
     if not os.path.exists(host):
         raise LibraryError("%s is not exists." % (host))
     for fdn in os.listdir(host):
         try:
             if fdn.endswith(".pyc") or fdn.endswith(".py"):
                 pass
             else:
                 sys.path.append(os.path.join(host, fdn))
                 f, n, d = imp.find_module("service")
                 module = imp.load_module("service", f, n, d)
                 cls.service[module.NAME] = module.FACTORY
                 sys.path.remove(os.path.join(host, fdn))
         except Exception as e:
             L.warning(str(e))
Esempio n. 8
0
 def __init__(self, path, clear=False):
     if not type(path) in [str, unicode]:
         raise WorkspaceError("path must be strings.")
     self.default_path = os.path.abspath(path)
     if os.path.exists(path):
         if len(os.listdir(path)) > 0:
             L.warning("It is not vacant folder in the path.")
             if clear:
                 try:
                     for f in os.listdir(path):
                         shutil.rmtree(os.path.join(path, f))
                 except Exception as e:
                     L.traceback()
                     raise WorkspaceError("it must be vacant folder in the path.")
     else:
         self._mkdir_recursive(self.default_path)
Esempio n. 9
0
    def test(self):
        self.assertTrue("stve.picture" in self.service.keys())
        self.assertTrue(self.service["stve.picture"].version() != None)
        pic = self.service["stve.picture"].get()

        self.assertTrue(self.get("system.tmp") != None)
        img = pic.open(os.path.join(self.get("system.tmp"), "test01.png"))
        self.assertTrue(img != None)
        opencv_img = pic.to_opencv(img)
        img2 = pic.to_pil(opencv_img)
        self.assertTrue(img2 != None)
        pic.save(img2, os.path.join(self.get("system.tmp"), "test02.png"))

        img3 = pic.open(os.path.join(self.get("system.tmp"), "test01.png"))
        self.assertTrue(img3 != None)
        L.info(pic.info(img3))
Esempio n. 10
0
    def execute_with_report(self, script, host, output):
        if not os.path.exists(host):
            raise TestRunnerError("%s is not exists." % (host))
        sys.path.append(host)

        if not os.path.exists(output):
            raise TestRunnerError("%s is not exists." % (output))

        suite = unittest.TestSuite()
        loader = unittest.TestLoader()
        module = self.load(script, host)
        if not module:
            L.warning("Not loaded module : %s" % script)
            raise TestRunnerError("%s is not extended StveTestCase." % script)
        else: suite.addTest(loader.loadTestsFromModule(module))
        xmlrunner.XMLTestRunner(output=output).run(suite)
Esempio n. 11
0
 def load(self, testcase, host):
     if testcase.find(".py") != -1:
         script = testcase
     else:
         script = testcase + ".py"
     path = os.path.join(host, script)
     if not os.path.exists(path):
         raise TestRunnerError("%s is not exists." % (path))
     name = script[:script.find(".")]
     L.debug("TestCase : %s" % path)
     try:
         if os.path.exists(path):
             f, n, d = imp.find_module(str(name))
             return imp.load_module(name, f, n, d)
         else:
             return False
     except ImportError as e:
         L.traceback()
         return False
Esempio n. 12
0
    def mkdir(self, folder, host="", clear=False):
        if not type(folder) in [str, unicode]:
            raise WorkspaceError("folder must be strings.")
        if host == "":
            path = os.path.join(self.root(), folder)
        else:
            if not os.path.exists(host): self._mkdir_recursive(host)
            path = os.path.join(host, folder)

        if os.path.exists(path):
            if len(os.listdir(path)) > 0:
                L.warning("It is not vacant folder in the path.")
                if clear:
                    try:
                        for f in os.listdir(path):
                            shutil.rmtree(os.path.join(path, f))
                    except Exception as e:
                        L.traceback()
                        raise WorkspaceError("it must be vacant folder in the path.")
        else:
            self._mkdir_recursive(path)
        return path
Esempio n. 13
0
    def rmdir(self, folder, host=""):
        if not type(folder) in [str, unicode]:
            raise WorkspaceError("folder must be strings.")

        if host == "":
            path = os.path.join(self.root(), folder)
        else:
            if not os.path.exists(host):
                L.warning("it is not exists %s" % host)
                return host
            path = os.path.join(host, folder)

        if not os.path.exists(path):
            L.warning("it is not exists %s" % path)
            return path
        else:
            try:
                shutil.rmtree(path); return path
            except Exception as e:
                L.traceback()
                raise WorkspaceError("Can't remove file %s. Please Check File Permission." % path)
Esempio n. 14
0
 def tearDownClass(cls):
     L.info("*** End TestCase     : %s *** " % __file__)
Esempio n. 15
0
 def test(self):
     self.assertTrue("stve.picture" in self.service.keys())
     self.assertTrue(self.service["stve.picture"].version() != None)
     L.info(self.service["stve.picture"].version())
Esempio n. 16
0
 def setUpClass(cls):
     L.info("*** Start TestCase   : %s *** " % __file__)
Esempio n. 17
0
 def tearDownClass(cls):
     L.info("*** End TestCase     : %s *** " % __file__)
Esempio n. 18
0
 def setUpClass(cls):
     L.info("*** Start TestCase   : %s *** " % __file__)
Esempio n. 19
0
 def test(self):
     self.assertTrue("stve.android" in self.service.keys())
     self.assertTrue(self.service["stve.android"].version() != None)
     L.info(self.service["stve.android"].version())
 def test(self):
     self.assertTrue("stve.picture" in self.service.keys())
     self.assertTrue(self.service["stve.picture"].version() != None)
     L.info(self.service["stve.picture"].version())
     pic = self.service["stve.picture"].get()
     self.assertTrue(pic != None)