Exemplo n.º 1
0
    def setUp(self):
        injection.configure()
        settings.use_base({
            'log_to_console': True,
            'single_light_discover': True,
            'use_fakes': True
        }).configure()
        fake_lifx.configure()
        light_set.configure()

        self._group0 = 'Group 0'
        self._group1 = 'Group 1'
        self._group2 = 'Group 2'

        self._location0 = 'Location 0'
        self._location1 = 'Location 1'
        self._location2 = 'Location 2'

        self._light0 = 'Light 0'
        self._light1 = 'Light 1'
        self._light2 = 'Light 2'
        self._light3 = 'Light 3'

        self._color = [1, 2, 3, 4]
        lifx = injection.provide(i_controller.Lifx)
        lifx.init_from([
            (self._light0, self._group0, self._location0, self._color, False),
            (self._light1, self._group0, self._location1, self._color, False),
            (self._light2, self._group1, self._location0, self._color, False),
            (self._light3, self._group1, self._location1, self._color, False)
        ])
Exemplo n.º 2
0
    def test_refresh(self):
        tested_set = light_set.LightSet()
        tested_set.discover()

        fake_lifx.using([
            (self._light0, self._group0, self._location0, self._color, False),
            (self._light1, self._group0, self._location1, self._color, False),
            (self._light2, self._group0, self._location1, self._color, False),
            (self._light3, self._group2, self._location0, self._color, False)
        ]).configure()
        light_set.configure()

        tested_set.refresh()
        self.assertEqual(len(tested_set.light_names), 4)
        self.assertEqual(len(tested_set.group_names), 2)
        self.assertEqual(len(tested_set.location_names), 2)

        group = tested_set.get_group(self._group0)
        self._assert_names_match(
            group, self._light0, self._light1, self._light2)
        self.assertIsNone(tested_set.get_group(self._group1))
        group = tested_set.get_group(self._group2)
        self._assert_names_match(group, self._light3)

        location = tested_set.get_location(self._location0)
        self._assert_names_match(location, self._light0, self._light3)
        location = tested_set.get_location(self._location1)
        self._assert_names_match(location, self._light1, self._light2)
Exemplo n.º 3
0
    def test_nested_break(self):
        light_set.configure()
        script = """
            units raw hue 100 saturation 200 brightness 300 kelvin 400
            assign i 0
            repeat begin
                if {i >= 2}
                    break
                hue i
                set all
                assign i {i + 1}

                assign j 1000
                repeat begin
                    if {j > 1002}
                        break
                    hue j
                    set all
                    assign j {j + 1}
                end
            end
        """
        self._runner.run_script(script)
        self._runner.check_global_call_list([
            (Action.SET_COLOR, ([0, 200, 300, 400], 0.0)),
            (Action.SET_COLOR, ([1000, 200, 300, 400], 0.0)),
            (Action.SET_COLOR, ([1001, 200, 300, 400], 0.0)),
            (Action.SET_COLOR, ([1002, 200, 300, 400], 0.0)),
            (Action.SET_COLOR, ([1, 200, 300, 400], 0.0)),
            (Action.SET_COLOR, ([1000, 200, 300, 400], 0.0)),
            (Action.SET_COLOR, ([1001, 200, 300, 400], 0.0)),
            (Action.SET_COLOR, ([1002, 200, 300, 400], 0.0))
        ])
Exemplo n.º 4
0
    def setUp(self):
        injection.configure()
        settings.using({
            'log_to_console': True,
            'single_light_discover': True,
            'use_fakes': True
        }).configure()

        self._group0 = 'Group 0'
        self._group1 = 'Group 1'
        self._group2 = 'Group 2'

        self._location0 = 'Location 0'
        self._location1 = 'Location 1'
        self._location2 = 'Location 2'

        self._light0 = 'Light 0'
        self._light1 = 'Light 1'
        self._light2 = 'Light 2'
        self._light3 = 'Light 3'

        self._color = [1, 2, 3, 4]
        fake_lifx.using([
            (self._light0, self._group0, self._location0, self._color, False),
            (self._light1, self._group0, self._location1, self._color, False),
            (self._light2, self._group1, self._location0, self._color, False),
            (self._light3, self._group1, self._location1, self._color, False)
        ]).configure()
        light_set.configure()
Exemplo n.º 5
0
 def _make_light_set():
     color = [1, 2, 3, 4]
     fake_lifx.using([
         ('light_01', 'x', 'y', color, False),
         ('light_02', 'group', 'loc', color, False),
         ('light_00', 'group', 'loc', color, False)
     ]).configure()
     light_set.configure()
Exemplo n.º 6
0
def configure():
    injection.configure()
    settings.use_base({
        'log_level': logging.ERROR,
        'log_to_console': True,
        'single_light_discover': True,
        'use_fakes': True
    }).configure()
    log_config.configure()
    fake_clock.configure()
    fake_lifx.configure()
    light_set.configure()
Exemplo n.º 7
0
    def test_mixture(self):
        fake_lifx.using_large_set().configure()
        light_set.configure()

        script = """
            hue 180 saturation 50 brightness 50 kelvin 1000

            repeat in "Table" and group "Pole" and "Chair"
            and location "Home" as the_light
            begin
                set the_light
            end
        """
        self._runner.run_script(script)
        self._runner.check_call_list(
            ('Top', 'Middle', 'Bottom', 'Table', 'Chair'),
            [(Action.SET_COLOR, ([32768, 32768, 32768, 1000], 0))] * 2)
Exemplo n.º 8
0
    def test_all_groups(self):
        script = """
            hue 180 saturation 50 brightness 50 kelvin 1000

            repeat group as grp with brt from 0 to 100
            begin
                brightness brt
                set group grp
            end
        """
        fake_lifx.using_large_set().configure()
        light_set.configure()
        self._runner.run_script(script)
        self._runner.check_call_list(
            ('Chair', 'Strip', 'Table'),
            (Action.SET_COLOR, ([32768, 32768, 0, 1000], 0)))
        self._runner.check_call_list(
            ('Bottom', 'Middle', 'Top'),
            (Action.SET_COLOR, ([32768, 32768, 65535, 1000], 0)))
Exemplo n.º 9
0
    def setUp(self):
        test_module.configure()

        self._group0 = 'Group 0'
        self._group1 = 'Group 1'

        self._location0 = 'Location 0'
        self._location1 = 'Location 1'

        self._colors = [[4, 8, 12, 16], [24, 28, 32, 36], [44, 48, 52, 56],
                        [64, 68, 72, 76]]
        self._names = ["Test g1 l1", "Test g1 l2", "Test g2 l1", "Test g2 l2"]

        fake_lifx.using([
            (self._names[0], self._group0, self._location0, self._colors[0]),
            (self._names[1], self._group0, self._location1, self._colors[1]),
            (self._names[2], self._group1, self._location0, self._colors[2]),
            (self._names[3], self._group1, self._location1, self._colors[3])
        ]).configure()
        light_set.configure()
Exemplo n.º 10
0
 def setUp(self):
     test_module.configure()
     fake_lifx.using_small_set().configure()
     light_set.configure()
     self._runner = ScriptRunner(self)