# Path: bormeparser/utils.py
# def get_borme_website(date, seccion, secure=True):
#     protocol = 'https' if secure else 'http'
#     return BORME_WEB_URL.format(protocol=protocol, year=date.year, month=date.month, day=date.day, seccion=seccion)
# 
# Path: bormeparser/utils.py
# def acto_to_attr(acto):
#     attr = remove_accents(acto).replace(' del ', ' ').replace(' por ', ' ').replace(' de ', ' ')
#     attr = attr.replace(' ', '_').replace('/', '_').replace('.', '_').lower()
#     attr = re.sub('[^A-Za-z_]+', '', attr)
#     return attr.rstrip('_')
# 
# Path: bormeparser/seccion.py
# class SECCION:
#     A = 'A'
#     B = 'B'
#     C = 'C'
# 
#     # TODO: No detecta tipo C, viene el texto comprimido
#     @staticmethod
#     def from_borme(seccion, subseccion):
#         if seccion in ('SECCIÓN PRIMERA', 'SECCIÓN PRIMERA'):
#             if subseccion == 'Actos inscritos':
#                 return SECCION.A
#             elif subseccion == 'Otros actos publicados en el Registro Mercantil':
#                 return SECCION.B
#             else:
#                 raise ValueError('InvalidSeccion: %s %s' % (seccion, subseccion))
#         else:
#             raise ValueError('InvalidSeccion: %s %s' % (seccion, subseccion))


import datetime
import unittest
from bormeparser.utils import get_borme_website
from bormeparser.utils import acto_to_attr
from bormeparser.seccion import SECCION
# Copyright (C) 2016-2017 Pablo Castellano <pablo@anche.no>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.




class BormeparserUtilsTestCase(unittest.TestCase):

    def test_get_borme_website(self):
        date = datetime.date(2016, 4, 21)
        url = get_borme_website(date, SECCION.A)
        self.assertEqual(url, 'https://www.boe.es/borme/dias/2016/04/21/index.php?s=A')
        url = get_borme_website(date, SECCION.C)
        self.assertEqual(url, 'https://www.boe.es/borme/dias/2016/04/21/index.php?s=C')

    def test_acto_to_attr(self):
        attr1 = acto_to_attr('Nombramientos')
        attr2 = acto_to_attr('Ceses/Dimisiones')

# Path: bormeparser/utils.py
# def get_borme_website(date, seccion, secure=True):
#     protocol = 'https' if secure else 'http'
#     return BORME_WEB_URL.format(protocol=protocol, year=date.year, month=date.month, day=date.day, seccion=seccion)
# 
# Path: bormeparser/utils.py
# def acto_to_attr(acto):
#     attr = remove_accents(acto).replace(' del ', ' ').replace(' por ', ' ').replace(' de ', ' ')
#     attr = attr.replace(' ', '_').replace('/', '_').replace('.', '_').lower()
#     attr = re.sub('[^A-Za-z_]+', '', attr)
#     return attr.rstrip('_')
# 
# Path: bormeparser/seccion.py
# class SECCION:
#     A = 'A'
#     B = 'B'
#     C = 'C'
# 
#     # TODO: No detecta tipo C, viene el texto comprimido
#     @staticmethod
#     def from_borme(seccion, subseccion):
#         if seccion in ('SECCIÓN PRIMERA', 'SECCIÓN PRIMERA'):
#             if subseccion == 'Actos inscritos':
#                 return SECCION.A
#             elif subseccion == 'Otros actos publicados en el Registro Mercantil':
#                 return SECCION.B
#             else:
#                 raise ValueError('InvalidSeccion: %s %s' % (seccion, subseccion))
#         else:
#             raise ValueError('InvalidSeccion: %s %s' % (seccion, subseccion))


# Path: bormeparser/tests/test_utils.py
import datetime
import unittest
from bormeparser.utils import get_borme_website
from bormeparser.utils import acto_to_attr
from bormeparser.seccion import SECCION

# Copyright (C) 2016-2017 Pablo Castellano <pablo@anche.no>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.




class BormeparserUtilsTestCase(unittest.TestCase):

    def test_get_borme_website(self):
        date = datetime.date(2016, 4, 21)
        url = get_borme_website(date, SECCION.A)
        self.assertEqual(url, 'https://www.boe.es/borme/dias/2016/04/21/index.php?s=A')
        url = get_borme_website(date, SECCION.C)
        self.assertEqual(url, 'https://www.boe.es/borme/dias/2016/04/21/index.php?s=C')

    def test_acto_to_attr(self):
        attr1 = acto_to_attr('Nombramientos')
        attr2 = acto_to_attr('Ceses/Dimisiones')

        attr3 = acto_to_attr('Fusión por absorción')