Exemplo n.º 1
0
    def test_node_query(self):
        """
        Make sure nodes returned by a PostGIS based query are the same as the
        regular ones.
        """
        params = {
            "sid": 3,
            "limit": 5000,
            "project_id": self.test_project_id,
            "z1": 0,
            "z2": 9,
            "top": 4625.0,
            "left": 2860.0,
            "bottom": 8075.0,
            "right": 10860.0,
            "labels": False,
        }

        non_postgis_nodes_r = node.node_list_tuples_query(
            params, self.test_project_id, None, None, include_labels=False, tn_provider=node.get_treenodes_classic
        )

        postgis_nodes_r = node.node_list_tuples_query(
            params, self.test_project_id, None, None, include_labels=False, tn_provider=node.get_treenodes_postgis
        )

        self.assertEqual(non_postgis_nodes_r.status_code, 200)
        self.assertEqual(postgis_nodes_r.status_code, 200)
        non_postgis_nodes = json.loads(non_postgis_nodes_r.content)
        postgis_nodes = json.loads(postgis_nodes_r.content)

        for n in non_postgis_nodes[1]:
            n[5] = frozenset([tuple(l) for l in n[5]])
        for n in postgis_nodes[1]:
            n[5] = frozenset([tuple(l) for l in n[5]])

        self.assertEqual(len(non_postgis_nodes), len(postgis_nodes))
        self.assertEqual(len(non_postgis_nodes[0]), len(postgis_nodes[0]))
        self.assertEqual(len(non_postgis_nodes[1]), len(postgis_nodes[1]))
        self.assertEqual(len(non_postgis_nodes[2]), len(postgis_nodes[2]))
        self.assertEqual(non_postgis_nodes[3], postgis_nodes[3])

        for tn in non_postgis_nodes[0]:
            self.assertTrue(tn in postgis_nodes[0])

        for tn in postgis_nodes[0]:
            self.assertTrue(tn in non_postgis_nodes[0])

        for c in non_postgis_nodes[1]:
            c[7] = sorted(c[7])

        for c in postgis_nodes[1]:
            c[7] = sorted(c[7])

        for c in non_postgis_nodes[1]:
            self.assertTrue(c in postgis_nodes[1])

        for c in postgis_nodes[1]:
            self.assertTrue(c in non_postgis_nodes[1])
Exemplo n.º 2
0
    def test_node_query(self):
        """
        Make sure nodes returned by a PostGIS based query are the same as the
        regular ones.
        """
        atnid = -1
        params = {
            'sid': 3,
            'limit': 5000,
            'project_id': self.test_project_id,
            'z1': 0,
            'z2': 9,
            'top': 4625.0,
            'left': 2860.0,
            'bottom': 8075.0,
            'right': 10860.0,
            'labels': False,
        }

        non_postgis_nodes_r = node.node_list_tuples_query(
            self.user,
            params,
            self.test_project_id,
            atnid,
            includeLabels=False,
            tn_provider=node.get_treenodes_classic)

        postgis_nodes_r = node.node_list_tuples_query(
            self.user,
            params,
            self.test_project_id,
            atnid,
            includeLabels=False,
            tn_provider=node.get_treenodes_postgis)

        self.assertEqual(non_postgis_nodes_r.status_code, 200)
        self.assertEqual(postgis_nodes_r.status_code, 200)
        non_postgis_nodes = json.loads(non_postgis_nodes_r.content)
        postgis_nodes = json.loads(postgis_nodes_r.content)

        self.assertEqual(len(non_postgis_nodes), len(postgis_nodes))
        self.assertEqual(len(non_postgis_nodes[0]), len(postgis_nodes[0]))
        self.assertEqual(len(non_postgis_nodes[1]), len(postgis_nodes[1]))
        self.assertEqual(len(non_postgis_nodes[2]), len(postgis_nodes[2]))
        self.assertEqual(non_postgis_nodes[3], postgis_nodes[3])

        for tn in non_postgis_nodes[0]:
            self.assertTrue(tn in postgis_nodes[0])

        for tn in postgis_nodes[0]:
            self.assertTrue(tn in non_postgis_nodes[0])

        for c in non_postgis_nodes[1]:
            self.assertTrue(c in postgis_nodes[1])

        for c in postgis_nodes[1]:
            self.assertTrue(c in non_postgis_nodes[1])
