예제 #1
0
 def test_valid_visible_if_menu_options(self):
     # does not raise
     validate_module_spec(
         {
             "id_name": "id",
             "name": "Name",
             "category": "Clean",
             "parameters": [
                 {
                     "id_name": "a",
                     "type": "string",
                     "visible_if": {"id_name": "b", "value": ["a", "b"]},
                 },
                 {
                     "id_name": "b",
                     "type": "menu",
                     "options": [
                         {"value": "a", "label": "A"},
                         "separator",
                         {"value": "b", "label": "B"},
                         {"value": "c", "label": "C"},
                     ],
                 },
             ],
         }
     )
예제 #2
0
 def test_validate_gdrivefile_invalid_secret(self):
     with self.assertRaisesRegex(
             ValueError,
             "Param 'b' 'secret_parameter' does not refer to a 'google'"):
         validate_module_spec({
             'id_name':
             'id',
             'name':
             'Name',
             'category':
             'Clean',
             'parameters': [
                 {
                     'id_name': 'a',
                     'type': 'secret',
                     'secret_logic': {
                         'provider': 'oauth',
                         'service': 'twitter',
                         'name': 'Connect',
                     },
                 },
                 {
                     'id_name': 'b',
                     'type': 'gdrivefile',
                     'secret_parameter': 'a',
                 },
             ],
         })
예제 #3
0
 def test_invalid_visible_if_menu_options(self):
     with self.assertRaisesRegex(
         ValueError, "Param 'a' has visible_if values \\{'x'\\} not in 'b' options"
     ):
         validate_module_spec(
             {
                 "id_name": "id",
                 "name": "Name",
                 "category": "Clean",
                 "parameters": [
                     {
                         "id_name": "a",
                         "type": "string",
                         "visible_if": {"id_name": "b", "value": ["a", "x"]},
                     },
                     {
                         "id_name": "b",
                         "type": "menu",
                         "options": [
                             {"value": "a", "label": "A"},
                             {"value": "c", "label": "C"},
                         ],
                     },
                 ],
             }
         )
예제 #4
0
 def test_validate_menu_invalid_default(self):
     with self.assertRaisesRegex(
             ValueError,
             "Param 'a' has a 'default' that is not in its 'options'"):
         validate_module_spec({
             'id_name':
             'id',
             'name':
             'Name',
             'category':
             'Clean',
             'parameters': [
                 {
                     'id_name': 'a',
                     'type': 'menu',
                     'options': [
                         {
                             'value': 'x',
                             'label': 'X'
                         },
                     ],
                     'default': 'y',
                 },
                 {
                     # Previously, we gave the wrong id_name
                     'id_name': 'not-a',
                     'type': 'string'
                 },
             ],
         })
예제 #5
0
 def test_valid_deprecated_visible_if_menu_options(self):
     # does not raise
     validate_module_spec({
         'id_name':
         'id',
         'name':
         'Name',
         'category':
         'Clean',
         'parameters': [
             {
                 'id_name': 'a',
                 'type': 'string',
                 # deprecated: use '|' to show valid options
                 'visible_if': {
                     'id_name': 'b',
                     'value': 'a|b'
                 },
             },
             {
                 'id_name': 'b',
                 'type': 'menu',
                 'menu_items': 'a||b|c',
             }
         ],
     })
예제 #6
0
 def test_missing_radio_options(self):
     with self.assertRaises(ValueError):
         validate_module_spec(
             {
                 "id_name": "id",
                 "name": "Name",
                 "category": "Clean",
                 "parameters": [{"id_name": "radio", "type": "radio"}],
             }
         )
예제 #7
0
 def test_multicolumn_tab_parameter(self):
     # does not raise
     validate_module_spec(
         {
             "id_name": "id",
             "name": "Name",
             "category": "Clean",
             "parameters": [
                 {"id_name": "a", "type": "column", "tab_parameter": "b"},
                 {"id_name": "b", "type": "tab"},
             ],
         }
     )
