Esempio n. 1
0
    def test_graph_entity__find_id(self):
        # a graph entity to test with
        entity = GraphEntity(service=Mock(), model_type="user", id=1)
        # the result to test against
        result = {
            'user': {
                'foo': [
                    {'id': 1}
                ],
                'bar': {
                    'id': 7,
                    'baz': [
                        {'id': 5}
                    ]
                },
                'baz': {
                    'id': 8,
                    'bing': []
                }
            }
        }
        # make sure it can find the number 1 in the list
        assert entity._find_id(result, 1), (
            "Could not find id in GraphEntity result."
        )
        # make sure it can find the number 1 in the list
        assert entity._find_id(result, 5), (
            "Could not find id in GraphEntity result."
        )

        # make sure we don't have any false positives
        assert not entity._find_id(result, 7), (
            "Encountered false positive in GraphEntity._find_id."
        )

        # make sure we don't have any false positives
        assert not entity._find_id(result, 8), (
            "Encountered a complicated false positive in GraphEntity._find_id."
        )
Esempio n. 2
0
    def test_graph_entity__find_id(self):
        # a graph entity to test with
        entity = GraphEntity(service=Mock(), model_type="user", id=1)
        # the result to test against
        result = {
            'user': {
                'foo': [{
                    'id': 1
                }],
                'bar': {
                    'id': 7,
                    'baz': [{
                        'id': 5
                    }]
                },
                'baz': {
                    'id': 8,
                    'bing': []
                }
            }
        }
        # make sure it can find the number 1 in the list
        assert entity._find_id(result,
                               1), ("Could not find id in GraphEntity result.")
        # make sure it can find the number 1 in the list
        assert entity._find_id(result,
                               5), ("Could not find id in GraphEntity result.")

        # make sure we don't have any false positives
        assert not entity._find_id(
            result, 7), ("Encountered false positive in GraphEntity._find_id.")

        # make sure we don't have any false positives
        assert not entity._find_id(result, 8), (
            "Encountered a complicated false positive in GraphEntity._find_id."
        )