diff --git a/config_cwr/__init__.py b/config_cwr/__init__.py index 139597f..e69de29 100644 --- a/config_cwr/__init__.py +++ b/config_cwr/__init__.py @@ -1,2 +0,0 @@ - - diff --git a/config_cwr/accessor.py b/config_cwr/accessor.py index 8e44a79..cd26449 100644 --- a/config_cwr/accessor.py +++ b/config_cwr/accessor.py @@ -3,6 +3,7 @@ import os import yaml + from cwr.grammar.factory.config import rule_config_file """ diff --git a/cwr/__init__.py b/cwr/__init__.py index 67a6d23..52bf2c1 100644 --- a/cwr/__init__.py +++ b/cwr/__init__.py @@ -7,5 +7,5 @@ :license: MIT, see LICENSE for more details. """ -__version__ = '0.0.29' +__version__ = '0.0.30' __license__ = 'MIT' diff --git a/cwr/grammar/field/basic.py b/cwr/grammar/field/basic.py index 200ba24..60cf09f 100644 --- a/cwr/grammar/field/basic.py +++ b/cwr/grammar/field/basic.py @@ -294,7 +294,7 @@ def boolean(name=None): name = 'Boolean Field' # Basic field - field = pp.Combine(pp.Literal('Y') | pp.Literal('N')) + field = pp.Regex('[YN]') # Parse action field.setParseAction(lambda b: _to_boolean(b[0])) @@ -346,10 +346,7 @@ def flag(name=None): name = 'Flag Field' # Basic field - field = pp.Combine(pp.Word('YNU', exact=1)) - - # Parse action - field.setParseAction(lambda f: _to_flag(f[0])) + field = pp.Regex('[YNU]') # Name field.setName(name) @@ -359,26 +356,6 @@ def flag(name=None): return field -def _to_flag(string): - """ - Transforms a string into a flag value. - - If a value which is not 'Y', 'N' or 'U' is received, a ParseException is - thrown. - - The received string is untouched, so if no exception is thrown the same - value that is received will be the one returned. - - :param: string: the string to transform - :return: the received string - """ - - if string not in ('Y', 'N', 'U'): - raise pp.ParseException(string, msg='Is not a valid flag value') - - return string - - """ Date field (D). diff --git a/cwr/grammar/field/record.py b/cwr/grammar/field/record.py index b73445a..17664bc 100644 --- a/cwr/grammar/field/record.py +++ b/cwr/grammar/field/record.py @@ -16,6 +16,7 @@ # Acquires data sources _config = CWRConfiguration() + # RECORD FIELDS # Prefix fields diff --git a/cwr/grammar/field/special.py b/cwr/grammar/field/special.py index 640500f..d9b4688 100644 --- a/cwr/grammar/field/special.py +++ b/cwr/grammar/field/special.py @@ -4,7 +4,7 @@ import pyparsing as pp -from cwr.other import ISWCCode, IPIBaseNumber, VISAN, AVIKey +from cwr.other import VISAN, AVIKey from cwr.grammar.field import basic from config_cwr.accessor import CWRConfiguration from data_cwr.accessor import CWRTables @@ -31,6 +31,7 @@ lineEnd = pp.lineEnd.suppress() lineEnd.setName("End of line") + # CONCRETE CASES FIELDS @@ -53,31 +54,7 @@ def ipi_base_number(name=None): if name is None: name = 'IPI Base Number Field' - # Separators are '-' - separator = pp.Literal('-').suppress() - separator = separator.setName('IPI Base Number Separator') \ - .setResultsName('separator') - - # Header is a digit in uppercase - header = pp.Literal('I') - header = header.setName('IPI Base Number Header').setResultsName('header') - - # ID code is composed of 9 numbers - id_code = basic.numeric(9) - id_code = id_code.setName('ID Code').setResultsName('id_code') - id_code = id_code.setParseAction(lambda c: int(c[0])) - - # Check digit is a single number - check_digit = pp.Regex('[0-9]') - check_digit = check_digit.setName('Check Digit') \ - .setResultsName('check_digit') - check_digit = check_digit.setParseAction(lambda c: int(c[0])) - - # Digit followed separator, 9 numbers, separator and 1 number - field = pp.Group(header + separator + id_code + separator + check_digit) - - # Parse action - field.setParseAction(lambda c: _to_ipibasecode(c[0])) + field = pp.Regex('I-[0-9]{9}-[0-9]') # Name field.setName(name) @@ -93,21 +70,6 @@ def ipi_base_number(name=None): return field.setResultsName('ipi_base_n') -def _to_ipibasecode(code): - """ - Transforms the result of parsing an IPI Base Number code string into a - IPIBaseNumber instance. - - :param code: the parsed code - :return: a IPIBaseNumber instance - """ - - if code: - return IPIBaseNumber(code.header, code.id_code, code.check_digit) - else: - return code - - def ipi_name_number(name=None): """ IPI Name Number field. @@ -149,24 +111,8 @@ def iswc(name=None): if name is None: name = 'ISWC Field' - # Header is always T - header = pp.Literal('T').suppress() - header = header.setName('ISWC Header').setResultsName('header') - - # ID code is composed of 9 numbers - id_code = basic.numeric(9) - id_code = id_code.setName('ID Code').setResultsName('id_code') - - # Check digit is a single number - check_digit = basic.numeric(1) - check_digit = check_digit.setName('Check Digit') \ - .setResultsName('check_digit') - # T followed by 10 numbers - field = pp.Group(header + id_code + check_digit) - - # Parse action - field.setParseAction(lambda c: _to_iswccode(c[0])) + field = pp.Regex('T[0-9]{10}') # Name field.setName(name) @@ -177,20 +123,6 @@ def iswc(name=None): return field.setResultsName('iswc') -def _to_iswccode(code): - """ - Transforms the result of parsing a ISWC code string into a ISWCCode - instance. - - :param code: the parsed code - :return: a ISWCCode instance - """ - if code: - return ISWCCode(code.id_code, code.check_digit) - else: - return code - - def percentage(columns, maximum=100, name=None): """ Creates the grammar for a Numeric (N) field storing a percentage and @@ -307,19 +239,25 @@ def _isrc_short(name=None): if name is None: name = 'ISRC Field' - separator = pp.Literal('-') - country = basic.lookup(config.get_data('isrc_country_code')) - registrant = basic.alphanum(3) - year = pp.Regex('[0-9]{2}') - work_id = pp.Regex('[0-9]{2}') + # separator = pp.Literal('-') + country = config.get_data('isrc_country_code') + # registrant = basic.alphanum(3) + # year = pp.Regex('[0-9]{2}') + # work_id = pp.Regex('[0-9]{2}') - field = pp.Combine(country + separator + registrant + separator + year + - separator + work_id) + country_regex = '' + for c in country: + if len(country_regex) > 0: + country_regex += '|' + country_regex += c + country_regex = '(' + country_regex + ')' - country.setName('ISO-2 Country Code') - registrant.setName('Registrant') - year.setName('Year') - work_id.setName('Work ID') + field = pp.Regex(country_regex + '-.{3}-[0-9]{2}-[0-9]{2}') + + # country.setName('ISO-2 Country Code') + # registrant.setName('Registrant') + # year.setName('Year') + # work_id.setName('Work ID') field.setName(name) @@ -352,17 +290,24 @@ def _isrc_long(name=None): if name is None: name = 'ISRC Field' - country = basic.lookup(config.get_data('isrc_country_code')) - registrant = basic.alphanum(3) - year = pp.Regex('[0-9]{2}') - work_id = pp.Regex('[0-9]{5}') + country = config.get_data('isrc_country_code') + # registrant = basic.alphanum(3) + # year = pp.Regex('[0-9]{2}') + # work_id = pp.Regex('[0-9]{5}') + + country_regex = '' + for c in country: + if len(country_regex) > 0: + country_regex += '|' + country_regex += c + country_regex = '(' + country_regex + ')' - field = pp.Combine(country + registrant + year + work_id) + field = pp.Regex(country_regex + '.{3}[0-9]{2}[0-9]{5}') - country.setName('ISO-2 Country Code') - registrant.setName('Registrant') - year.setName('Year') - work_id.setName('Work ID') + # country.setName('ISO-2 Country Code') + # registrant.setName('Registrant') + # year.setName('Year') + # work_id.setName('Work ID') field.setName(name) @@ -382,39 +327,13 @@ def visan(name=None): if name is None: name = 'V-ISAN Field' - version = basic.numeric(8) - version = version.setName('Version').setResultsName('version') - - isan = basic.numeric(12) - isan = isan.setName('ISAN').setResultsName('isan') - - episode = basic.numeric(4) - episode = episode.setName('Episode').setResultsName('episode') - - check_digit = basic.numeric(1) - check_digit = check_digit.setName('Check Digit') \ - .setResultsName('check_digit') - - field = pp.Group(version + isan + episode + check_digit) - - field.setParseAction(lambda v: _to_visan(v[0])) + field = pp.Regex('[0-9]{25}') field.setName(name) return field.setResultsName('visan') -def _to_visan(parsed): - """ - Transforms the data from a V-ISAN field into a VISAN instance. - - :param parsed: the data parsed from a V-ISAN field - :return: a VISAN instance created from the data - """ - return VISAN(parsed.version, parsed.isan, parsed.episode, - parsed.check_digit) - - def audio_visual_key(name=None): """ Creates the grammar for an Audio Visual Key code. diff --git a/cwr/parser/decoder/dictionary.py b/cwr/parser/decoder/dictionary.py index 5145dda..23c3ce6 100644 --- a/cwr/parser/decoder/dictionary.py +++ b/cwr/parser/decoder/dictionary.py @@ -19,7 +19,7 @@ InstrumentationSummaryRecord, PerformingArtistRecord, WorkOriginRecord, \ WorkRecord from cwr.file import CWRFile, FileTag -from cwr.other import ISWCCode, IPIBaseNumber, AVIKey, VISAN +from cwr.other import AVIKey, VISAN from cwr.table_value import MediaTypeValue, TableValue, InstrumentValue """ @@ -917,16 +917,7 @@ def __init__(self): def decode(self, data): if data: - if isinstance(data, IPIBaseNumber): - result = data - elif isinstance(data, int) or data.__class__.__name__ == 'long': - result = IPIBaseNumber(None, - data, - None) - else: - result = IPIBaseNumber(data['header'], - data['id_code'], - data['check_digit']) + result = data else: result = None @@ -939,11 +930,7 @@ def __init__(self): def decode(self, data): if data: - if isinstance(data, ISWCCode): - result = data - else: - result = ISWCCode(data['id_code'], - data['check_digit']) + result = data else: result = None diff --git a/cwr/parser/decoder/file.py b/cwr/parser/decoder/file.py index 5c4adff..f2903e7 100644 --- a/cwr/parser/decoder/file.py +++ b/cwr/parser/decoder/file.py @@ -239,7 +239,6 @@ def default_file_decoder(): :return: a CWR file decoder for the default standard """ transmission_rule = default_grammar_factory().get_rule('transmission') - transmission_rule.enablePackrat() return FileDecoder( transmission_rule, diff --git a/cwr/parser/encoder/dictionary.py b/cwr/parser/encoder/dictionary.py index 67fc1cf..288839d 100644 --- a/cwr/parser/encoder/dictionary.py +++ b/cwr/parser/encoder/dictionary.py @@ -219,10 +219,7 @@ def __init__(self): def encode(self, iswc): if iswc: - encoded = {} - - encoded['id_code'] = iswc.id_code - encoded['check_digit'] = iswc.check_digit + encoded = iswc else: encoded = None @@ -235,11 +232,7 @@ def __init__(self): def encode(self, ipi): if ipi: - encoded = {} - - encoded['header'] = ipi.header - encoded['id_code'] = ipi.id_code - encoded['check_digit'] = ipi.check_digit + encoded = ipi else: encoded = None diff --git a/tests/grammar/factory/record/test_component.py b/tests/grammar/factory/record/test_component.py index 4f18102..d0a2d12 100644 --- a/tests/grammar/factory/record/test_component.py +++ b/tests/grammar/factory/record/test_component.py @@ -38,8 +38,7 @@ def test_valid_full(self): self.assertEqual(1234, result.transaction_sequence_n) self.assertEqual(23, result.record_sequence_n) self.assertEqual('THE TITLE', result.title) - self.assertEqual(12345678, result.iswc.id_code) - self.assertEqual(9, result.iswc.check_digit) + self.assertEqual('T0123456789', result.iswc) self.assertEqual('ABCD0123456789', result.submitter_work_n) self.assertEqual(3, result.duration.hour) self.assertEqual(2, result.duration.minute) @@ -50,12 +49,8 @@ def test_valid_full(self): self.assertEqual('LAST NAME 2', result.writer_2_last_name) self.assertEqual('FIRST NAME 2', result.writer_2_first_name) self.assertEqual(14107339, result.writer_2_ipi_name_n) - self.assertEqual('I', result.writer_1_ipi_base_n.header) - self.assertEqual(229, result.writer_1_ipi_base_n.id_code) - self.assertEqual(7, result.writer_1_ipi_base_n.check_digit) - self.assertEqual('I', result.writer_2_ipi_base_n.header) - self.assertEqual(230, result.writer_2_ipi_base_n.id_code) - self.assertEqual(7, result.writer_2_ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', result.writer_1_ipi_base_n) + self.assertEqual('I-000000230-7', result.writer_2_ipi_base_n) class TestComponentGrammarException(unittest.TestCase): diff --git a/tests/grammar/factory/record/test_entire_work_title.py b/tests/grammar/factory/record/test_entire_work_title.py index 060655b..c74d5b5 100644 --- a/tests/grammar/factory/record/test_entire_work_title.py +++ b/tests/grammar/factory/record/test_entire_work_title.py @@ -29,22 +29,17 @@ def test_valid_full(self): self.assertEqual(1234, result.transaction_sequence_n) self.assertEqual(23, result.record_sequence_n) self.assertEqual('THE TITLE', result.title) - self.assertEqual(12345678, result.iswc.id_code) - self.assertEqual(9, result.iswc.check_digit) + self.assertEqual('T0123456789', result.iswc) self.assertEqual('ES', result.language_code) self.assertEqual('LAST NAME 1', result.writer_1_last_name) self.assertEqual('FIRST NAME 1', result.writer_1_first_name) self.assertEqual('THE SOURCE', result.source) self.assertEqual(14107338, result.writer_1_ipi_name_n) - self.assertEqual('I', result.writer_1_ipi_base_n.header) - self.assertEqual(229, result.writer_1_ipi_base_n.id_code) - self.assertEqual(7, result.writer_1_ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', result.writer_1_ipi_base_n) self.assertEqual('LAST NAME 2', result.writer_2_last_name) self.assertEqual('FIRST NAME 2', result.writer_2_first_name) self.assertEqual(14107339, result.writer_2_ipi_name_n) - self.assertEqual('I', result.writer_2_ipi_base_n.header) - self.assertEqual(230, result.writer_2_ipi_base_n.id_code) - self.assertEqual(7, result.writer_2_ipi_base_n.check_digit) + self.assertEqual('I-000000230-7', result.writer_2_ipi_base_n) self.assertEqual('ABCD0123456789', result.submitter_work_n) diff --git a/tests/grammar/factory/record/test_interested_party_agreement.py b/tests/grammar/factory/record/test_interested_party_agreement.py index 97c33cd..d7268e0 100644 --- a/tests/grammar/factory/record/test_interested_party_agreement.py +++ b/tests/grammar/factory/record/test_interested_party_agreement.py @@ -64,9 +64,7 @@ def test_valid_full(self): self.assertEqual(1234, result.transaction_sequence_n) self.assertEqual(23, result.record_sequence_n) self.assertEqual('AC', result.agreement_role_code) - self.assertEqual('I', result.ipi_base_n.header) - self.assertEqual(229, result.ipi_base_n.id_code) - self.assertEqual(7, result.ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', result.ipi_base_n) self.assertEqual(1234567890, result.ipi_name_n) self.assertEqual('A12345678', result.ip_n) self.assertEqual('LAST NAME', result.ip_last_name) @@ -92,9 +90,7 @@ def test_societies_lowest(self): self.assertEqual(1234, result.transaction_sequence_n) self.assertEqual(23, result.record_sequence_n) self.assertEqual('AC', result.agreement_role_code) - self.assertEqual('I', result.ipi_base_n.header) - self.assertEqual(229, result.ipi_base_n.id_code) - self.assertEqual(7, result.ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', result.ipi_base_n) self.assertEqual(1234567890, result.ipi_name_n) self.assertEqual('A12345678', result.ip_n) self.assertEqual('LAST NAME', result.ip_last_name) diff --git a/tests/grammar/factory/record/test_npr.py b/tests/grammar/factory/record/test_npr.py index 460d984..915a5c5 100644 --- a/tests/grammar/factory/record/test_npr.py +++ b/tests/grammar/factory/record/test_npr.py @@ -36,9 +36,7 @@ def test_valid_full(self): self.assertEqual('NAME', result.performing_artist_name) self.assertEqual('FIRST NAME', result.performing_artist_first_name) self.assertEqual(14107338, result.performing_artist_ipi_name_n) - self.assertEqual('I', result.performing_artist_ipi_base_n.header) - self.assertEqual(229, result.performing_artist_ipi_base_n.id_code) - self.assertEqual(7, result.performing_artist_ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', result.performing_artist_ipi_base_n) self.assertEqual('ES', result.language_code) self.assertEqual('EN', result.performance_language) self.assertEqual('CAN', result.performance_dialect) @@ -60,9 +58,7 @@ def test_extended_character(self): self.assertEqual('FIRST NAME \xc6\x8f', result.performing_artist_first_name) self.assertEqual(14107338, result.performing_artist_ipi_name_n) - self.assertEqual('I', result.performing_artist_ipi_base_n.header) - self.assertEqual(229, result.performing_artist_ipi_base_n.id_code) - self.assertEqual(7, result.performing_artist_ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', result.performing_artist_ipi_base_n) self.assertEqual('ES', result.language_code) self.assertEqual('EN', result.performance_language) self.assertEqual('CAN', result.performance_dialect) diff --git a/tests/grammar/factory/record/test_original_work_title.py b/tests/grammar/factory/record/test_original_work_title.py index 3346c3b..3a9b131 100644 --- a/tests/grammar/factory/record/test_original_work_title.py +++ b/tests/grammar/factory/record/test_original_work_title.py @@ -29,22 +29,17 @@ def test_valid_full(self): self.assertEqual(1234, result.transaction_sequence_n) self.assertEqual(23, result.record_sequence_n) self.assertEqual('THE TITLE', result.title) - self.assertEqual(12345678, result.iswc.id_code) - self.assertEqual(9, result.iswc.check_digit) + self.assertEqual('T0123456789', result.iswc) self.assertEqual('ES', result.language_code) self.assertEqual('LAST NAME 1', result.writer_1_last_name) self.assertEqual('FIRST NAME 1', result.writer_1_first_name) self.assertEqual('THE SOURCE', result.source) self.assertEqual(14107338, result.writer_1_ipi_name_n) - self.assertEqual('I', result.writer_1_ipi_base_n.header) - self.assertEqual(229, result.writer_1_ipi_base_n.id_code) - self.assertEqual(7, result.writer_1_ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', result.writer_1_ipi_base_n) self.assertEqual('LAST NAME 2', result.writer_2_last_name) self.assertEqual('FIRST NAME 2', result.writer_2_first_name) self.assertEqual(14107339, result.writer_2_ipi_name_n) - self.assertEqual('I', result.writer_2_ipi_base_n.header) - self.assertEqual(230, result.writer_2_ipi_base_n.id_code) - self.assertEqual(7, result.writer_2_ipi_base_n.check_digit) + self.assertEqual('I-000000230-7', result.writer_2_ipi_base_n) self.assertEqual('ABCD0123456789', result.submitter_work_n) diff --git a/tests/grammar/factory/record/test_performing_artist.py b/tests/grammar/factory/record/test_performing_artist.py index a3cdcc0..bd53765 100644 --- a/tests/grammar/factory/record/test_performing_artist.py +++ b/tests/grammar/factory/record/test_performing_artist.py @@ -31,9 +31,7 @@ def test_valid_full(self): self.assertEqual('LAST NAME', result.performing_artist_last_name) self.assertEqual('FIRST NAME', result.performing_artist_first_name) self.assertEqual(14107338, result.performing_artist_ipi_name_n) - self.assertEqual('I', result.performing_artist_ipi_base_n.header) - self.assertEqual(229, result.performing_artist_ipi_base_n.id_code) - self.assertEqual(7, result.performing_artist_ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', result.performing_artist_ipi_base_n) class TestPerformingArtistGrammarException(unittest.TestCase): diff --git a/tests/grammar/factory/record/test_publisher.py b/tests/grammar/factory/record/test_publisher.py index 6c5096a..bddf200 100644 --- a/tests/grammar/factory/record/test_publisher.py +++ b/tests/grammar/factory/record/test_publisher.py @@ -81,9 +81,7 @@ def test_valid_full(self): self.assertEqual(23.12, result.sr_ownership_share) self.assertEqual('B', result.special_agreements) self.assertEqual('Y', result.first_recording_refusal) - self.assertEqual('I', result.publisher.ipi_base_n.header) - self.assertEqual(229, result.publisher.ipi_base_n.id_code) - self.assertEqual(7, result.publisher.ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', result.publisher.ipi_base_n) self.assertEqual('A0123456789124', result.international_standard_code) self.assertEqual('A0123456789125', result.society_assigned_agreement_n) self.assertEqual('OS', result.agreement_type) diff --git a/tests/grammar/factory/record/test_work.py b/tests/grammar/factory/record/test_work.py index 8e8bb69..6b26e5e 100644 --- a/tests/grammar/factory/record/test_work.py +++ b/tests/grammar/factory/record/test_work.py @@ -75,8 +75,7 @@ def test_valid_common_b(self): self.assertEqual('MUSIC WORK', result.title) self.assertEqual('ES', result.language_code) self.assertEqual('000000199', result.submitter_work_n) - self.assertEqual(35117711, result.iswc.id_code) - self.assertEqual(1, result.iswc.check_digit) + self.assertEqual('T0351177111', result.iswc) self.assertEqual(2039, result.copyright_date.year) self.assertEqual(10, result.copyright_date.month) self.assertEqual(2, result.copyright_date.day) @@ -119,8 +118,7 @@ def test_valid_full(self): self.assertEqual('TITLE OF THE WORK', result.title) self.assertEqual('EN', result.language_code) self.assertEqual('ABCD0123456789', result.submitter_work_n) - self.assertEqual(12345678, result.iswc.id_code) - self.assertEqual(9, result.iswc.check_digit) + self.assertEqual('T0123456789', result.iswc) self.assertEqual(1, result.copyright_date.month) self.assertEqual(2, result.copyright_date.day) self.assertEqual(2013, result.copyright_date.year) @@ -165,8 +163,7 @@ def test_valid_minimum(self): self.assertEqual('TITLE OF THE WORK', result.title) self.assertEqual('EN', result.language_code) self.assertEqual('ABCD0123456789', result.submitter_work_n) - self.assertEqual(12345678, result.iswc.id_code) - self.assertEqual(9, result.iswc.check_digit) + self.assertEqual('T0123456789', result.iswc) self.assertEqual(1, result.copyright_date.month) self.assertEqual(2, result.copyright_date.day) self.assertEqual(2013, result.copyright_date.year) diff --git a/tests/grammar/factory/record/test_work_conflict.py b/tests/grammar/factory/record/test_work_conflict.py index 840bdb2..7dd1ef0 100644 --- a/tests/grammar/factory/record/test_work_conflict.py +++ b/tests/grammar/factory/record/test_work_conflict.py @@ -38,8 +38,7 @@ def test_valid_full(self): self.assertEqual('TITLE OF THE WORK', result.title) self.assertEqual('EN', result.language_code) self.assertEqual('ABCD0123456789', result.submitter_work_n) - self.assertEqual(12345678, result.iswc.id_code) - self.assertEqual(9, result.iswc.check_digit) + self.assertEqual('T0123456789', result.iswc) self.assertEqual(1, result.copyright_date.month) self.assertEqual(2, result.copyright_date.day) self.assertEqual(2013, result.copyright_date.year) @@ -84,8 +83,7 @@ def test_valid_minimum(self): self.assertEqual('TITLE OF THE WORK', result.title) self.assertEqual('EN', result.language_code) self.assertEqual('ABCD0123456789', result.submitter_work_n) - self.assertEqual(12345678, result.iswc.id_code) - self.assertEqual(9, result.iswc.check_digit) + self.assertEqual('T0123456789', result.iswc) self.assertEqual(1, result.copyright_date.month) self.assertEqual(2, result.copyright_date.day) self.assertEqual(2013, result.copyright_date.year) diff --git a/tests/grammar/factory/record/test_work_origin.py b/tests/grammar/factory/record/test_work_origin.py index c72f542..a861607 100644 --- a/tests/grammar/factory/record/test_work_origin.py +++ b/tests/grammar/factory/record/test_work_origin.py @@ -34,10 +34,7 @@ def test_full(self): self.assertEqual(1234, result.cut_number) self.assertEqual('THE LIBRARY', result.library) self.assertEqual('B', result.bltvr) - self.assertEqual(12345678, result.visan.version) - self.assertEqual(123456789012, result.visan.isan) - self.assertEqual(1234, result.visan.episode) - self.assertEqual(1, result.visan.check_digit) + self.assertEqual('1234567812345678901212341', result.visan) self.assertEqual('ABDFE', result.production_n) self.assertEqual('EPISODE TITLE', result.episode_title) self.assertEqual('ABD12345', result.episode_n) @@ -59,10 +56,7 @@ def test_common(self): self.assertEqual(0, result.cut_number) self.assertEqual(None, result.library) self.assertEqual(None, result.bltvr) - self.assertEqual(0, result.visan.version) - self.assertEqual(0, result.visan.isan) - self.assertEqual(0, result.visan.episode) - self.assertEqual(0, result.visan.check_digit) + self.assertEqual('0000000000000000000000000', result.visan) self.assertEqual(None, result.production_n) self.assertEqual('EPISODE TITLE', result.episode_title) self.assertEqual(None, result.episode_n) diff --git a/tests/grammar/factory/record/test_writer.py b/tests/grammar/factory/record/test_writer.py index 5792978..9fa6af0 100644 --- a/tests/grammar/factory/record/test_writer.py +++ b/tests/grammar/factory/record/test_writer.py @@ -119,9 +119,7 @@ def test_valid_full(self): self.assertEqual('Y', result.reversionary) self.assertEqual('Y', result.first_recording_refusal) self.assertEqual('Y', result.work_for_hire) - self.assertEqual('I', result.writer.ipi_base_n.header) - self.assertEqual(229, result.writer.ipi_base_n.id_code) - self.assertEqual(7, result.writer.ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', result.writer.ipi_base_n) self.assertEqual(12345678901, result.writer.personal_number) self.assertEqual('B', result.usa_license) @@ -149,9 +147,7 @@ def test_ipi_number(self): self.assertEqual('Y', result.reversionary) self.assertEqual('Y', result.first_recording_refusal) self.assertEqual('Y', result.work_for_hire) - self.assertEqual(None, result.writer.ipi_base_n.header) - self.assertEqual(1234567890123, result.writer.ipi_base_n.id_code) - self.assertEqual(None, result.writer.ipi_base_n.check_digit) + self.assertEqual(1234567890123, result.writer.ipi_base_n) self.assertEqual(12345678901, result.writer.personal_number) self.assertEqual('B', result.usa_license) diff --git a/tests/grammar/field/special/test_ipi_base_number.py b/tests/grammar/field/special/test_ipi_base_number.py index dec5305..d6e0f92 100644 --- a/tests/grammar/field/special/test_ipi_base_number.py +++ b/tests/grammar/field/special/test_ipi_base_number.py @@ -27,9 +27,7 @@ def test_common(self): result = self.ipi.parseString(code) - self.assertEqual('I', result.ipi_base_n.header) - self.assertEqual(229, result.ipi_base_n.id_code) - self.assertEqual(7, result.ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', result.ipi_base_n) class TestIPIBaseNumberValid(unittest.TestCase): @@ -48,9 +46,7 @@ def test_common(self): result = self.ipi.parseString(code)[0] - self.assertEqual('I', result.header) - self.assertEqual(229, result.id_code) - self.assertEqual(7, result.check_digit) + self.assertEqual('I-000000229-7', result) def test_max(self): """ @@ -60,9 +56,7 @@ def test_max(self): result = self.ipi.parseString(code)[0] - self.assertEqual('I', result.header) - self.assertEqual(999999999, result.id_code) - self.assertEqual(9, result.check_digit) + self.assertEqual('I-999999999-9', result) def test_min(self): """ @@ -72,9 +66,7 @@ def test_min(self): result = self.ipi.parseString(code)[0] - self.assertEqual('I', result.header) - self.assertEqual(0, result.id_code) - self.assertEqual(0, result.check_digit) + self.assertEqual('I-000000000-0', result) class TestIPIBaseNumberException(unittest.TestCase): diff --git a/tests/grammar/field/special/test_iswc.py b/tests/grammar/field/special/test_iswc.py index cf12ddf..179a073 100644 --- a/tests/grammar/field/special/test_iswc.py +++ b/tests/grammar/field/special/test_iswc.py @@ -27,9 +27,7 @@ def test_common(self): result = self.iswc.parseString(code) - self.assertEqual('T', result.iswc.header) - self.assertEqual(34524680, result.iswc.id_code) - self.assertEqual(1, result.iswc.check_digit) + self.assertEqual('T0345246801', result.iswc) class TestISWCValid(unittest.TestCase): @@ -48,9 +46,7 @@ def test_common(self): result = self.iswc.parseString(code)[0] - self.assertEqual('T', result.header) - self.assertEqual(34524680, result.id_code) - self.assertEqual(1, result.check_digit) + self.assertEqual('T0345246801', result) def test_max(self): """ @@ -60,9 +56,7 @@ def test_max(self): result = self.iswc.parseString(code)[0] - self.assertEqual('T', result.header) - self.assertEqual(999999999, result.id_code) - self.assertEqual(9, result.check_digit) + self.assertEqual('T9999999999', result) def test_min(self): """ @@ -72,9 +66,7 @@ def test_min(self): result = self.iswc.parseString(code)[0] - self.assertEqual('T', result.header) - self.assertEqual(000000000, result.id_code) - self.assertEqual(0, result.check_digit) + self.assertEqual('T0000000000', result) class TestISWCException(unittest.TestCase): diff --git a/tests/grammar/field/special/test_visan.py b/tests/grammar/field/special/test_visan.py index e893904..490b4a0 100644 --- a/tests/grammar/field/special/test_visan.py +++ b/tests/grammar/field/special/test_visan.py @@ -24,10 +24,7 @@ def test_common(self): result = self.ean.parseString(code)[0] - self.assertEqual(1234567, result.version) - self.assertEqual(12345678912, result.isan) - self.assertEqual(123, result.episode) - self.assertEqual(1, result.check_digit) + self.assertEqual('0123456701234567891201231', result) class TestVISANResultName(unittest.TestCase): @@ -43,7 +40,4 @@ def test_common(self): result = self.ean.parseString(code) - self.assertEqual(1234567, result.visan.version) - self.assertEqual(12345678912, result.visan.isan) - self.assertEqual(123, result.visan.episode) - self.assertEqual(1, result.visan.check_digit) + self.assertEqual('0123456701234567891201231', result.visan) diff --git a/tests/parser/dictionary/decoder/interested_party/test_publisher.py b/tests/parser/dictionary/decoder/interested_party/test_publisher.py index a4d51b2..9ca21f1 100644 --- a/tests/parser/dictionary/decoder/interested_party/test_publisher.py +++ b/tests/parser/dictionary/decoder/interested_party/test_publisher.py @@ -20,18 +20,12 @@ def setUp(self): self._decoder = PublisherDictionaryDecoder() def test_encoded(self): - ipi_base = {} - - ipi_base['header'] = 'I' - ipi_base['id_code'] = 229 - ipi_base['check_digit'] = 7 - data = {} data['ip_n'] = 'IP123' data['publisher_name'] = 'NAME' data['ipi_name_n'] = 250165006 - data['ipi_base_n'] = ipi_base + data['ipi_base_n'] = 'I-000000229-7' data['tax_id'] = 923703412 record = self._decoder.decode(data) @@ -41,6 +35,4 @@ def test_encoded(self): self.assertEqual(250165006, record.ipi_name_n) self.assertEqual(923703412, record.tax_id) - self.assertEqual('I', record.ipi_base_n.header) - self.assertEqual(229, record.ipi_base_n.id_code) - self.assertEqual(7, record.ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', record.ipi_base_n) diff --git a/tests/parser/dictionary/decoder/interested_party/test_writer.py b/tests/parser/dictionary/decoder/interested_party/test_writer.py index 39f14f2..97fdd86 100644 --- a/tests/parser/dictionary/decoder/interested_party/test_writer.py +++ b/tests/parser/dictionary/decoder/interested_party/test_writer.py @@ -20,18 +20,12 @@ def setUp(self): self._decoder = WriterDictionaryDecoder() def test_encoded(self): - ipi_base = {} - - ipi_base['header'] = 'I' - ipi_base['id_code'] = 229 - ipi_base['check_digit'] = 7 - data = {} data['ip_n'] = 'ABC15' data['personal_number'] = 'ABC1234' data['ipi_name_n'] = 14107338 - data['ipi_base_n'] = ipi_base + data['ipi_base_n'] = 'I-000000229-7' data['writer_first_name'] = 'NAME' data['writer_last_name'] = 'LAST NAME' data['tax_id'] = 923703412 @@ -45,6 +39,4 @@ def test_encoded(self): self.assertEqual('LAST NAME', record.writer_last_name) self.assertEqual(923703412, record.tax_id) - self.assertEqual('I', record.ipi_base_n.header) - self.assertEqual(229, record.ipi_base_n.id_code) - self.assertEqual(7, record.ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', record.ipi_base_n) diff --git a/tests/parser/dictionary/decoder/other/test_ipi_base.py b/tests/parser/dictionary/decoder/other/test_ipi_base.py index ec80178..5151f5e 100644 --- a/tests/parser/dictionary/decoder/other/test_ipi_base.py +++ b/tests/parser/dictionary/decoder/other/test_ipi_base.py @@ -20,14 +20,6 @@ def setUp(self): self._decoder = IPIBaseDictionaryDecoder() def test_encoded(self): - data = {} + record = self._decoder.decode('I-000000229-7') - data['header'] = 'T' - data['id_code'] = 123456789 - data['check_digit'] = 1 - - record = self._decoder.decode(data) - - self.assertEqual('T', record.header) - self.assertEqual(123456789, record.id_code) - self.assertEqual(1, record.check_digit) + self.assertEqual('I-000000229-7', record) diff --git a/tests/parser/dictionary/decoder/other/test_iswc.py b/tests/parser/dictionary/decoder/other/test_iswc.py index 23e2ece..512dadb 100644 --- a/tests/parser/dictionary/decoder/other/test_iswc.py +++ b/tests/parser/dictionary/decoder/other/test_iswc.py @@ -20,13 +20,6 @@ def setUp(self): self._decoder = ISWCDictionaryDecoder() def test_encoded(self): - data = {} + record = self._decoder.decode('T0123456789') - data['id_code'] = 123456789 - data['check_digit'] = 1 - - record = self._decoder.decode(data) - - self.assertEqual('T', record.header) - self.assertEqual(123456789, record.id_code) - self.assertEqual(1, record.check_digit) + self.assertEqual('T0123456789', record) diff --git a/tests/parser/dictionary/decoder/record/test_authored_work.py b/tests/parser/dictionary/decoder/record/test_authored_work.py index 4cc0015..5433b6b 100644 --- a/tests/parser/dictionary/decoder/record/test_authored_work.py +++ b/tests/parser/dictionary/decoder/record/test_authored_work.py @@ -21,18 +21,6 @@ def setUp(self): self._decoder = AuthoredWorkDictionaryDecoder() def test_encoded(self): - ipi_base_1 = {} - - ipi_base_1['header'] = 'I' - ipi_base_1['id_code'] = 229 - ipi_base_1['check_digit'] = 7 - - ipi_base_2 = {} - - ipi_base_2['header'] = 'I' - ipi_base_2['id_code'] = 339 - ipi_base_2['check_digit'] = 7 - data = {} data['record_type'] = 'EWT' @@ -45,9 +33,9 @@ def test_encoded(self): data['writer_2_first_name'] = 'FIRST NAME 2' data['writer_2_last_name'] = 'LAST NAME 2' data['writer_1_ipi_name_n'] = 250165006 - data['writer_1_ipi_base_n'] = ipi_base_1 + data['writer_1_ipi_base_n'] = 'I-000000229-7' data['writer_2_ipi_name_n'] = 350165006 - data['writer_2_ipi_base_n'] = ipi_base_2 + data['writer_2_ipi_base_n'] = 'I-000000339-7' data['source'] = 'SOURCE' data['language_code'] = 'ES' data['iswc'] = ISWCCode(12345678, 9) @@ -70,10 +58,6 @@ def test_encoded(self): self.assertEqual(12345678, record.iswc.id_code) self.assertEqual(9, record.iswc.check_digit) - self.assertEqual('I', record.writer_1_ipi_base_n.header) - self.assertEqual(229, record.writer_1_ipi_base_n.id_code) - self.assertEqual(7, record.writer_1_ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', record.writer_1_ipi_base_n) - self.assertEqual('I', record.writer_2_ipi_base_n.header) - self.assertEqual(339, record.writer_2_ipi_base_n.id_code) - self.assertEqual(7, record.writer_2_ipi_base_n.check_digit) + self.assertEqual('I-000000339-7', record.writer_2_ipi_base_n) diff --git a/tests/parser/dictionary/decoder/record/test_component.py b/tests/parser/dictionary/decoder/record/test_component.py index 5e2471a..5fd50f5 100644 --- a/tests/parser/dictionary/decoder/record/test_component.py +++ b/tests/parser/dictionary/decoder/record/test_component.py @@ -22,18 +22,6 @@ def setUp(self): self._decoder = ComponentDictionaryDecoder() def test_encoded(self): - ipi_base_1 = {} - - ipi_base_1['header'] = 'I' - ipi_base_1['id_code'] = 229 - ipi_base_1['check_digit'] = 7 - - ipi_base_2 = {} - - ipi_base_2['header'] = 'I' - ipi_base_2['id_code'] = 339 - ipi_base_2['check_digit'] = 7 - data = {} data['record_type'] = 'COM' @@ -46,9 +34,9 @@ def test_encoded(self): data['writer_2_last_name'] = 'LAST NAME 2' data['writer_2_first_name'] = 'FIRST NAME 2' data['writer_1_ipi_name_n'] = 14107338 - data['writer_1_ipi_base_n'] = ipi_base_1 + data['writer_1_ipi_base_n'] = 'I-000000229-7' data['writer_2_ipi_name_n'] = 14107400 - data['writer_2_ipi_base_n'] = ipi_base_2 + data['writer_2_ipi_base_n'] = 'I-000000339-7' data['iswc'] = ISWCCode(12345678, 9) data['duration'] = datetime.datetime.strptime('011200', '%H%M%S').time() @@ -71,10 +59,6 @@ def test_encoded(self): self.assertEqual(datetime.datetime.strptime('011200', '%H%M%S').time(), record.duration) - self.assertEqual('I', record.writer_1_ipi_base_n.header) - self.assertEqual(229, record.writer_1_ipi_base_n.id_code) - self.assertEqual(7, record.writer_1_ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', record.writer_1_ipi_base_n) - self.assertEqual('I', record.writer_2_ipi_base_n.header) - self.assertEqual(339, record.writer_2_ipi_base_n.id_code) - self.assertEqual(7, record.writer_2_ipi_base_n.check_digit) + self.assertEqual('I-000000339-7', record.writer_2_ipi_base_n) diff --git a/tests/parser/dictionary/decoder/record/test_interested_party_for_agreement.py b/tests/parser/dictionary/decoder/record/test_interested_party_for_agreement.py index 5de27bf..c4ea858 100644 --- a/tests/parser/dictionary/decoder/record/test_interested_party_for_agreement.py +++ b/tests/parser/dictionary/decoder/record/test_interested_party_for_agreement.py @@ -21,12 +21,6 @@ def setUp(self): self._decoder = InterestedPartyForAgreementDictionaryDecoder() def test_encoded(self): - ipi_base = {} - - ipi_base['header'] = 'I' - ipi_base['id_code'] = 229 - ipi_base['check_digit'] = 7 - data = {} data['record_type'] = 'IPA' @@ -37,7 +31,7 @@ def test_encoded(self): data['agreement_role_code'] = 'AS' data['ip_writer_first_name'] = 'FIRST NAME' data['ipi_name_n'] = 250165006 - data['ipi_base_n'] = ipi_base + data['ipi_base_n'] = 'I-000000229-7' data['pr_society'] = 1 data['pr_share'] = 50.1 data['mr_society'] = 2 @@ -62,6 +56,4 @@ def test_encoded(self): self.assertEqual(3, record.sr_society) self.assertEqual(50.3, record.sr_share) - self.assertEqual('I', record.ipi_base_n.header) - self.assertEqual(229, record.ipi_base_n.id_code) - self.assertEqual(7, record.ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', record.ipi_base_n) diff --git a/tests/parser/dictionary/decoder/record/test_non_roman_alphabet_performance_data.py b/tests/parser/dictionary/decoder/record/test_non_roman_alphabet_performance_data.py index 65410ae..7053715 100644 --- a/tests/parser/dictionary/decoder/record/test_non_roman_alphabet_performance_data.py +++ b/tests/parser/dictionary/decoder/record/test_non_roman_alphabet_performance_data.py @@ -21,12 +21,6 @@ def setUp(self): self._decoder = NonRomanAlphabetPerformanceDataDictionaryDecoder() def test_encoded(self): - ipi_base = {} - - ipi_base['header'] = 'I' - ipi_base['id_code'] = 229 - ipi_base['check_digit'] = 7 - data = {} data['record_type'] = 'NPR' @@ -35,7 +29,7 @@ def test_encoded(self): data['performing_artist_first_name'] = 'FIRST NAME' data['performing_artist_name'] = 'NAME' data['performing_artist_ipi_name_n'] = 250165006 - data['performing_artist_ipi_base_n'] = ipi_base + data['performing_artist_ipi_base_n'] = 'I-000000229-7' data['language_code'] = 'ES' data['performance_language'] = 'EN' data['performance_dialect'] = 'EUS' @@ -52,6 +46,4 @@ def test_encoded(self): self.assertEqual('EN', record.performance_language) self.assertEqual('EUS', record.performance_dialect) - self.assertEqual('I', record.performing_artist_ipi_base_n.header) - self.assertEqual(229, record.performing_artist_ipi_base_n.id_code) - self.assertEqual(7, record.performing_artist_ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', record.performing_artist_ipi_base_n) diff --git a/tests/parser/dictionary/decoder/record/test_performing_artist.py b/tests/parser/dictionary/decoder/record/test_performing_artist.py index 9017158..55d7a08 100644 --- a/tests/parser/dictionary/decoder/record/test_performing_artist.py +++ b/tests/parser/dictionary/decoder/record/test_performing_artist.py @@ -20,12 +20,6 @@ def setUp(self): self._decoder = PerformingArtistDictionaryDecoder() def test_encoded(self): - ipi_base = {} - - ipi_base['header'] = 'I' - ipi_base['id_code'] = 229 - ipi_base['check_digit'] = 7 - data = {} data['record_type'] = 'PER' @@ -34,7 +28,7 @@ def test_encoded(self): data['performing_artist_last_name'] = 'LAST NAME' data['performing_artist_first_name'] = 'FIRST NAME' data['performing_artist_ipi_name_n'] = 250165006 - data['performing_artist_ipi_base_n'] = ipi_base + data['performing_artist_ipi_base_n'] = 'I-000000229-7' record = self._decoder.decode(data) @@ -45,6 +39,4 @@ def test_encoded(self): self.assertEqual('FIRST NAME', record.performing_artist_first_name) self.assertEqual(250165006, record.performing_artist_ipi_name_n) - self.assertEqual('I', record.performing_artist_ipi_base_n.header) - self.assertEqual(229, record.performing_artist_ipi_base_n.id_code) - self.assertEqual(7, record.performing_artist_ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', record.performing_artist_ipi_base_n) diff --git a/tests/parser/dictionary/decoder/record/test_publisher.py b/tests/parser/dictionary/decoder/record/test_publisher.py index 974d717..4ac9938 100644 --- a/tests/parser/dictionary/decoder/record/test_publisher.py +++ b/tests/parser/dictionary/decoder/record/test_publisher.py @@ -20,18 +20,12 @@ def setUp(self): self._decoder = PublisherRecordDictionaryDecoder() def test_encoded(self): - ipi_base = {} - - ipi_base['header'] = 'I' - ipi_base['id_code'] = 229 - ipi_base['check_digit'] = 7 - publisher = {} publisher['ip_n'] = 'IP123' publisher['publisher_name'] = 'NAME' publisher['ipi_name_n'] = 250165006 - publisher['ipi_base_n'] = ipi_base + publisher['ipi_base_n'] = 'I-000000229-7' publisher['tax_id'] = 923703412 data = {} @@ -65,9 +59,7 @@ def test_encoded(self): self.assertEqual(250165006, record.publisher.ipi_name_n) self.assertEqual(923703412, record.publisher.tax_id) - self.assertEqual('I', record.publisher.ipi_base_n.header) - self.assertEqual(229, record.publisher.ipi_base_n.id_code) - self.assertEqual(7, record.publisher.ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', record.publisher.ipi_base_n) self.assertEqual('SPU', record.record_type) self.assertEqual(3, record.transaction_sequence_n) diff --git a/tests/parser/dictionary/decoder/record/test_writer.py b/tests/parser/dictionary/decoder/record/test_writer.py index 574defa..26291e4 100644 --- a/tests/parser/dictionary/decoder/record/test_writer.py +++ b/tests/parser/dictionary/decoder/record/test_writer.py @@ -20,18 +20,12 @@ def setUp(self): self._decoder = WriterRecordDictionaryDecoder() def test_encoded(self): - ipi_base = {} - - ipi_base['header'] = 'I' - ipi_base['id_code'] = 229 - ipi_base['check_digit'] = 7 - writer = {} writer['ip_n'] = 'ABC15' writer['personal_number'] = 'ABC1234' writer['ipi_name_n'] = 14107338 - writer['ipi_base_n'] = ipi_base + writer['ipi_base_n'] = 'I-000000229-7' writer['writer_first_name'] = 'NAME' writer['writer_last_name'] = 'LAST NAME' writer['tax_id'] = 923703412 @@ -65,9 +59,7 @@ def test_encoded(self): self.assertEqual('LAST NAME', record.writer.writer_last_name) self.assertEqual(923703412, record.writer.tax_id) - self.assertEqual('I', record.writer.ipi_base_n.header) - self.assertEqual(229, record.writer.ipi_base_n.id_code) - self.assertEqual(7, record.writer.ipi_base_n.check_digit) + self.assertEqual('I-000000229-7', record.writer.ipi_base_n) self.assertEqual('SWR', record.record_type) self.assertEqual(3, record.transaction_sequence_n) diff --git a/tests/parser/dictionary/encoder/interested_party/test_publisher.py b/tests/parser/dictionary/encoder/interested_party/test_publisher.py index 582e15f..d556b05 100644 --- a/tests/parser/dictionary/encoder/interested_party/test_publisher.py +++ b/tests/parser/dictionary/encoder/interested_party/test_publisher.py @@ -4,7 +4,6 @@ from cwr.parser.encoder.dictionary import PublisherDictionaryEncoder from cwr.interested_party import Publisher -from cwr.other import IPIBaseNumber """ Publisher to dictionary encoding tests. @@ -22,12 +21,10 @@ def setUp(self): self._encoder = PublisherDictionaryEncoder() def test_encoded(self): - ipi_base = IPIBaseNumber('I', 229, 7) - data = Publisher(ip_n='ABC15', publisher_name='NAME', ipi_name_n=14107338, - ipi_base_n=ipi_base, + ipi_base_n='I-000000229-7', tax_id=923703412) encoded = self._encoder.encode(data) @@ -37,6 +34,4 @@ def test_encoded(self): self.assertEqual(14107338, encoded['ipi_name_n']) self.assertEqual(923703412, encoded['tax_id']) - self.assertEqual('I', encoded['ipi_base_n']['header']) - self.assertEqual(229, encoded['ipi_base_n']['id_code']) - self.assertEqual(7, encoded['ipi_base_n']['check_digit']) + self.assertEqual('I-000000229-7', encoded['ipi_base_n']) diff --git a/tests/parser/dictionary/encoder/interested_party/test_writer.py b/tests/parser/dictionary/encoder/interested_party/test_writer.py index 729af6c..70d8499 100644 --- a/tests/parser/dictionary/encoder/interested_party/test_writer.py +++ b/tests/parser/dictionary/encoder/interested_party/test_writer.py @@ -4,7 +4,6 @@ from cwr.parser.encoder.dictionary import WriterDictionaryEncoder from cwr.interested_party import Writer -from cwr.other import IPIBaseNumber """ Writer to dictionary encoding tests. @@ -22,12 +21,10 @@ def setUp(self): self._encoder = WriterDictionaryEncoder() def test_encoded(self): - ipi_base = IPIBaseNumber('I', 229, 7) - data = Writer(ip_n='ABC15', personal_number='ABC1234', ipi_name_n=14107338, - ipi_base_n=ipi_base, + ipi_base_n='I-000000229-7', writer_first_name='NAME', writer_last_name='LAST NAME', tax_id=923703412) @@ -41,6 +38,4 @@ def test_encoded(self): self.assertEqual('LAST NAME', encoded['writer_last_name']) self.assertEqual(923703412, encoded['tax_id']) - self.assertEqual('I', encoded['ipi_base_n']['header']) - self.assertEqual(229, encoded['ipi_base_n']['id_code']) - self.assertEqual(7, encoded['ipi_base_n']['check_digit']) + self.assertEqual('I-000000229-7', encoded['ipi_base_n']) diff --git a/tests/parser/dictionary/encoder/other/test_ipi_base.py b/tests/parser/dictionary/encoder/other/test_ipi_base.py index 1cad026..c863133 100644 --- a/tests/parser/dictionary/encoder/other/test_ipi_base.py +++ b/tests/parser/dictionary/encoder/other/test_ipi_base.py @@ -3,7 +3,6 @@ import unittest from cwr.parser.encoder.dictionary import IPIBaseDictionaryEncoder -from cwr.other import IPIBaseNumber """ Acknowledgement to dictionary encoding tests. @@ -21,11 +20,6 @@ def setUp(self): self._encoder = IPIBaseDictionaryEncoder() def test_encoded(self): - data = IPIBaseNumber('T', 123456789, - 1) + encoded = self._encoder.encode('T-123456789-1') - encoded = self._encoder.encode(data) - - self.assertEqual('T', encoded['header']) - self.assertEqual(123456789, encoded['id_code']) - self.assertEqual(1, encoded['check_digit']) + self.assertEqual('T-123456789-1', encoded) diff --git a/tests/parser/dictionary/encoder/other/test_iswc.py b/tests/parser/dictionary/encoder/other/test_iswc.py index 59583ee..1c9c034 100644 --- a/tests/parser/dictionary/encoder/other/test_iswc.py +++ b/tests/parser/dictionary/encoder/other/test_iswc.py @@ -3,7 +3,6 @@ import unittest from cwr.parser.encoder.dictionary import ISWCDictionaryEncoder -from cwr.other import ISWCCode """ Acknowledgement to dictionary encoding tests. @@ -21,10 +20,6 @@ def setUp(self): self._encoder = ISWCDictionaryEncoder() def test_encoded(self): - data = ISWCCode(123456789, - 1) + encoded = self._encoder.encode('T0123456789') - encoded = self._encoder.encode(data) - - self.assertEqual(123456789, encoded['id_code']) - self.assertEqual(1, encoded['check_digit']) + self.assertEqual('T0123456789', encoded) diff --git a/tests/parser/dictionary/encoder/record/test_authored_work.py b/tests/parser/dictionary/encoder/record/test_authored_work.py index a4a4cdc..12f9084 100644 --- a/tests/parser/dictionary/encoder/record/test_authored_work.py +++ b/tests/parser/dictionary/encoder/record/test_authored_work.py @@ -4,7 +4,6 @@ from cwr.parser.encoder.dictionary import AuthoredWorkDictionaryEncoder from cwr.work import AuthoredWorkRecord -from cwr.other import ISWCCode, IPIBaseNumber """ AuthoredWorkRecord to dictionary encoding tests. @@ -22,10 +21,6 @@ def setUp(self): self._encoder = AuthoredWorkDictionaryEncoder() def test_encoded(self): - iswc = ISWCCode(12345678, 9) - ipi1 = IPIBaseNumber('I', 229, 7) - ipi2 = IPIBaseNumber('I', 300, 7) - data = AuthoredWorkRecord(record_type='EWT', transaction_sequence_n=3, record_sequence_n=15, @@ -35,13 +30,13 @@ def test_encoded(self): writer_1_last_name='LAST NAME 1', writer_2_first_name='FIRST NAME 2', writer_2_last_name='LAST NAME 2', - writer_1_ipi_base_n=ipi1, + writer_1_ipi_base_n='I-000000229-7', writer_1_ipi_name_n=14107338, - writer_2_ipi_base_n=ipi2, + writer_2_ipi_base_n='I-000000300-7', writer_2_ipi_name_n=14107448, source='SOURCE', language_code='ES', - iswc=iswc) + iswc='T0123456789') encoded = self._encoder.encode(data) @@ -59,13 +54,8 @@ def test_encoded(self): self.assertEqual('SOURCE', encoded['source']) self.assertEqual('ES', encoded['language_code']) - self.assertEqual('I', encoded['writer_1_ipi_base_n']['header']) - self.assertEqual(229, encoded['writer_1_ipi_base_n']['id_code']) - self.assertEqual(7, encoded['writer_1_ipi_base_n']['check_digit']) + self.assertEqual('I-000000229-7', encoded['writer_1_ipi_base_n']) - self.assertEqual('I', encoded['writer_2_ipi_base_n']['header']) - self.assertEqual(300, encoded['writer_2_ipi_base_n']['id_code']) - self.assertEqual(7, encoded['writer_2_ipi_base_n']['check_digit']) + self.assertEqual('I-000000300-7', encoded['writer_2_ipi_base_n']) - self.assertEqual(12345678, encoded['iswc']['id_code']) - self.assertEqual(9, encoded['iswc']['check_digit']) + self.assertEqual('T0123456789', encoded['iswc']) diff --git a/tests/parser/dictionary/encoder/record/test_component.py b/tests/parser/dictionary/encoder/record/test_component.py index b6ae810..c34df3a 100644 --- a/tests/parser/dictionary/encoder/record/test_component.py +++ b/tests/parser/dictionary/encoder/record/test_component.py @@ -5,7 +5,6 @@ from cwr.parser.encoder.dictionary import ComponentDictionaryEncoder from cwr.work import ComponentRecord -from cwr.other import ISWCCode, IPIBaseNumber """ ComponentRecord to dictionary encoding tests. @@ -23,10 +22,6 @@ def setUp(self): self._encoder = ComponentDictionaryEncoder() def test_encoded(self): - iswc = ISWCCode(12345678, 9) - ipi_base_1 = IPIBaseNumber('I', 229, 7) - ipi_base_2 = IPIBaseNumber('I', 339, 7) - data = ComponentRecord(record_type='COM', transaction_sequence_n=3, record_sequence_n=15, @@ -36,11 +31,11 @@ def test_encoded(self): writer_1_first_name='FIRST NAME 1', writer_2_first_name='FIRST NAME 2', writer_2_last_name='LAST NAME 2', - writer_1_ipi_base_n=ipi_base_1, + writer_1_ipi_base_n='I-000000229-7', writer_1_ipi_name_n=14107338, - writer_2_ipi_base_n=ipi_base_2, + writer_2_ipi_base_n='I-000000339-7', writer_2_ipi_name_n=14107400, - iswc=iswc, + iswc='T0123456789', duration=datetime.datetime.strptime('011200', '%H%M%S').time()) @@ -61,13 +56,8 @@ def test_encoded(self): self.assertEqual(datetime.datetime.strptime('011200', '%H%M%S').time(), encoded['duration']) - self.assertEqual('I', encoded['writer_1_ipi_base_n']['header']) - self.assertEqual(229, encoded['writer_1_ipi_base_n']['id_code']) - self.assertEqual(7, encoded['writer_1_ipi_base_n']['check_digit']) + self.assertEqual('I-000000229-7', encoded['writer_1_ipi_base_n']) - self.assertEqual('I', encoded['writer_2_ipi_base_n']['header']) - self.assertEqual(339, encoded['writer_2_ipi_base_n']['id_code']) - self.assertEqual(7, encoded['writer_2_ipi_base_n']['check_digit']) + self.assertEqual('I-000000339-7', encoded['writer_2_ipi_base_n']) - self.assertEqual(12345678, encoded['iswc']['id_code']) - self.assertEqual(9, encoded['iswc']['check_digit']) + self.assertEqual('T0123456789', encoded['iswc']) diff --git a/tests/parser/dictionary/encoder/record/test_interested_party_agreement.py b/tests/parser/dictionary/encoder/record/test_interested_party_agreement.py index c52ceff..253b6de 100644 --- a/tests/parser/dictionary/encoder/record/test_interested_party_agreement.py +++ b/tests/parser/dictionary/encoder/record/test_interested_party_agreement.py @@ -5,7 +5,6 @@ from cwr.parser.encoder.dictionary import \ InterestedPartyForAgreementDictionaryEncoder from cwr.agreement import InterestedPartyForAgreementRecord -from cwr.other import IPIBaseNumber """ InterestedPartyForAgreementRecord to dictionary encoding tests. @@ -23,8 +22,6 @@ def setUp(self): self._encoder = InterestedPartyForAgreementDictionaryEncoder() def test_encoded(self): - ipi_base = IPIBaseNumber('I', 229, 7) - data = InterestedPartyForAgreementRecord(record_type='ACK', transaction_sequence_n=3, record_sequence_n=15, @@ -33,7 +30,7 @@ def test_encoded(self): agreement_role_code='AS', ip_writer_first_name='FIRST NAME', ipi_name_n='00014107338', - ipi_base_n=ipi_base, + ipi_base_n='I-000000229-7', pr_society=12, pr_share=50.5, mr_society=13, @@ -58,6 +55,4 @@ def test_encoded(self): self.assertEqual(14, encoded['sr_society']) self.assertEqual(70.5, encoded['sr_share']) - self.assertEqual('I', encoded['ipi_base_n']['header']) - self.assertEqual(229, encoded['ipi_base_n']['id_code']) - self.assertEqual(7, encoded['ipi_base_n']['check_digit']) + self.assertEqual('I-000000229-7', encoded['ipi_base_n']) diff --git a/tests/parser/dictionary/encoder/record/test_npr.py b/tests/parser/dictionary/encoder/record/test_npr.py index 850268d..6ffdec2 100644 --- a/tests/parser/dictionary/encoder/record/test_npr.py +++ b/tests/parser/dictionary/encoder/record/test_npr.py @@ -5,7 +5,6 @@ from cwr.parser.encoder.dictionary import \ NonRomanAlphabetPerformanceDataDictionaryEncoder from cwr.non_roman_alphabet import NonRomanAlphabetPerformanceDataRecord -from cwr.other import IPIBaseNumber """ NPRRecord to dictionary encoding tests. @@ -23,15 +22,13 @@ def setUp(self): self._encoder = NonRomanAlphabetPerformanceDataDictionaryEncoder() def test_encoded(self): - ipi_base = IPIBaseNumber('I', 229, 7) - data = NonRomanAlphabetPerformanceDataRecord(record_type='NPA', transaction_sequence_n=3, record_sequence_n=15, performing_artist_first_name='FIRST NAME', performing_artist_name='NAME', performing_artist_ipi_name_n=14107338, - performing_artist_ipi_base_n=ipi_base, + performing_artist_ipi_base_n='I-000000229-7', language_code='ES', performance_language='EN', performance_dialect='SC') @@ -48,8 +45,5 @@ def test_encoded(self): self.assertEqual('EN', encoded['performance_language']) self.assertEqual('SC', encoded['performance_dialect']) - self.assertEqual('I', encoded['performing_artist_ipi_base_n']['header']) - self.assertEqual(229, - encoded['performing_artist_ipi_base_n']['id_code']) - self.assertEqual(7, - encoded['performing_artist_ipi_base_n']['check_digit']) + self.assertEqual('I-000000229-7', + encoded['performing_artist_ipi_base_n']) diff --git a/tests/parser/dictionary/encoder/record/test_performing_artist.py b/tests/parser/dictionary/encoder/record/test_performing_artist.py index 519d4b8..a2fa703 100644 --- a/tests/parser/dictionary/encoder/record/test_performing_artist.py +++ b/tests/parser/dictionary/encoder/record/test_performing_artist.py @@ -4,7 +4,6 @@ from cwr.parser.encoder.dictionary import PerformingArtistDictionaryEncoder from cwr.work import PerformingArtistRecord -from cwr.other import IPIBaseNumber """ PerformingArtistRecord to dictionary encoding tests. @@ -22,15 +21,13 @@ def setUp(self): self._encoder = PerformingArtistDictionaryEncoder() def test_encoded(self): - ipi_base = IPIBaseNumber('I', 229, 7) - data = PerformingArtistRecord(record_type='PER', transaction_sequence_n=3, record_sequence_n=15, performing_artist_last_name='LAST NAME', performing_artist_first_name='FIRST NAME', performing_artist_ipi_name_n=14107338, - performing_artist_ipi_base_n=ipi_base) + performing_artist_ipi_base_n='I-000000229-7') encoded = self._encoder.encode(data) @@ -41,8 +38,5 @@ def test_encoded(self): self.assertEqual('FIRST NAME', encoded['performing_artist_first_name']) self.assertEqual(14107338, encoded['performing_artist_ipi_name_n']) - self.assertEqual('I', encoded['performing_artist_ipi_base_n']['header']) - self.assertEqual(229, - encoded['performing_artist_ipi_base_n']['id_code']) - self.assertEqual(7, - encoded['performing_artist_ipi_base_n']['check_digit']) + self.assertEqual('I-000000229-7', + encoded['performing_artist_ipi_base_n']) diff --git a/tests/parser/dictionary/encoder/record/test_publisher.py b/tests/parser/dictionary/encoder/record/test_publisher.py index e2c5080..41e5528 100644 --- a/tests/parser/dictionary/encoder/record/test_publisher.py +++ b/tests/parser/dictionary/encoder/record/test_publisher.py @@ -4,7 +4,6 @@ from cwr.parser.encoder.dictionary import PublisherRecordDictionaryEncoder from cwr.interested_party import PublisherRecord, Publisher -from cwr.other import IPIBaseNumber """ Publisher to dictionary encoding tests. @@ -22,12 +21,10 @@ def setUp(self): self._encoder = PublisherRecordDictionaryEncoder() def test_encoded(self): - ipi_base = IPIBaseNumber('I', 229, 7) - publisher = Publisher(ip_n='ABC15', publisher_name='NAME', ipi_name_n=14107338, - ipi_base_n=ipi_base, + ipi_base_n='I-000000229-7', tax_id=923703412) data = PublisherRecord(record_type='SPU', @@ -58,9 +55,7 @@ def test_encoded(self): self.assertEqual(14107338, publisher['ipi_name_n']) self.assertEqual(923703412, publisher['tax_id']) - self.assertEqual('I', publisher['ipi_base_n']['header']) - self.assertEqual(229, publisher['ipi_base_n']['id_code']) - self.assertEqual(7, publisher['ipi_base_n']['check_digit']) + self.assertEqual('I-000000229-7', publisher['ipi_base_n']) self.assertEqual('SPU', encoded['record_type']) self.assertEqual(3, encoded['transaction_sequence_n']) diff --git a/tests/parser/dictionary/encoder/record/test_work.py b/tests/parser/dictionary/encoder/record/test_work.py index 95c14eb..d161fdb 100644 --- a/tests/parser/dictionary/encoder/record/test_work.py +++ b/tests/parser/dictionary/encoder/record/test_work.py @@ -5,7 +5,6 @@ from cwr.parser.encoder.dictionary import WorkDictionaryEncoder from cwr.work import WorkRecord -from cwr.other import ISWCCode """ WorkRecord to dictionary encoding tests. @@ -23,8 +22,6 @@ def setUp(self): self._encoder = WorkDictionaryEncoder() def test_encoded(self): - iswc = ISWCCode(12345678, 9) - data = WorkRecord(record_type='NWR', transaction_sequence_n=3, record_sequence_n=15, @@ -44,7 +41,7 @@ def test_encoded(self): excerpt_type='MOV', composite_type='MED', composite_component_count=5, - iswc=iswc, + iswc='T0123456789', work_type='BL', duration=datetime.datetime.strptime('011200', '%H%M%S').time(), @@ -92,8 +89,7 @@ def test_encoded(self): self.assertEqual('Y', encoded['exceptional_clause']) self.assertEqual(True, encoded['grand_rights_indicator']) - self.assertEqual(12345678, encoded['iswc']['id_code']) - self.assertEqual(9, encoded['iswc']['check_digit']) + self.assertEqual('T0123456789', encoded['iswc']) def test_encoded_no_iswc(self): iswc = None diff --git a/tests/parser/dictionary/encoder/record/test_writer.py b/tests/parser/dictionary/encoder/record/test_writer.py index 985c861..2a27c48 100644 --- a/tests/parser/dictionary/encoder/record/test_writer.py +++ b/tests/parser/dictionary/encoder/record/test_writer.py @@ -4,7 +4,6 @@ from cwr.parser.encoder.dictionary import WriterRecordDictionaryEncoder from cwr.interested_party import Writer, WriterRecord -from cwr.other import IPIBaseNumber """ Writer to dictionary encoding tests. @@ -22,12 +21,10 @@ def setUp(self): self._encoder = WriterRecordDictionaryEncoder() def test_encoded(self): - ipi_base = IPIBaseNumber('I', 229, 7) - writer = Writer(ip_n='ABC15', personal_number='ABC1234', ipi_name_n=14107338, - ipi_base_n=ipi_base, + ipi_base_n='I-000000229-7', writer_first_name='NAME', writer_last_name='LAST NAME', tax_id=923703412) @@ -60,9 +57,7 @@ def test_encoded(self): self.assertEqual('LAST NAME', writer['writer_last_name']) self.assertEqual(923703412, writer['tax_id']) - self.assertEqual('I', writer['ipi_base_n']['header']) - self.assertEqual(229, writer['ipi_base_n']['id_code']) - self.assertEqual(7, writer['ipi_base_n']['check_digit']) + self.assertEqual('I-000000229-7', writer['ipi_base_n']) self.assertEqual('SWR', encoded['record_type']) self.assertEqual(3, encoded['transaction_sequence_n'])