예제 #8
0
 def test_validate_gdrivefile_missing_secret(self):
     with self.assertRaisesRegex(
         ValueError, "Param 'b' has a 'secret_parameter' that is not a 'secret'"
     ):
         validate_module_spec(
             {
                 "id_name": "id",
                 "name": "Name",
                 "category": "Clean",
                 "parameters": [
                     {"id_name": "b", "type": "gdrivefile", "secret_parameter": "a"}
                 ],
             }
         )
예제 #9
0
 def test_unique_params(self):
     with self.assertRaisesRegex(ValueError, "Param 'dup' appears twice"):
         validate_module_spec(
             {
                 "id_name": "id",
                 "name": "Name",
                 "category": "Clean",
                 "parameters": [
                     {"id_name": "dup", "type": "string"},
                     {"id_name": "original", "type": "string"},
                     {"id_name": "dup", "type": "string"},
                 ],
             }
         )
예제 #10
0
    def test_schema_errors(self):
        with self.assertRaises(ValueError) as cm:
            validate_module_spec(
                {
                    "name": "Hello",
                    "link": "not a link at all",
                    "loads_data": "NotABoolean",
                    "parameters": [],
                }
            )

        self.assertRegex(str(cm.exception), "'id_name' is a required property")
        self.assertRegex(str(cm.exception), "'category' is a required property")
        self.assertRegex(str(cm.exception), "'not a link at all' is not a 'uri'")
        self.assertRegex(str(cm.exception), "'NotABoolean' is not of type 'boolean'")
예제 #11
0
 def test_multicolumn_non_tab_parameter(self):
     with self.assertRaisesRegex(
         ValueError, "Param 'a' has a 'tab_parameter' that is not a 'tab'"
     ):
         validate_module_spec(
             {
                 "id_name": "id",
                 "name": "Name",
                 "category": "Clean",
                 "parameters": [
                     {"id_name": "a", "type": "column", "tab_parameter": "b"},
                     {"id_name": "b", "type": "string"},  # Not a 'tab'
                 ],
             }
         )
예제 #12
0
 def test_missing_menu_items(self):
     with self.assertRaises(ValueError):
         validate_module_spec({
             'id_name':
             'id',
             'name':
             'Name',
             'category':
             'Clean',
             'parameters': [
                 {
                     'id_name': 'menu',
                     'type': 'menu'
                 },
             ],
         })
예제 #13
0
 def test_missing_radio_options(self):
     with self.assertRaises(ValueError):
         validate_module_spec({
             'id_name':
             'id',
             'name':
             'Name',
             'category':
             'Clean',
             'parameters': [
                 {
                     'id_name': 'radio',
                     'type': 'radio'
                 },
             ],
         })
예제 #14
0
    def test_schema_errors(self):
        with self.assertRaises(ValueError) as cm:
            validate_module_spec({
                'name': 'Hello',
                'link': 'not a link at all',
                'loads_data': 'NotABoolean',
                'parameters': []
            })

        self.assertRegex(str(cm.exception), "'id_name' is a required property")
        self.assertRegex(str(cm.exception),
                         "'category' is a required property")
        self.assertRegex(str(cm.exception),
                         "'not a link at all' is not a 'uri'")
        self.assertRegex(str(cm.exception),
                         "'NotABoolean' is not of type 'boolean'")
예제 #15
0
 def test_valid_visible_if(self):
     # does not raise
     validate_module_spec(
         {
             "id_name": "id",
             "name": "Name",
             "category": "Clean",
             "parameters": [
                 {
                     "id_name": "a",
                     "type": "string",
                     "visible_if": {"id_name": "b", "value": True},
                 },
                 {"id_name": "b", "type": "string"},
             ],
         }
     )
