-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
icons, fixes, cleanups, initial testing clobber
- Loading branch information
1 parent
779e43a
commit 585e99d
Showing
15 changed files
with
269 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
''' | ||
XML Snippets for building valid QXW files for testing. | ||
Structure: | ||
header | ||
engine_header | ||
<Any Fixtures you want to use> | ||
<Any Functions you want to use> | ||
engine_footer | ||
virtual_console (default is empty_virtual_console) | ||
simple_desk (default is empty_simple_desk) | ||
footer | ||
''' | ||
|
||
header = '''<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE Workspace> | ||
<Workspace xmlns="http://www.qlcplus.org/Workspace" CurrentWindow="FixtureManager"> | ||
<Creator> | ||
<Name>Q Light Controller Plus</Name> | ||
<Version>4.12.0</Version> | ||
<Author>daniel.fairhead</Author> | ||
</Creator> | ||
''' | ||
engine_header = '''<Engine> | ||
<InputOutputMap> | ||
<Universe Name="Universe 1" ID="0"> | ||
<Output Plugin="E1.31" Line="1"> | ||
<PluginParameters UniverseChannels="363"/> | ||
</Output> | ||
</Universe> | ||
<Universe Name="Universe 2" ID="1"/> | ||
<Universe Name="Universe 3" ID="2"/> | ||
<Universe Name="Universe 4" ID="3"/> | ||
</InputOutputMap> | ||
''' | ||
|
||
engine_footer = '</Engine>' | ||
|
||
footer = ''' | ||
</Workspace> | ||
''' | ||
|
||
empty_virtual_console = ''' | ||
<VirtualConsole> | ||
<Frame Caption=""> | ||
<Appearance> | ||
<FrameStyle>None</FrameStyle> | ||
<ForegroundColor>Default</ForegroundColor> | ||
<BackgroundColor>Default</BackgroundColor> | ||
<BackgroundImage>None</BackgroundImage> | ||
<Font>Default</Font> | ||
</Appearance> | ||
</Frame> | ||
<Properties> | ||
<Size Width="1920" Height="1080"/> | ||
<GrandMaster ChannelMode="Intensity" ValueMode="Reduce" SliderMode="Normal"/> | ||
</Properties> | ||
</VirtualConsole> | ||
''' | ||
|
||
empty_simple_desk = ''' | ||
<SimpleDesk> | ||
<Engine/> | ||
</SimpleDesk> | ||
''' | ||
|
||
def generic_fixture(uid, address, channels=1, universe=0, name=None): | ||
return ''' | ||
<Fixture> | ||
<Manufacturer>Generic</Manufacturer> | ||
<Model>Generic</Model> | ||
<Mode>1 Channel</Mode> | ||
<ID>{uid}</ID> | ||
<Name>{name}</Name> | ||
<Universe>{universe}</Universe> | ||
<Address>{address}</Address> | ||
<Channels>{channels}</Channels> | ||
</Fixture> | ||
'''.format(uid=uid, address=address, universe=universe, channels=channels, | ||
name=name or 'Dimmer %i' % uid) | ||
|
||
def function_scene(uid, name, path=""): | ||
return '''<Function ID="{uid}" Type="Scene" Name="{name}" Path="{path}"> | ||
<Speed FadeIn="0" FadeOut="0" Duration="0"/> | ||
</Function>'''.format(uid=uid, name=name, path=path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
import xml.etree.ElementTree as ET | ||
from io import StringIO | ||
|
||
from unittest import TestCase | ||
|
||
from reader import NS, QLCFile | ||
import snippets | ||
|
||
class BasicFileTest(TestCase): | ||
def setUp(self): | ||
super().setUp() | ||
self.virtual_console = snippets.empty_virtual_console | ||
self.simple_desk = snippets.empty_simple_desk | ||
self.fixtures = [] | ||
self.functions = [] | ||
|
||
def get_xml(self): | ||
return '\n'.join(( | ||
snippets.header, | ||
snippets.engine_header, | ||
'\n'.join(self.fixtures), | ||
'\n'.join(self.functions), | ||
snippets.engine_footer, | ||
self.virtual_console, | ||
self.simple_desk, | ||
snippets.footer)) | ||
|
||
|
||
class SanityTest(BasicFileTest): | ||
def test_basicfile(self): | ||
x = StringIO(self.get_xml()) | ||
r = ET.parse(x).getroot() | ||
|
||
# TODO: callout to actual QLC+ to load the file and check it | ||
|
||
def test_some_fixtures(self): | ||
self.fixtures = [ | ||
snippets.generic_fixture(0, 1), | ||
snippets.generic_fixture(1, 2), | ||
snippets.generic_fixture(2, 3, channels=6), | ||
] | ||
|
||
x = StringIO(self.get_xml()) | ||
r = ET.parse(x).getroot() | ||
|
||
def test_some_functions(self): | ||
self.functions = [ | ||
snippets.function_scene(0, "Basic Scene"), | ||
snippets.function_scene(1, "Basic Scene 1"), | ||
snippets.function_scene(2, "Basic Scene 2"), | ||
] | ||
x = StringIO(self.get_xml()) | ||
r = ET.parse(x).getroot() | ||
|
||
def test_some_fixtures_and_functions(self): | ||
self.fixtures = [ | ||
snippets.generic_fixture(0, 1), | ||
snippets.generic_fixture(1, 2), | ||
snippets.generic_fixture(2, 3, channels=6), | ||
] | ||
|
||
self.functions = [ | ||
snippets.function_scene(0, "Basic Scene"), | ||
snippets.function_scene(1, "Basic Scene 1"), | ||
snippets.function_scene(2, "Basic Scene 2"), | ||
] | ||
|
||
x = StringIO(self.get_xml()) | ||
r = ET.parse(x).getroot() | ||
|
||
# TODO: Functions USING fixtures... | ||
|
||
################################## | ||
|
||
class TestCopyingSimpleScene(BasicFileTest): | ||
def test_copy_to_blank_file(self): | ||
self.functions = [] | ||
empty_file = QLCFile(StringIO(self.get_xml())) | ||
|
||
self.functions = [ | ||
snippets.function_scene(0, "Basic Scene"), | ||
snippets.function_scene(1, "Basic Scene 1"), | ||
snippets.function_scene(2, "Basic Scene 2"), | ||
] | ||
|
||
full_file = QLCFile(StringIO(self.get_xml())) | ||
|
||
clipboard = list(full_file.iter_functions_for_clipboard(['0','1','2'])) | ||
empty_file.paste_functions_here(clipboard) | ||
|
||
new_functions = empty_file.list_functions() | ||
self.assertEqual(new_functions[0].attrib["Name"], "Basic Scene") | ||
self.assertEqual(new_functions[1].attrib["Name"], "Basic Scene 1") | ||
self.assertEqual(new_functions[2].attrib["Name"], "Basic Scene 2") | ||
|
||
self.assertEqual(new_functions[0].attrib["ID"], "0") | ||
self.assertEqual(new_functions[1].attrib["ID"], "1") | ||
self.assertEqual(new_functions[2].attrib["ID"], "2") | ||
|
||
def test_copy_to_nonempty_file(self): | ||
|
||
self.functions = [ | ||
snippets.function_scene(0, "Basic Scene"), | ||
snippets.function_scene(1, "Basic Scene 1"), | ||
snippets.function_scene(2, "Basic Scene 2"), | ||
] | ||
|
||
to_file = QLCFile(StringIO(self.get_xml())) | ||
|
||
self.functions = [ | ||
snippets.function_scene(0, "Basic Scene A"), | ||
snippets.function_scene(1, "Basic Scene B"), | ||
snippets.function_scene(2, "Basic Scene C"), | ||
] | ||
|
||
from_file = QLCFile(StringIO(self.get_xml())) | ||
|
||
clipboard = list(from_file.iter_functions_for_clipboard(['0','1','2'])) | ||
to_file.paste_functions_here(clipboard) | ||
|
||
new_functions = to_file.list_functions() | ||
self.assertEqual(len(new_functions), 6) | ||
self.assertEqual(new_functions[0].attrib["Name"], "Basic Scene") | ||
self.assertEqual(new_functions[1].attrib["Name"], "Basic Scene 1") | ||
self.assertEqual(new_functions[2].attrib["Name"], "Basic Scene 2") | ||
self.assertEqual(new_functions[3].attrib["Name"], "Basic Scene A") | ||
self.assertEqual(new_functions[4].attrib["Name"], "Basic Scene B") | ||
self.assertEqual(new_functions[5].attrib["Name"], "Basic Scene C") | ||
|
||
|
||
self.assertEqual(new_functions[0].attrib["ID"], "0") | ||
self.assertEqual(new_functions[1].attrib["ID"], "1") | ||
self.assertEqual(new_functions[2].attrib["ID"], "2") | ||
self.assertEqual(new_functions[3].attrib["ID"], "3") | ||
self.assertEqual(new_functions[4].attrib["ID"], "4") | ||
self.assertEqual(new_functions[5].attrib["ID"], "5") | ||
|
||
|
||
|
||
|
||
|
||
|