From bf60a54febdb9151054506ec0b1c8916e30d8ba5 Mon Sep 17 00:00:00 2001 From: eddumm22 Date: Tue, 30 Sep 2014 17:39:06 -0300 Subject: [PATCH] class generica para fazer a busca no obj base --- wscacicneo/model/reports.py | 42 ++++++++++++++++++++++++++++++++++++++++++ wscacicneo/test/test_reports.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 0 deletions(-) create mode 100644 wscacicneo/model/reports.py create mode 100644 wscacicneo/test/test_reports.py diff --git a/wscacicneo/model/reports.py b/wscacicneo/model/reports.py new file mode 100644 index 0000000..3a92257 --- /dev/null +++ b/wscacicneo/model/reports.py @@ -0,0 +1,42 @@ +#!/usr/env python +# -*- coding: utf-8 -*- +__author__ = 'macieski' + +from requests.exceptions import HTTPError +from wscacicneo import config +import logging +from liblightbase.lbbase.struct import Base, BaseMetadata +from liblightbase.lbbase.lbstruct.group import * +from liblightbase.lbbase.lbstruct.field import * +from liblightbase.lbbase.content import Content +from wscacicneo.model import coleta_manual +from liblightbase.lbrest.base import BaseREST +from liblightbase.lbrest.document import DocumentREST +from liblightbase.lbutils import conv +from liblightbase.lbsearch.search import Search, OrderBy + +log = logging.getLogger() + + +class Reports(): + + def __init__(self, nm_base, rest_url=None): + if rest_url is None: + self.rest_url = config.REST_URL + else: + self.rest_url = rest_url + self.base = coleta_manual.ColetaManualBase(nm_base, self.rest_url).lbbase + print(type(self.base)) + self.documentrest = DocumentREST(self.rest_url, self.base, response_object=True) + + + def get_base_orgao(self): + """ + retorna todos os documentos da base + """ + search = Search( + limit=None + ) + get = self.documentrest.get_collection(search_obj=search) + + return get diff --git a/wscacicneo/test/test_reports.py b/wscacicneo/test/test_reports.py new file mode 100644 index 0000000..7e054ad --- /dev/null +++ b/wscacicneo/test/test_reports.py @@ -0,0 +1,32 @@ +#!/usr/env python +# -*- coding: utf-8 -*- +__author__ = 'eduardo' + +import unittest +from wscacicneo.model import reports +from liblightbase.lbbase.struct import Base +from liblightbase.lbutils import conv + +class TestOrgaoBase(unittest.TestCase): + """ + Testa base do órgão no LB + """ + def setUp(self): + """ + Carregando atributos genéricos do teste + """ + self.rest_url = 'http://api.brlight.net/api' + self.nm_base = 'coleta_manual' + + def test_get_doc_base(self): + """ + Testa busca o documento completo da base + """ + get_doc = reports.Reports(self.rest_url, self.nm_base) + lbbase = get_doc.get_base_orgao + + def tearDown(self): + """ + Apaga dados do teste + """ + pass -- libgit2 0.21.2