Changeset - a6c5b87890ae
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 20 months ago 2023-05-24 20:14:30
drewp@bigasterisk.com
fix effect and fader tests
2 files changed with 22 insertions and 27 deletions:
0 comments (0 inline, 0 general)
light9/effect/effecteval_test.py
Show inline comments
 
import time
 
import unittest
 

	
 
from freezegun import freeze_time
 
from light9.effect.effecteval import EffectEval
 
from light9.effect.settings import BareEffectSettings, DeviceSettings, EffectSettings
 
from light9.effect.simple_outputs import SimpleOutputs
 
from rdflib import Namespace
 

	
 
from light9.collector.collector import Collector
 
from light9.collector.output import Output
 
from light9.collector.weblisteners import WebListeners
 
from light9.effect.effecteval import EffectEval2
 
from light9.effect.settings import DeviceSettings, EffectSettings
 
from light9.mock_syncedgraph import MockSyncedGraph
 
from light9.namespaces import DEV, L9
 
from light9.newtypes import (ClientSessionType, ClientType, DeviceAttr, DeviceUri, EffectAttr, EffectClass, HexColor, UnixTime)
 
from light9.newtypes import (DeviceAttr, DeviceUri, EffectAttr, EffectUri, HexColor)
 

	
 
PREFIX = '''
 
    @prefix : <http://light9.bigasterisk.com/> .
 
    @prefix dev: <http://light9.bigasterisk.com/device/> .
 
    @prefix effect: <http://light9.bigasterisk.com/effect/> .
 

	
 
'''
 

	
 
THEATER = '''
 

	
 
    :effectClass1 a :EffectClass .
 
#add light to here
 
THEATER = PREFIX + '''
 
    :effect1
 
        a :Effect;
 
        :effectFunction effect:scale;
 
        :input [ :effectAttr :strength ];
 
        :setting [ :device dev:light1; :deviceAttr :color; :value "#ff0000" ] .
 
'''
 
effectClass1 = EffectClass(L9['effectClass1'])
 
effect1 = EffectUri(L9['effect1'])
 

	
 

	
 
class TestEffectEval:
 

	
 
    def test_scalesColors(self):
 
        g = MockSyncedGraph(THEATER)
 
        so = SimpleOutputs(g)
 
        ee = EffectEval(g, effectClass1, so)
 
        s = BareEffectSettings(s={EffectAttr(L9['strength']): 0.5})
 
        ds,report = ee.outputFromEffect(s, songTime=0, noteTime=0)
 
        assert ds == DeviceSettings(g, [(DeviceUri(L9['light1']), DeviceAttr(L9['color']), HexColor('#888888'))])
 
        ee = EffectEval2(g, effect1)
 
        s = EffectSettings(g, [(effect1, EffectAttr(L9['strength']), 0.5)])
 
        ds = ee.compute(s)
 
        assert ds == DeviceSettings(g, [(DeviceUri(DEV['light1']), DeviceAttr(L9['color']), HexColor('#7f0000'))])
light9/effect/sequencer/eval_faders_test.py
Show inline comments
 
@@ -33,31 +33,33 @@ NOTE_GRAPH = PREFIXES + '''
 

	
 
            :light1
 
                a :SimpleDimmer;
 
                :dmxUniverse dmxA:;
 
                :dmxBase 178 .
 

	
 
            effect:effect1
 
                a :Effect;
 
                :setting effect:effect1_set1 .
 
            effect:effect1_set1
 
                :device :light1;
 
                :deviceAttr :brightness;
 
                :scaledValue 0.5 .
 
                :value 0.5 .
 
            :fade1
 
                a :Fader;
 
                :effectClass effect:effect1;
 
                :effectAttr :strength;
 
                :effect effect:effect1;
 
                :setting :fs1;
 
                :value 0.6 .
 
            :fs1 
 
                :effectAttr :strength .
 

	
 
        '''
 

	
 

	
 
class TestFaderEval:
 

	
 
    def test_faderValueScalesEffectSettings(self):
 
        g = MockSyncedGraph(NOTE_GRAPH)
 
        sender = mock.MagicMock()
 

	
 
        f = FaderEval(g, sender)
 
        f = FaderEval(g)
 
        devSettings = f.computeOutput()
 
        assert devSettings == DeviceSettings(g, [(L9['light1'], L9['brightness'], 0.3)])
 
\ No newline at end of file
0 comments (0 inline, 0 general)