Ejemplo n.º 1
0
    def get(self, request, *args, **kwargs):
        orgao_id = kwargs.get(self.orgao_url_kwarg)
        cpf = kwargs.get("cpf")
        search_string = request.GET.get("search_string", "")
        page = int(request.GET.get("page", 1))

        data = PIPPrincipaisInvestigadosDAO.get(orgao_id=orgao_id, cpf=cpf)

        data = self.search(search_string, data)

        page_data = self.paginate(data, page=page, page_size=self.PAGE_SIZE)
        response = {
            'investigados': page_data,
            'nr_paginas': self.get_n_pages(data)
        }

        return Response(response)
Ejemplo n.º 2
0
    def test_get(self, _get, _get_hbase):
        _get_hbase.return_value = {
            "1278": {
                "is_pinned": True,
                "is_removed": False
            },
            "5678": {
                "is_pinned": False,
                "is_removed": True
            },
        }
        _get.return_value = [
            {
                "nm_investigado": "Nome1",
                "representante_dk": "1234",
                "pip_codigo": 1,
                "nr_investigacoes": 10,
                "flag_multipromotoria": None,
                "flag_top50": True,
            },
            {
                "nm_investigado": "Nome2",
                "representante_dk": "1278",
                "pip_codigo": 1,
                "nr_investigacoes": 5,
                "flag_multipromotoria": True,
                "flag_top50": None,
            },
            {
                "nm_investigado": "Nome3",
                "representante_dk": "5678",
                "pip_codigo": 1,
                "nr_investigacoes": 15,
                "flag_multipromotoria": None,
                "flag_top50": None,
            },
        ]

        expected_output = [
            {
                "nm_investigado": "Nome2",
                "representante_dk": "1278",
                "pip_codigo": 1,
                "nr_investigacoes": 5,
                "flag_multipromotoria": True,
                "flag_top50": None,
                "is_pinned": True,
                "is_removed": False
            },
            {
                "nm_investigado": "Nome1",
                "representante_dk": "1234",
                "pip_codigo": 1,
                "nr_investigacoes": 10,
                "flag_multipromotoria": None,
                "flag_top50": True,
                "is_pinned": False,
                "is_removed": False
            },
        ]

        data = PIPPrincipaisInvestigadosDAO.get("1", "2")
        assert data == expected_output