-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_test_xml_files.py
More file actions
62 lines (50 loc) · 2.11 KB
/
example_test_xml_files.py
File metadata and controls
62 lines (50 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
Example test file - don't attempt to run this file directly.
This file contains examples for each of the XML files that can be part of a standard Indigo plugin. I do a little bit of
magic to get the path correct. The assumption is that your repo is constructed something like this:
MyPluginRepo/
tests/
shared/
test_xml_files.py # can be named anything
MyPlugin.indigoPlugin/
Contents/
Server Folder/
Actions.xml
Devices.xml
Events.xml
MenuItems.xml
PluginConfig.xml
You can of course just insert the correct path to the file your setup is different.
Of course, most plugins only use a subset of the config ui files, so you only need to test the ones that you use in your
plugin.
To run your tests, in Terminal run this test with:
> cd <path/to/repo/root/>
> python -m unittest test_xml.TestActionsXml
"""
import os
from .classes import APIBase, ValidateXmlFile
# Construct the path to the server plugin directory given the assumption above.
# This would result in a path like: /Users/me/MyPluginRepo/MyPlugin.indigoPlugin/Contents/Server Folder
# because the hardcoded path is relative to the location of this file and os.path.abspath() will adjust to make it
# the correct full path.
SERVER_PLUGIN_DIR_PATH = os.path.abspath(
os.path.join(
os.path.dirname(__file__),
"../MyPlugin.indigoPlugin/Contents/Server Plugin"
)
)
class TestDeviceXml(ValidateXmlFile, APIBase):
server_plugin_dir_path = SERVER_PLUGIN_DIR_PATH
file_name = "Devices.xml"
class TestActionsXml(ValidateXmlFile, APIBase):
server_plugin_dir_path = SERVER_PLUGIN_DIR_PATH
file_name = "Actions.xml"
class TestEventsXml(ValidateXmlFile, APIBase):
server_plugin_dir_path = SERVER_PLUGIN_DIR_PATH
file_name = "Events.xml"
class TestMenuItemsXml(ValidateXmlFile, APIBase):
server_plugin_dir_path = SERVER_PLUGIN_DIR_PATH
file_name = "MenuItems.xml"
class TestPluginConfigXml(ValidateXmlFile, APIBase):
server_plugin_dir_path = SERVER_PLUGIN_DIR_PATH
file_name = "PluginConfig.xml"