Commit bf60a54febdb9151054506ec0b1c8916e30d8ba5
1 parent
cd02128c
Exists in
master
class generica para fazer a busca no obj base
Showing
2 changed files
with
74 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,42 @@ |
1 | +#!/usr/env python | |
2 | +# -*- coding: utf-8 -*- | |
3 | +__author__ = 'macieski' | |
4 | + | |
5 | +from requests.exceptions import HTTPError | |
6 | +from wscacicneo import config | |
7 | +import logging | |
8 | +from liblightbase.lbbase.struct import Base, BaseMetadata | |
9 | +from liblightbase.lbbase.lbstruct.group import * | |
10 | +from liblightbase.lbbase.lbstruct.field import * | |
11 | +from liblightbase.lbbase.content import Content | |
12 | +from wscacicneo.model import coleta_manual | |
13 | +from liblightbase.lbrest.base import BaseREST | |
14 | +from liblightbase.lbrest.document import DocumentREST | |
15 | +from liblightbase.lbutils import conv | |
16 | +from liblightbase.lbsearch.search import Search, OrderBy | |
17 | + | |
18 | +log = logging.getLogger() | |
19 | + | |
20 | + | |
21 | +class Reports(): | |
22 | + | |
23 | + def __init__(self, nm_base, rest_url=None): | |
24 | + if rest_url is None: | |
25 | + self.rest_url = config.REST_URL | |
26 | + else: | |
27 | + self.rest_url = rest_url | |
28 | + self.base = coleta_manual.ColetaManualBase(nm_base, self.rest_url).lbbase | |
29 | + print(type(self.base)) | |
30 | + self.documentrest = DocumentREST(self.rest_url, self.base, response_object=True) | |
31 | + | |
32 | + | |
33 | + def get_base_orgao(self): | |
34 | + """ | |
35 | + retorna todos os documentos da base | |
36 | + """ | |
37 | + search = Search( | |
38 | + limit=None | |
39 | + ) | |
40 | + get = self.documentrest.get_collection(search_obj=search) | |
41 | + | |
42 | + return get | ... | ... |
... | ... | @@ -0,0 +1,32 @@ |
1 | +#!/usr/env python | |
2 | +# -*- coding: utf-8 -*- | |
3 | +__author__ = 'eduardo' | |
4 | + | |
5 | +import unittest | |
6 | +from wscacicneo.model import reports | |
7 | +from liblightbase.lbbase.struct import Base | |
8 | +from liblightbase.lbutils import conv | |
9 | + | |
10 | +class TestOrgaoBase(unittest.TestCase): | |
11 | + """ | |
12 | + Testa base do órgão no LB | |
13 | + """ | |
14 | + def setUp(self): | |
15 | + """ | |
16 | + Carregando atributos genéricos do teste | |
17 | + """ | |
18 | + self.rest_url = 'http://api.brlight.net/api' | |
19 | + self.nm_base = 'coleta_manual' | |
20 | + | |
21 | + def test_get_doc_base(self): | |
22 | + """ | |
23 | + Testa busca o documento completo da base | |
24 | + """ | |
25 | + get_doc = reports.Reports(self.rest_url, self.nm_base) | |
26 | + lbbase = get_doc.get_base_orgao | |
27 | + | |
28 | + def tearDown(self): | |
29 | + """ | |
30 | + Apaga dados do teste | |
31 | + """ | |
32 | + pass | ... | ... |