예제 #16
0
 def test_multicolumn_missing_tab_parameter(self):
     with self.assertRaisesRegex(
             ValueError,
             "Param 'a' has a 'tab_parameter' that is not in 'parameters'"):
         validate_module_spec({
             'id_name':
             'id',
             'name':
             'Name',
             'category':
             'Clean',
             'parameters': [{
                 'id_name': 'a',
                 'type': 'column',
                 'tab_parameter': 'b',  # does not exist
             }],
         })
예제 #17
0
 def test_invalid_visible_if(self):
     with self.assertRaisesRegex(
         ValueError, "Param 'a' has visible_if id_name 'b', which does not exist"
     ):
         validate_module_spec(
             {
                 "id_name": "id",
                 "name": "Name",
                 "category": "Clean",
                 "parameters": [
                     {
                         "id_name": "a",
                         "type": "string",
                         "visible_if": {"id_name": "b", "value": True},
                     }
                 ],
             }
         )
예제 #18
0
 def test_multicolumn_missing_tab_parameter(self):
     with self.assertRaisesRegex(
         ValueError, "Param 'a' has a 'tab_parameter' that is not in 'parameters'"
     ):
         validate_module_spec(
             {
                 "id_name": "id",
                 "name": "Name",
                 "category": "Clean",
                 "parameters": [
                     {
                         "id_name": "a",
                         "type": "column",
                         "tab_parameter": "b",  # does not exist
                     }
                 ],
             }
         )
예제 #19
0
 def test_validate_deprecated_menu(self):
     # does not raise
     validate_module_spec({
         'id_name':
         'id',
         'name':
         'Name',
         'category':
         'Clean',
         'parameters': [
             {
                 'id_name': 'a',
                 'type': 'menu',
                 'menu_items': 'x||y|z',
                 'default': 0,
             },
         ],
     })
예제 #20
0
 def test_validate_gdrivefile_missing_secret(self):
     with self.assertRaisesRegex(
             ValueError,
             "Param 'b' has a 'secret_parameter' that is not a 'secret'"):
         validate_module_spec({
             'id_name':
             'id',
             'name':
             'Name',
             'category':
             'Clean',
             'parameters': [
                 {
                     'id_name': 'b',
                     'type': 'gdrivefile',
                     'secret_parameter': 'a',
                 },
             ],
         })
예제 #21
0
 def test_valid_visible_if(self):
     # does not raise
     validate_module_spec({
         'id_name':
         'id',
         'name':
         'Name',
         'category':
         'Clean',
         'parameters': [{
             'id_name': 'a',
             'type': 'string',
             'visible_if': {
                 'id_name': 'b',
                 'value': True
             },
         }, {
             'id_name': 'b',
             'type': 'string'
         }],
     })
예제 #22
0
 def test_multicolumn_tab_parameter(self):
     # does not raise
     validate_module_spec({
         'id_name':
         'id',
         'name':
         'Name',
         'category':
         'Clean',
         'parameters': [
             {
                 'id_name': 'a',
                 'type': 'column',
                 'tab_parameter': 'b',
             },
             {
                 'id_name': 'b',
                 'type': 'tab',
             },
         ],
     })
예제 #23
0
 def test_invalid_visible_if(self):
     with self.assertRaisesRegex(
             ValueError,
             "Param 'a' has visible_if id_name 'b', which does not exist"):
         validate_module_spec({
             'id_name':
             'id',
             'name':
             'Name',
             'category':
             'Clean',
             'parameters': [
                 {
                     'id_name': 'a',
                     'type': 'string',
                     'visible_if': {
                         'id_name': 'b',
                         'value': True
                     },
                 },
             ],
         })
예제 #24
0
 def test_valid_visible_if_menu_options(self):
     # does not raise
     validate_module_spec({
         'id_name':
         'id',
         'name':
         'Name',
         'category':
         'Clean',
         'parameters': [{
             'id_name': 'a',
             'type': 'string',
             'visible_if': {
                 'id_name': 'b',
                 'value': ['a', 'b']
             },
         }, {
             'id_name':
             'b',
             'type':
             'menu',
             'options': [
                 {
                     'value': 'a',
                     'label': 'A'
                 },
                 'separator',
                 {
                     'value': 'b',
                     'label': 'B'
                 },
                 {
                     'value': 'c',
                     'label': 'C'
                 },
             ],
         }],
     })
