# Path: processing/importaffiliation.py
# REGEX_ARTICLE = re.compile("^S[0-9]{4}-[0-9]{3}[0-9xX][0-2][0-9]{3}[0-9]{4}[0-9]{5}$")
# def _config_logging(logging_level='INFO', logging_file=None):
# def is_valid_pid(pid):
# def parse_csv_line(data):
# def is_clean_checked(parsed_line, original_article):
# def get_original_article(pid, collection):
# def isis_like_json(data):
# def import_doc_affiliations(data, normalized_affiliations):
# def check_affiliations(file_name='processing/normalized_affiliations.csv', import_data=False, encoding='utf-8'):
# def main():


import unittest
from processing import importaffiliation
        class MockArticle(object):
            def __init__(self):
                self.publisher_id = u'S0001-37652013000100001'
                self.affiliations = [
                    {
                        'index': u'aff1',
                        'addr_line': u'Rio de Janeiro',
                        'institution': u'Museu Nacional/UFRJ',
                        'country': u'Brasil'
                    }
                ]

            @property
            def journal(self):

                j = MockJournal()
                return j

        self.mockarticle = MockArticle()

    def test_parse_csv_line_ok_isis_mfn(self):

        line = u'27136|scl|S0001-37652013000100001|2013|An. Acad. Bras. Ciênc.|v85n1|aff1|Museu Nacional/UFRJ|Brasil|Universidade Federal do Rio de Janeiro|Brazil|BR|São Paulo|SP'

        result = importaffiliation.parse_csv_line(line.split('|'))

        self.assertEqual(result['mfn'], u'27136')

    def test_parse_csv_line_ok_pid(self):


# Path: processing/importaffiliation.py
# REGEX_ARTICLE = re.compile("^S[0-9]{4}-[0-9]{3}[0-9xX][0-2][0-9]{3}[0-9]{4}[0-9]{5}$")
# def _config_logging(logging_level='INFO', logging_file=None):
# def is_valid_pid(pid):
# def parse_csv_line(data):
# def is_clean_checked(parsed_line, original_article):
# def get_original_article(pid, collection):
# def isis_like_json(data):
# def import_doc_affiliations(data, normalized_affiliations):
# def check_affiliations(file_name='processing/normalized_affiliations.csv', import_data=False, encoding='utf-8'):
# def main():


# Path: tests/test_processing_importaff.py
import unittest
from processing import importaffiliation

        class MockArticle(object):
            def __init__(self):
                self.publisher_id = u'S0001-37652013000100001'
                self.affiliations = [
                    {
                        'index': u'aff1',
                        'addr_line': u'Rio de Janeiro',
                        'institution': u'Museu Nacional/UFRJ',
                        'country': u'Brasil'
                    }
                ]

            @property
            def journal(self):

                j = MockJournal()
                return j

        self.mockarticle = MockArticle()

    def test_parse_csv_line_ok_isis_mfn(self):

        line = u'27136|scl|S0001-37652013000100001|2013|An. Acad. Bras. Ciênc.|v85n1|aff1|Museu Nacional/UFRJ|Brasil|Universidade Federal do Rio de Janeiro|Brazil|BR|São Paulo|SP'

        result = importaffiliation.parse_csv_line(line.split('|'))

        self.assertEqual(result['mfn'], u'27136')

    def test_parse_csv_line_ok_pid(self):


        line = u'27136|scl|S0001-37652013000100001|2013|An. Acad. Bras. Ciênc.|v85n1|aff1|Museu Nacional/UFRJ|Brasil|Universidade Federal do Rio de Janeiro|Brazil|BR|São Paulo|SP'