コード例 #1
0
    def test_get_current_associations_routes(self):
        self._add_test_data_routes()

        new_associations = {
            'routes': [{
                'document_id': 1,
                'is_parent': True
            }],
            'waypoints': [{
                'document_id': 2,
                'is_parent': True
            }]
        }

        current_associations = _get_current_associations(
            self.route1, new_associations)

        expected_current_associations = {
            'routes': [{
                'document_id': self.route2.document_id,
                'is_parent': False
            }],
            'waypoints': [{
                'document_id': self.waypoint1.document_id,
                'is_parent': True
            }, {
                'document_id': self.waypoint2.document_id,
                'is_parent': True
            }]
        }
        self.assertEqual(current_associations, expected_current_associations)
コード例 #2
0
ファイル: test_association.py プロジェクト: c2corg/v6_api
    def test_get_current_associations_routes(self):
        self._add_test_data_routes()

        new_associations = {
            'routes': [
                {'document_id': 1, 'is_parent': True}
            ],
            'waypoints': [
                {'document_id': 2, 'is_parent': True}
            ]
        }

        current_associations = _get_current_associations(
            self.route1, new_associations)

        expected_current_associations = {
            'routes': [
                {'document_id': self.route2.document_id, 'is_parent': False}
            ],
            'waypoints': [
                {
                    'document_id': self.waypoint1.document_id,
                    'is_parent': True
                },
                {
                    'document_id': self.waypoint2.document_id,
                    'is_parent': True
                }
            ]
        }
        self.assertEqual(current_associations, expected_current_associations)
コード例 #3
0
    def test_get_current_associations_waypoints_partial(self):
        self.session.add(
            Association.create(parent_document=self.waypoint1,
                               child_document=self.waypoint2))
        self.session.flush()

        new_associations = {}
        current_associations = _get_current_associations(
            self.waypoint1, new_associations)

        expected_current_associations = {}
        self.assertEqual(current_associations, expected_current_associations)
コード例 #4
0
ファイル: test_association.py プロジェクト: c2corg/v6_api
    def test_get_current_associations_waypoints_partial(self):
        self.session.add(Association.create(
            parent_document=self.waypoint1, child_document=self.waypoint2)
        )
        self.session.flush()

        new_associations = {}
        current_associations = _get_current_associations(
            self.waypoint1, new_associations)

        expected_current_associations = {}
        self.assertEqual(current_associations, expected_current_associations)
コード例 #5
0
    def test_get_current_associations_waypoints(self):
        self.waypoint3 = Waypoint(waypoint_type='summit')
        self.session.add(self.waypoint3)
        self.session.flush()
        self.session.add_all([
            Association.create(parent_document=self.waypoint1,
                               child_document=self.waypoint2),
            Association.create(parent_document=self.waypoint3,
                               child_document=self.waypoint1),
            Association.create(parent_document=self.waypoint1,
                               child_document=self.route1),
            Association.create(parent_document=self.waypoint1,
                               child_document=self.route2),
        ])
        self.session.flush()

        new_associations = {
            # routes are ignored
            'routes': [{
                'document_id': 1,
                'is_parent': True
            }, {
                'document_id': 2,
                'is_parent': True
            }],
            'waypoints': [{
                'document_id': 3,
                'is_parent': True
            }],
            'waypoint_children': [{
                'document_id': 4,
                'is_parent': False
            }]
        }

        current_associations = _get_current_associations(
            self.waypoint1, new_associations)

        expected_current_associations = {
            'waypoints': [{
                'document_id': self.waypoint3.document_id,
                'is_parent': True
            }],
            'waypoint_children': [{
                'document_id': self.waypoint2.document_id,
                'is_parent': False
            }]
        }
        self.assertEqual(current_associations, expected_current_associations)
コード例 #6
0
ファイル: test_association.py プロジェクト: c2corg/v6_api
    def test_get_current_associations_waypoints(self):
        self.waypoint3 = Waypoint(waypoint_type='summit')
        self.session.add(self.waypoint3)
        self.session.flush()
        self.session.add_all([
            Association.create(
                parent_document=self.waypoint1, child_document=self.waypoint2),
            Association.create(
                parent_document=self.waypoint3, child_document=self.waypoint1),
            Association.create(
                parent_document=self.waypoint1, child_document=self.route1),
            Association.create(
                parent_document=self.waypoint1, child_document=self.route2),
        ])
        self.session.flush()

        new_associations = {
            # routes are ignored
            'routes': [
                {'document_id': 1, 'is_parent': True},
                {'document_id': 2, 'is_parent': True}
            ],
            'waypoints': [
                {'document_id': 3, 'is_parent': True}
            ],
            'waypoint_children': [
                {'document_id': 4, 'is_parent': False}
            ]
        }

        current_associations = _get_current_associations(
            self.waypoint1, new_associations)

        expected_current_associations = {
            'waypoints': [
                {
                    'document_id': self.waypoint3.document_id,
                    'is_parent': True
                }
            ],
            'waypoint_children': [
                {
                    'document_id': self.waypoint2.document_id,
                    'is_parent': False
                }
            ]
        }
        self.assertEqual(current_associations, expected_current_associations)
コード例 #7
0
    def test_get_current_associations_routes_partial(self):
        """ Check that only those types are loaded that are also given in the
        new associations (e.g. waypoints are not loaded in this case because
        the type is not given as input).
        """
        self._add_test_data_routes()

        new_associations = {'routes': [{'document_id': 1, 'is_parent': True}]}

        current_associations = _get_current_associations(
            self.route1, new_associations)

        expected_current_associations = {
            'routes': [{
                'document_id': self.route2.document_id,
                'is_parent': False
            }]
        }
        self.assertEqual(current_associations, expected_current_associations)
コード例 #8
0
ファイル: test_association.py プロジェクト: c2corg/v6_api
    def test_get_current_associations_routes_partial(self):
        """ Check that only those types are loaded that are also given in the
        new associations (e.g. waypoints are not loaded in this case because
        the type is not given as input).
        """
        self._add_test_data_routes()

        new_associations = {
            'routes': [
                {'document_id': 1, 'is_parent': True}
            ]
        }

        current_associations = _get_current_associations(
            self.route1, new_associations)

        expected_current_associations = {
            'routes': [
                {'document_id': self.route2.document_id, 'is_parent': False}
            ]
        }
        self.assertEqual(current_associations, expected_current_associations)