예제 #25
0
 def test_validate_gdrivefile_invalid_secret(self):
     with self.assertRaisesRegex(
         ValueError, "Param 'b' 'secret_parameter' does not refer to a 'google'"
     ):
         validate_module_spec(
             {
                 "id_name": "id",
                 "name": "Name",
                 "category": "Clean",
                 "parameters": [
                     {
                         "id_name": "a",
                         "type": "secret",
                         "secret_logic": {
                             "provider": "oauth",
                             "service": "twitter",
                             "name": "Connect",
                         },
                     },
                     {"id_name": "b", "type": "gdrivefile", "secret_parameter": "a"},
                 ],
             }
         )
예제 #26
0
 def test_validate_menu_with_default(self):
     # does not raise
     validate_module_spec(
         {
             "id_name": "id",
             "name": "Name",
             "category": "Clean",
             "parameters": [
                 {
                     "id_name": "a",
                     "type": "menu",
                     "placeholder": "Select something",
                     "options": [
                         {"value": "x", "label": "X"},
                         "separator",
                         {"value": "y", "label": "Y"},
                         {"value": "z", "label": "Z"},
                     ],
                     "default": "y",
                 }
             ],
         }
     )
예제 #27
0
 def test_multicolumn_non_tab_parameter(self):
     with self.assertRaisesRegex(
             ValueError,
             "Param 'a' has a 'tab_parameter' that is not a 'tab'"):
         validate_module_spec({
             'id_name':
             'id',
             'name':
             'Name',
             'category':
             'Clean',
             'parameters': [
                 {
                     'id_name': 'a',
                     'type': 'column',
                     'tab_parameter': 'b',
                 },
                 {
                     'id_name': 'b',
                     'type': 'string',  # Not a 'tab'
                 },
             ],
         })
예제 #28
0
 def test_validate_menu_with_default(self):
     # does not raise
     validate_module_spec({
         'id_name':
         'id',
         'name':
         'Name',
         'category':
         'Clean',
         'parameters': [
             {
                 'id_name':
                 'a',
                 'type':
                 'menu',
                 'placeholder':
                 'Select something',
                 'options': [
                     {
                         'value': 'x',
                         'label': 'X'
                     },
                     'separator',
                     {
                         'value': 'y',
                         'label': 'Y'
                     },
                     {
                         'value': 'z',
                         'label': 'Z'
                     },
                 ],
                 'default':
                 'y',
             },
         ],
     })
예제 #29
0
 def test_validate_menu_invalid_default(self):
     with self.assertRaisesRegex(
         ValueError, "Param 'a' has a 'default' that is not in its 'options'"
     ):
         validate_module_spec(
             {
                 "id_name": "id",
                 "name": "Name",
                 "category": "Clean",
                 "parameters": [
                     {
                         "id_name": "a",
                         "type": "menu",
                         "options": [{"value": "x", "label": "X"}],
                         "default": "y",
                     },
                     {
                         # Previously, we gave the wrong id_name
                         "id_name": "not-a",
                         "type": "string",
                     },
                 ],
             }
         )
예제 #30
0
 def test_unique_params(self):
     with self.assertRaisesRegex(ValueError, "Param 'dup' appears twice"):
         validate_module_spec({
             'id_name':
             'id',
             'name':
             'Name',
             'category':
             'Clean',
             'parameters': [
                 {
                     'id_name': 'dup',
                     'type': 'string'
                 },
                 {
                     'id_name': 'original',
                     'type': 'string'
                 },
                 {
                     'id_name': 'dup',
                     'type': 'string'
                 },
             ],
         })