def test_get_areas(self):
        update_area(self.area1)
        areas = get_areas(self.waypoint1, 'en')

        self.assertEqual(len(areas), 1)
        self.assertEqual(
            areas[0].document_id, self.area1.document_id)
Esempio n. 2
0
    def test_update_area(self):
        update_area(self.area1)

        added_links = self.session.query(AreaAssociation). \
            filter(AreaAssociation.area_id == self.area1.document_id).all()
        self.assertEqual(len(added_links), 1)
        self.assertEqual(added_links[0].document_id,
                         self.waypoint1.document_id)
    def test_update_area(self):
        update_area(self.area1)

        added_links = self.session.query(AreaAssociation). \
            filter(AreaAssociation.area_id == self.area1.document_id).all()
        self.assertEqual(len(added_links), 1)
        self.assertEqual(
            added_links[0].document_id, self.waypoint1.document_id)
Esempio n. 4
0
def update_associations(area, update_types, user_id):
    """Update the links between this area and documents when the geometry
    has changed.
    """
    if update_types:
        # update cache key for currently associated docs
        update_cache_version_for_area(area)

    if UpdateType.GEOM in update_types:
        update_area(area, reset=True)
Esempio n. 5
0
    def test_update_area_reset_first_forwarded(self):
        """Tests that areas with `redirects_to` are ignored.
        """
        # add an association with wp2, which should be removed after the update
        self.session.add(
            AreaAssociation(document_id=self.waypoint2.document_id,
                            area_id=self.area2.document_id))
        self.session.flush()

        update_area(self.area2, reset=True)

        updated_links = self.session.query(AreaAssociation). \
            filter(AreaAssociation.area_id == self.area2.document_id).all()
        self.assertEqual(len(updated_links), 0)
Esempio n. 6
0
    def test_update_area_reset_first(self):
        # add an association with wp2, which should be removed after the update
        self.session.add(
            AreaAssociation(document_id=self.waypoint2.document_id,
                            area_id=self.area1.document_id))
        self.session.flush()

        update_area(self.area1, reset=True)

        updated_links = self.session.query(AreaAssociation). \
            filter(AreaAssociation.area_id == self.area1.document_id).all()
        self.assertEqual(len(updated_links), 1)
        self.assertEqual(updated_links[0].document_id,
                         self.waypoint1.document_id)
    def test_update_area_reset_first_forwarded(self):
        """Tests that areas with `redirects_to` are ignored.
        """
        # add an association with wp2, which should be removed after the update
        self.session.add(AreaAssociation(
            document_id=self.waypoint2.document_id,
            area_id=self.area2.document_id))
        self.session.flush()

        update_area(self.area2, reset=True)

        updated_links = self.session.query(AreaAssociation). \
            filter(AreaAssociation.area_id == self.area2.document_id).all()
        self.assertEqual(len(updated_links), 0)
    def test_update_area_reset_first(self):
        # add an association with wp2, which should be removed after the update
        self.session.add(AreaAssociation(
            document_id=self.waypoint2.document_id,
            area_id=self.area1.document_id))
        self.session.flush()

        update_area(self.area1, reset=True)

        updated_links = self.session.query(AreaAssociation). \
            filter(AreaAssociation.area_id == self.area1.document_id).all()
        self.assertEqual(len(updated_links), 1)
        self.assertEqual(
            updated_links[0].document_id, self.waypoint1.document_id)
Esempio n. 9
0
    def test_get_areas(self):
        update_area(self.area1)
        areas = get_areas(self.waypoint1, 'en')

        self.assertEqual(len(areas), 1)
        self.assertEqual(areas[0].document_id, self.area1.document_id)
Esempio n. 10
0
def insert_associations(area, user_id):
    """Create links between this new area and documents.
    """
    update_area(area, reset=False)
Esempio n. 11
0
def update_associations(area, update_types, user_id):
    """Update the links between this area and documents when the geometry
    has changed.
    """
    if UpdateType.GEOM in update_types:
        update_area(area, reset=True)
Esempio n. 12
0
def insert_associations(area, user_id):
    """Create links between this new area and documents.
    """
    update_area(area, reset=False)