Ejemplo n.º 1
0
    def test_get_publications(self):

        document = next(get_documents('I', 2002))
        pubs = document['publications'][:]
        document['publications'] = ['' for _ in document['publications']]

        expected = {
            'publications': [''] * 3,
            'series': 'I-A',
            'dre_id': 118243,
            'supplement': None,
            'date': '2002-01-02',
            'number': '1/2002',
            'name': 'Diário da República'
        }

        self.assertEqual(expected, document)

        expected = {
            'dre_id': 584794,
            'date': datetime.date(2002, 1, 2),
            'type': 'Decreto-Lei',
            'number': '1/2002',
            'creator': 'Ministério da Economia',
            'pages': '6 - 7',
            'pdf_id': 584725
        }

        del pubs[0]['text']
        del pubs[0]['summary']

        self.assertEqual(expected, pubs[0])
Ejemplo n.º 2
0
def update_database():
    year = datetime.datetime.now().date().year
    for year in range(year - 1, year + 1):
        for document in get_documents('I', year):
            save_document(document)
Ejemplo n.º 3
0
def bootstrap_database():
    logging.getLogger('django').setLevel(logging.INFO)
    logging.getLogger('pt_law_downloader').setLevel(logging.INFO)
    for year in range(1975, datetime.datetime.now().date().year + 1):
        for document in get_documents('I', year):
            save_document(document)
Ejemplo n.º 4
0
def update_database(from_year=datetime.datetime.now().date().year,
                    to_year=datetime.datetime.now().date().year):
    for year in range(from_year, to_year + 1):
        for document in get_documents('I', year):
            save_document(document)
Ejemplo n.º 5
0
def bootstrap_database():
    logging.getLogger('django').setLevel(logging.INFO)
    logging.getLogger('pt_law_downloader').setLevel(logging.INFO)
    for year in range(1975, datetime.datetime.now().date().year + 1):
        for document in get_documents('I', year):
            save_document(document)