Exemplo n.º 3
0
    def test_node_query(self):
        """
        Make sure nodes returned by a PostGIS based query are the same as the
        regular ones.
        """
        atnid = -1
        params = {
            'sid': 3,
            'limit': 5000,
            'project_id': self.test_project_id,
            'z1': 0,
            'z2': 9,
            'top': 4625.0,
            'left': 2860.0,
            'bottom': 8075.0,
            'right': 10860.0,
            'labels': False,
        }

        non_postgis_nodes_r = node.node_list_tuples_query(self.user, params,
                self.test_project_id, atnid, includeLabels=False,
                tn_provider=node.get_treenodes_classic)

        postgis_nodes_r = node.node_list_tuples_query(self.user, params,
                self.test_project_id, atnid, includeLabels=False,
                tn_provider=node.get_treenodes_postgis)

        self.assertEqual(non_postgis_nodes_r.status_code, 200)
        self.assertEqual(postgis_nodes_r.status_code, 200)
        non_postgis_nodes = json.loads(non_postgis_nodes_r.content)
        postgis_nodes = json.loads(postgis_nodes_r.content)

        self.assertEqual(len(non_postgis_nodes), len(postgis_nodes))
        self.assertEqual(len(non_postgis_nodes[0]), len(postgis_nodes[0]))
        self.assertEqual(len(non_postgis_nodes[1]), len(postgis_nodes[1]))
        self.assertEqual(len(non_postgis_nodes[2]), len(postgis_nodes[2]))
        self.assertEqual(non_postgis_nodes[3], postgis_nodes[3])

        for tn in non_postgis_nodes[0]:
            self.assertTrue(tn in postgis_nodes[0])

        for tn in postgis_nodes[0]:
            self.assertTrue(tn in non_postgis_nodes[0])

        for c in non_postgis_nodes[1]:
            self.assertTrue(c in postgis_nodes[1])

        for c in postgis_nodes[1]:
            self.assertTrue(c in non_postgis_nodes[1])
