How to use the grlc.gquery.get_enumeration function in grlc

To help you get started, we’ve selected a few grlc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CLARIAH / grlc / tests / test_gquery.py View on Github external
def test_get_enumeration(self, mock_get):
        mock_get.return_value = Mock(ok=True)
        mock_get.return_value.json.return_value = {
            'results': {
                'bindings': [
                    {'o1': {'value': 'v1'}},
                    {'o1': {'value': 'v2'}}
                ]
            }
        }

        rq, _ = self.loader.getTextForName('test-rq')
        metadata = {'enumerate': 'o1'}
        enumeration = gquery.get_enumeration(rq, 'o1', 'http://mock-endpoint/sparql', metadata)
        self.assertIsInstance(enumeration, list, 'Should return a list of values')
        self.assertEqual(len(enumeration), 2, 'Should have two elements')
github CLARIAH / grlc / tests / test_gquery.py View on Github external
def test_get_static_enumeration(self):
        rq, _ = self.loader.getTextForName('test-enum')

        metadata = gquery.get_yaml_decorators(rq)
        self.assertIn('enumerate', metadata, 'Should contain enumerate')

        enumeration = gquery.get_enumeration(rq, 'o', 'http://mock-endpoint/sparql', metadata)
        self.assertIsInstance(enumeration, list, 'Should return a list of values')
        self.assertEqual(len(enumeration), 2, 'Should have two elements')