Пример #1
0
 def test_acquire(self):
     picture_name = "test.tiff"
     size = (1024, 1024)
     
     # change resolution
     try:
         # "Andor SimCam" contains a space, so cut the line ourselves
         cmdline = ["cli", "--set-attr", "Camera", "resolution", "%d,%d" % size]
         ret = main.main(cmdline)
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
     
     # acquire (simulated) image
     try:
         # "Andor SimCam" contains a space, so cut the line ourselves
         cmdline = ["cli", "--acquire", "Camera", "--output=%s" % picture_name]
         ret = main.main(cmdline)
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
     
     st = os.stat(picture_name) # this test also that the file is created
     self.assertGreater(st.st_size, 0)
     im = Image.open(picture_name)
     self.assertEqual(im.format, "TIFF")
     self.assertEqual(im.size, size)
Пример #2
0
 def test_check(self):
     try:
         cmdline = "cli --check"
         ret = main.main(cmdline.split())
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "Not detecting backend running")
Пример #3
0
 def test_error_scan(self):
     try:
         cmdline = "cli --scan bar.foo"
         ret = main.main(cmdline.split())
     except SystemExit as exc: # because it's handled by argparse
         ret = exc.code
     self.assertNotEqual(ret, 0, "Wrongly succeeded trying to run scan with unknown class: '%s'" % cmdline)
Пример #4
0
 def test_set_attr(self):
     # to read attribute power
     regex = re.compile("\spower\s.*value:\s*([.0-9]+)")
     
     # read before
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = ["cli", "--list-prop", "Light Engine"]
         ret = main.main(cmdline)
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
     
     output = out.getvalue()
     power = float(regex.search(output).group(1))
     self.assertGreaterEqual(power, 0, "power should be bigger than 0")   
     
     # set the new value
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = ["cli", "--set-attr", "Light Engine", "power", "0"]
         ret = main.main(cmdline)
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
     
     # read the new value
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = ["cli", "--list-prop", "Light Engine"]
         ret = main.main(cmdline)
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
     
     output = out.getvalue()
     power = float(regex.search(output).group(1))
     self.assertEqual(power, 0, "power should be 0")
Пример #5
0
 def test_error_command_line(self):
     """
     It checks handling when wrong number of argument is given
     """
     try:
         cmdline = "cli --set-attr light power"
         ret = main.main(cmdline.split())
     except SystemExit, exc: # because it's handled by argparse
         ret = exc.code
Пример #6
0
 def test_scan(self):
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = "cli --log-level=2 --scan"
         ret = main.main(cmdline.split())
     except SystemExit, exc:
         ret = exc.code
Пример #7
0
 def test_list_prop(self):
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = "cli --list-prop Spectra"
         ret = main.main(cmdline.split())
     except SystemExit, exc:
         ret = exc.code
Пример #8
0
 def test_error_command_line(self):
     """
     It checks handling when wrong number of argument is given
     """
     try:
         cmdline = "cli --set-attr light power"
         ret = main.main(cmdline.split())
     except SystemExit as exc: # because it's handled by argparse
         ret = exc.code
     self.assertNotEqual(ret, 0, "trying to run erroneous '%s'" % cmdline)
Пример #9
0
 def test_stop(self):
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = "cli --stop"
         ret = main.main(cmdline.split())
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
Пример #10
0
 def test_acquire(self):
     picture_name = "test.tiff"
     size = (1024, 1024)
     
     # change resolution
     try:
         # "Andor SimCam" contains a space, so use \t as delimiter
         cmdline = "cli\t--set-attr\tAndor SimCam\tresolution\t%d,%d" % size
         ret = main.main(cmdline.split("\t"))
     except SystemExit, exc:
         ret = exc.code
Пример #11
0
 def test_set_attr_dict(self):
     # set a dict, which is a bit complicated structure
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = "cli --set-attr OLStage speed x:0.5,y:0.2"
         ret = main.main(cmdline.split())
     except SystemExit, exc:
         ret = exc.code
Пример #12
0
    def test_position(self):
        try:
            # change the stdout
            out = StringIO.StringIO()
            sys.stdout = out

            cmdline = ["cli", "--position", "Sample Stage", "x", "50e-6"]
            ret = main.main(cmdline)
        except SystemExit as exc:
            ret = exc.code
        self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