Exemplo n.º 4
0
    def test_node_query(self):
        """
        Make sure nodes returned by a PostGIS based query are the same as the
        regular ones.
        """
        params = {
            'sid': 3,
            'limit': 5000,
            'project_id': self.test_project_id,
            'z1': 0,
            'z2': 9,
            'top': 4625.0,
            'left': 2860.0,
            'bottom': 8075.0,
            'right': 10860.0,
            'labels': False,
        }

        postgis_3d_nodes_r = node.node_list_tuples_query(
            params,
            self.test_project_id,
            node.Postgis3dNodeProvider(),
            tuple(),
            tuple(),
            include_labels=False)

        postgis_2d_nodes_r = node.node_list_tuples_query(
            params,
            self.test_project_id,
            node.Postgis2dNodeProvider(),
            tuple(),
            tuple(),
            include_labels=False)

        with self.settings(PREPARED_STATEMENTS=True):
            node_3d_ps_provider = node.Postgis3dNodeProvider()
            node_3d_ps_provider.prepare_db_statements(connection)
            postgis_3d_ps_nodes_r = node.node_list_tuples_query(
                params,
                self.test_project_id,
                node_3d_ps_provider,
                tuple(),
                tuple(),
                include_labels=False)

        with self.settings(PREPARED_STATEMENTS=True):
            node_2d_ps_provider = node.Postgis2dNodeProvider()
            node_2d_ps_provider.prepare_db_statements(connection)
            postgis_2d_ps_nodes_r = node.node_list_tuples_query(
                params,
                self.test_project_id,
                node_2d_ps_provider,
                tuple(),
                tuple(),
                include_labels=False)

        self.assertEqual(postgis_3d_nodes_r.status_code, 200)
        self.assertEqual(postgis_2d_nodes_r.status_code, 200)
        self.assertEqual(postgis_3d_ps_nodes_r.status_code, 200)
        self.assertEqual(postgis_2d_ps_nodes_r.status_code, 200)
        postgis_3d_nodes = json.loads(
            postgis_3d_nodes_r.content.decode('utf-8'))
        postgis_2d_nodes = json.loads(
            postgis_2d_nodes_r.content.decode('utf-8'))
        postgis_3d_ps_nodes = json.loads(
            postgis_3d_ps_nodes_r.content.decode('utf-8'))
        postgis_2d_ps_nodes = json.loads(
            postgis_2d_ps_nodes_r.content.decode('utf-8'))

        def test_returned_nodes(reference, to_test):
            self.assertEqual(len(reference), len(to_test))
            self.assertEqual(len(reference[0]), len(to_test[0]))
            self.assertEqual(len(reference[1]), len(to_test[1]))
            self.assertEqual(len(reference[2]), len(to_test[2]))
            self.assertEqual(reference[3], to_test[3])

            for tn in reference[0]:
                self.assertTrue(tn in to_test[0])

            for tn in to_test[0]:
                self.assertTrue(tn in reference[0])

            for c in reference[1]:
                c[7] = sorted(c[7])

            for c in to_test[1]:
                c[7] = sorted(c[7])

            for c in reference[1]:
                self.assertTrue(c in to_test[1])

            for c in to_test[1]:
                self.assertTrue(c in reference[1])

        test_returned_nodes(postgis_3d_nodes, postgis_2d_nodes)
        test_returned_nodes(postgis_3d_nodes, postgis_3d_ps_nodes)
        test_returned_nodes(postgis_3d_nodes, postgis_2d_ps_nodes)
Exemplo n.º 5
0
    def test_node_query(self):
        """
        Make sure nodes returned by a PostGIS based query are the same as the
        regular ones.
        """
        params = {
            'sid': 3,
            'limit': 5000,
            'project_id': self.test_project_id,
            'z1': 0,
            'z2': 9,
            'top': 4625.0,
            'left': 2860.0,
            'bottom': 8075.0,
            'right': 10860.0,
            'labels': False,
        }

        postgis_3d_nodes_r = node.node_list_tuples_query(params,
                self.test_project_id, node.Postgis3dNodeProvider(),
                tuple(), tuple(), include_labels=False)

        postgis_2d_nodes_r = node.node_list_tuples_query(params,
                self.test_project_id, node.Postgis2dNodeProvider(),
                tuple(), tuple(), include_labels=False)

        with self.settings(PREPARED_STATEMENTS=True):
            node_3d_ps_provider = node.Postgis3dNodeProvider()
            node_3d_ps_provider.prepare_db_statements(connection)
            postgis_3d_ps_nodes_r = node.node_list_tuples_query(params,
                    self.test_project_id, node_3d_ps_provider,
                    tuple(), tuple(), include_labels=False)

        with self.settings(PREPARED_STATEMENTS=True):
            node_2d_ps_provider = node.Postgis2dNodeProvider()
            node_2d_ps_provider.prepare_db_statements(connection)
            postgis_2d_ps_nodes_r = node.node_list_tuples_query(params,
                    self.test_project_id, node_2d_ps_provider,
                    tuple(), tuple(), include_labels=False)


        self.assertEqual(postgis_3d_nodes_r.status_code, 200)
        self.assertEqual(postgis_2d_nodes_r.status_code, 200)
        self.assertEqual(postgis_3d_ps_nodes_r.status_code, 200)
        self.assertEqual(postgis_2d_ps_nodes_r.status_code, 200)
        postgis_3d_nodes = json.loads(postgis_3d_nodes_r.content.decode('utf-8'))
        postgis_2d_nodes = json.loads(postgis_2d_nodes_r.content.decode('utf-8'))
        postgis_3d_ps_nodes = json.loads(postgis_3d_ps_nodes_r.content.decode('utf-8'))
        postgis_2d_ps_nodes = json.loads(postgis_2d_ps_nodes_r.content.decode('utf-8'))

        def test_returned_nodes(reference, to_test):
            self.assertEqual(len(reference), len(to_test))
            self.assertEqual(len(reference[0]), len(to_test[0]))
            self.assertEqual(len(reference[1]), len(to_test[1]))
            self.assertEqual(len(reference[2]), len(to_test[2]))
            self.assertEqual(reference[3], to_test[3])

            for tn in reference[0]:
                self.assertTrue(tn in to_test[0])

            for tn in to_test[0]:
                self.assertTrue(tn in reference[0])

            for c in reference[1]:
                c[7] = sorted(c[7])

            for c in to_test[1]:
                c[7] = sorted(c[7])

            for c in reference[1]:
                self.assertTrue(c in to_test[1])

            for c in to_test[1]:
                self.assertTrue(c in reference[1])

        test_returned_nodes(postgis_3d_nodes, postgis_2d_nodes)
        test_returned_nodes(postgis_3d_nodes, postgis_3d_ps_nodes)
        test_returned_nodes(postgis_3d_nodes, postgis_2d_ps_nodes)
