def test_3dl_preset(self):
        """ Test 3dl preset

        """
        preset = presets.get_default_preset()
        # test type must be 3D
        self.failUnlessRaises(presets.PresetException,
                              THREEDL_HELPER.check_preset,
                              preset
                              )
        preset[presets.TYPE] = '3D'
        # test shaper attr exists
        self.failUnlessRaises(presets.PresetException,
                              THREEDL_HELPER.check_preset,
                              preset
                              )
        preset[SHAPER] = True
        # test mesh attr exists
        self.failUnlessRaises(presets.PresetException,
                              THREEDL_HELPER.check_preset,
                              preset
                              )
        preset[MESH] = True
        # test preset is ok
        THREEDL_HELPER.check_preset(preset)
        # test ranges are int
        outlutfile = os.path.join(self.tmp_dir, "test.3dl")
        self.failUnlessRaises(PresetException,
                              THREEDL_HELPER.write_3d_lut,
                              self.processor_3d.applyRGB,
                              outlutfile,
                              preset)
    def test_check_attributes(self):
        """ Test preset check function

        """
        outlutfile = os.path.join(self.tmp_dir, "test.cube")
        default_preset = presets.get_default_preset()
        CUBE_HELPER.check_preset(default_preset)
        # test missing attr
        cust_preset = {}
        self.failUnlessRaises(presets.PresetException,
                              CUBE_HELPER.check_preset, cust_preset)
        for attr in presets.BASIC_ATTRS:
            cust_preset[attr] = default_preset[attr]
            self.failUnlessRaises(presets.PresetException,
                              CUBE_HELPER.check_preset, cust_preset)
        ## test specific attr
        # change type to 1D
        cust_preset[presets.TYPE] = '1D'
        self.failUnlessRaises(presets.PresetException,
                              CUBE_HELPER.check_preset, cust_preset)
        cust_preset[presets.OUT_BITDEPTH] = 12
        CUBE_HELPER.check_preset(cust_preset)
        # try to write a 3D LUT with a 1D preset
        self.failUnlessRaises(alh.AbstractLUTException,
                              CUBE_HELPER.write_3d_lut,
                              self.processor_1d,
                              outlutfile,
                              cust_preset)
        # change type to 2D
        cust_preset[presets.TYPE] = '3D'
        self.failUnlessRaises(presets.PresetException,
                              CUBE_HELPER.check_preset, cust_preset)
        cust_preset[presets.CUBE_SIZE] = 17
        CUBE_HELPER.check_preset(cust_preset)
        # try to write a 1D LUT with a 3D preset
        self.failUnlessRaises(alh.AbstractLUTException,
                              CUBE_HELPER.write_1d_lut,
                              self.processor_1d,
                              outlutfile,
                              cust_preset)
        # # test value type
        # cube size
        cust_preset[presets.CUBE_SIZE] = presets.CUBE_SIZE_MAX_VALUE + 1
        self.failUnlessRaises(presets.PresetException,
                              CUBE_HELPER.check_preset, cust_preset)
        cust_preset[presets.CUBE_SIZE] = default_preset[presets.CUBE_SIZE]
        # range
        tests = 'test', ['a', 'a'], [0.0, 0.5, 1.0], 0.1
        for test in tests:
            cust_preset[presets.IN_RANGE] = test
            self.failUnlessRaises(presets.PresetException,
                                  CUBE_HELPER.check_preset,
                                  cust_preset)
        cust_preset[presets.IN_RANGE] = 0.1, 1
        CUBE_HELPER.check_preset(cust_preset)
        cust_preset[presets.IN_RANGE] = (0.1, 1)
        CUBE_HELPER.check_preset(cust_preset)