Beispiel #1
0
 def _get_attribute_role(self, key, value=None):
     """See `graph_reference.get_role`."""
     object_name = self._name
     parent_object_names = self._get_parent_object_names()
     return graph_reference.get_role(
         object_name, key, value=value,
         parent_object_names=parent_object_names
     )
Beispiel #2
0
 def _get_attribute_role(self, key, value=None):
     """See `graph_reference.get_role`."""
     object_name = self._name
     parent_object_names = self._get_parent_object_names()
     return graph_reference.get_role(
         object_name, key, value=value,
         parent_object_names=parent_object_names
     )
Beispiel #3
0
    def test_get_role_with_value(self):

        # some attributes are conditionally considered data if they're arrays

        # (<object_name>, <attribute_name>, <parent_object_names>, <role>)
        test_tuples = [
            ('scatter', 'x', 'wh0cares', ('figure', 'data'), 'data'),
            ('scatter', 'marker', 'wh0cares', ('figure', 'data'), 'object'),
            ('marker', 'color', 'r', ('figure', 'data', 'scatter'), 'style'),
            ('marker', 'color', ['r'], ('figure', 'data', 'scatter'), 'data'),
        ]

        for tup in test_tuples:
            object_name, key, value, parent_object_names, role = tup
            found_role = get_role(object_name, key, value=value,
                                  parent_object_names=parent_object_names)
            self.assertEqual(found_role, role, msg=tup)
    def test_get_role_with_value(self):

        # some attributes are conditionally considered data if they're arrays

        # (<object_name>, <attribute_name>, <parent_object_names>, <role>)
        test_tuples = [
            ('scatter', 'x', 'wh0cares', ('figure', 'data'), 'data'),
            ('scatter', 'marker', 'wh0cares', ('figure', 'data'), 'object'),
            ('marker', 'color', 'r', ('figure', 'data', 'scatter'), 'style'),
            ('marker', 'color', ['r'], ('figure', 'data', 'scatter'), 'data'),
        ]

        for tup in test_tuples:
            object_name, key, value, parent_object_names, role = tup
            found_role = get_role(object_name, key, value=value,
                                  parent_object_names=parent_object_names)
            self.assertEqual(found_role, role, msg=tup)
    def test_get_role_no_value(self):

        # this is a bit fragile, but we pick a few stable values

        # (<object_name>, <attribute_name>, <parent_object_names>, <role>)
        test_tuples = [('scatter', 'x', ('figure', 'data'), 'data'),
                       ('scatter', 'marker', ('figure', 'data'), 'object'),
                       ('marker', 'color', ('figure', 'data', 'scatter'),
                        'style'), ('layout', 'margin', ('figure', ), 'object'),
                       ('figure', 'data', (), 'object')]

        for tup in test_tuples:
            object_name, key, parent_object_names, role = tup
            found_role = get_role(object_name,
                                  key,
                                  parent_object_names=parent_object_names)
            self.assertEqual(found_role, role, msg=tup)
    def test_get_role_no_value(self):

        # this is a bit fragile, but we pick a few stable values

        # (<object_name>, <attribute_name>, <parent_object_names>, <role>)
        test_tuples = [
            ('scatter', 'x', ('figure', 'data'), 'data'),
            ('scatter', 'marker', ('figure', 'data'), 'object'),
            ('marker', 'color', ('figure', 'data', 'scatter'), 'style'),
            ('layout', 'margin', ('figure', ), 'object'),
            ('figure', 'data', (), 'object')
        ]

        for tup in test_tuples:
            object_name, key, parent_object_names, role = tup
            found_role = get_role(object_name, key,
                                  parent_object_names=parent_object_names)
            self.assertEqual(found_role, role, msg=tup)