Exemplo n.º 6
0
    def test_node_query(self):
        """
        Make sure nodes returned by a PostGIS based query are the same as the
        regular ones.
        """
        params = {
            'sid': 3,
            'limit': 5000,
            'project_id': self.test_project_id,
            'z1': 0,
            'z2': 9,
            'top': 4625.0,
            'left': 2860.0,
            'bottom': 8075.0,
            'right': 10860.0,
            'labels': False,
        }

        non_postgis_nodes_r = node.node_list_tuples_query(
            params,
            self.test_project_id,
            None,
            None,
            include_labels=False,
            node_provider=node.ClassicNodeProvider())

        postgis_3d_nodes_r = node.node_list_tuples_query(
            params,
            self.test_project_id,
            None,
            None,
            include_labels=False,
            node_provider=node.Postgis3dNodeProvider())

        postgis_2d_nodes_r = node.node_list_tuples_query(
            params,
            self.test_project_id,
            None,
            None,
            include_labels=False,
            node_provider=node.Postgis2dNodeProvider())

        self.assertEqual(non_postgis_nodes_r.status_code, 200)
        self.assertEqual(postgis_3d_nodes_r.status_code, 200)
        self.assertEqual(postgis_2d_nodes_r.status_code, 200)
        non_postgis_nodes = json.loads(non_postgis_nodes_r.content)
        postgis_3d_nodes = json.loads(postgis_3d_nodes_r.content)
        postgis_2d_nodes = json.loads(postgis_2d_nodes_r.content)

        def test_returned_nodes(reference, to_test):
            self.assertEqual(len(reference), len(to_test))
            self.assertEqual(len(reference[0]), len(to_test[0]))
            self.assertEqual(len(reference[1]), len(to_test[1]))
            self.assertEqual(len(reference[2]), len(to_test[2]))
            self.assertEqual(reference[3], to_test[3])

            for tn in reference[0]:
                self.assertTrue(tn in to_test[0])

            for tn in to_test[0]:
                self.assertTrue(tn in reference[0])

            for c in reference[1]:
                c[7] = sorted(c[7])

            for c in to_test[1]:
                c[7] = sorted(c[7])

            for c in reference[1]:
                self.assertTrue(c in to_test[1])

            for c in to_test[1]:
                self.assertTrue(c in reference[1])

        test_returned_nodes(non_postgis_nodes, postgis_3d_nodes)
        test_returned_nodes(non_postgis_nodes, postgis_2d_nodes)