Пример #13
0
 def test_set_attr_dict(self):
     # set a dict, which is a bit complicated structure
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = ["cli", "--set-attr", "Sample Stage", "speed", "x: 0.5, y: 0.2"]
         ret = main.main(cmdline)
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
Пример #14
0
 def test_move(self):
     # TODO compare position VA
     # test move and also multiple move requests
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = "cli --move OLStage x 5 --move OLStage y -0.2"
         ret = main.main(cmdline.split())
     except SystemExit, exc:
         ret = exc.code
Пример #15
0
 def test_help(self):
     """
     It checks handling help option
     """
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = "cli --help"
         ret = main.main(cmdline.split())
     except SystemExit, exc:
         ret = exc.code
Пример #16
0
    def test_reference(self):
        # On this simulated hardware, no component supports referencing, so
        # just check that referencing correctly reports this
        try:
            # change the stdout
            out = StringIO.StringIO()
            sys.stdout = out

            cmdline = ["cli", "--reference", "Sample Stage", "x"]
            ret = main.main(cmdline)
        except SystemExit as exc:
            ret = exc.code
        self.assertNotEqual(ret, 0, "Referencing should have failed with '%s'" % cmdline)
Пример #17
0
 def test_move(self):
     # TODO compare position VA
     # test move and also multiple move requests
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = ["cli", "--move", "Sample Stage", "x", "5", "--move", "Sample Stage", "y", "-0.2"]
         ret = main.main(cmdline)
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
Пример #18
0
 def test_set_attr(self):
     # to read attribute power
     regex = re.compile("\spower\s.*value:\s*([.0-9]+)")
     
     # read before
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = "cli --list-prop Spectra"
         ret = main.main(cmdline.split())
     except SystemExit, exc:
         ret = exc.code
Пример #19
0
 def test_list(self):
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = "cli --list"
         ret = main.main(cmdline.split())
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
     
     output = out.getvalue()
     self.assertTrue("Light Engine" in output)
     self.assertTrue("Camera" in output)
Пример #20
0
 def test_list_prop(self):
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = ["cli", "--list-prop", "Light Engine"]
         ret = main.main(cmdline)
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
     
     output = out.getvalue()
     self.assertTrue("role" in output)
     self.assertTrue("swVersion" in output)
     self.assertTrue("power" in output)
Пример #21
0
    def test_scan(self):
        try:
            # change the stdout
            out = StringIO.StringIO()
            sys.stdout = out
            
            cmdline = "cli --log-level=2 --scan"
            ret = main.main(cmdline.split())
        except SystemExit as exc:
            ret = exc.code
        self.assertEqual(ret, 0, "trying to run '%s' returned %s" % (cmdline, ret))
        
        output = out.getvalue()
        # AndorCam3 SimCam should be there for sure (if libandor3-dev is installed)
        # self.assertTrue("andorcam3.AndorCam3" in output)

        self.assertTrue("andorcam2.FakeAndorCam2" in output)
Пример #22
0
 def test_help(self):
     """
     It checks handling help option
     """
     try:
         # change the stdout
         out = StringIO.StringIO()
         sys.stdout = out
         
         cmdline = "cli --help"
         ret = main.main(cmdline.split())
     except SystemExit as exc:
         ret = exc.code
     self.assertEqual(ret, 0, "trying to run '%s' returned %s" % (cmdline, ret))
     
     output = out.getvalue()
     self.assertTrue("optional arguments" in output)
Пример #23
0
 except SystemExit, exc:
     ret = exc.code
 self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
 
 output = out.getvalue()
 power = float(regex.search(output).group(1))
 self.assertGreaterEqual(power, 0, "power should be bigger than 0")   
 
 # set the new value
 try:
     # change the stdout
     out = StringIO.StringIO()
     sys.stdout = out
     
     cmdline = "cli --set-attr Spectra power 0"
     ret = main.main(cmdline.split())
 except SystemExit, exc:
     ret = exc.code
 self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
 
 # read the new value
 try:
     # change the stdout
     out = StringIO.StringIO()
     sys.stdout = out
     
     cmdline = "cli --list-prop Spectra"
     ret = main.main(cmdline.split())
 except SystemExit, exc:
     ret = exc.code
 self.assertEqual(ret, 0, "trying to run '%s'" % cmdline)
Пример #24
0
 def test_error_scan(self):
     try:
         cmdline = "cli --scan bar.foo"
         ret = main.main(cmdline.split())
     except SystemExit, exc: # because it's handled by argparse
         ret = exc.code
Пример #25
0
 def test_check(self):
     try:
         cmdline = "cli --check"
         ret = main.main(cmdline.split())
     except SystemExit, exc:
         ret = exc.code