├── .coveragerc
├── .gitignore
├── .travis.yml
├── LICENSE
├── MANIFEST.in
├── Makefile
├── README.rst
├── config_cwr
├── __init__.py
├── accessor.py
├── acknowledge_config_example.yml
├── default_values.yml
├── field_config_common.yml
├── field_config_filename.yml
├── field_config_table.yml
├── group_config_common.cml
├── record_config_common.cml
├── record_config_filename.cml
└── transaction_config_common.cml
├── cwr
├── __init__.py
├── acknowledge
│ ├── __init__.py
│ └── file.py
├── acknowledgement.py
├── agreement.py
├── file.py
├── grammar
│ ├── __init__.py
│ ├── factory
│ │ ├── __init__.py
│ │ ├── adapter.py
│ │ ├── config.py
│ │ ├── decorator.py
│ │ └── rule.py
│ └── field
│ │ ├── __init__.py
│ │ ├── basic.py
│ │ ├── filename.py
│ │ ├── record.py
│ │ ├── special.py
│ │ └── table.py
├── group.py
├── info.py
├── interested_party.py
├── non_roman_alphabet.py
├── other.py
├── parser
│ ├── __init__.py
│ ├── decoder
│ │ ├── __init__.py
│ │ ├── common.py
│ │ ├── cwrjson.py
│ │ ├── dictionary.py
│ │ └── file.py
│ └── encoder
│ │ ├── __init__.py
│ │ ├── common.py
│ │ ├── cwrjson.py
│ │ ├── dictionary.py
│ │ ├── file.py
│ │ └── standart
│ │ ├── __init__.py
│ │ ├── field.py
│ │ └── record.py
├── record.py
├── table_value.py
├── transmission.py
├── utils
│ ├── __init__.py
│ └── printer.py
├── validation
│ ├── __init__.py
│ ├── common.py
│ ├── record.py
│ └── transaction.py
└── work.py
├── data_cwr
├── __init__.py
├── accessor.py
├── cwr_agreement_role_code.csv
├── cwr_agreement_type.csv
├── cwr_character_set.csv
├── cwr_composite_type.csv
├── cwr_excerpt_type.csv
├── cwr_files_manufacture_clause.csv
├── cwr_inclusion_exclusion_indicator.csv
├── cwr_instrument_code.csv
├── cwr_intended_purpose.csv
├── cwr_isrc_country_code.csv
├── cwr_language_code.csv
├── cwr_lyric_adaptation.csv
├── cwr_media_type.csv
├── cwr_message_level.csv
├── cwr_message_type.csv
├── cwr_music_arrangement.csv
├── cwr_musical_work_distribution_category.csv
├── cwr_post_term_collection_status.csv
├── cwr_prior_royalty_status.csv
├── cwr_publisher_type.csv
├── cwr_record_type.csv
├── cwr_recording_format.csv
├── cwr_recording_technique.csv
├── cwr_sales_manufacture_clause.csv
├── cwr_sender_type.csv
├── cwr_society_code.csv
├── cwr_special_agreement_indicator.csv
├── cwr_standard_instrumentation_type.csv
├── cwr_subject_code.csv
├── cwr_text_music_relationship.csv
├── cwr_tis_code.csv
├── cwr_title_type.csv
├── cwr_transaction_status.csv
├── cwr_transaction_type.csv
├── cwr_type_of_right.csv
├── cwr_usa_license_indicator.csv
├── cwr_version_type.csv
├── cwr_work_type.csv
└── cwr_writer_designation_code.csv
├── docs
├── Makefile
├── diagrams
│ ├── readme.txt
│ ├── rules_tree_generic_example.uxf
│ └── rules_tree_group_header_example.uxf
├── make.bat
└── source
│ ├── _downloads
│ └── cwr_files
│ │ ├── charset_rules.rar
│ │ ├── cwr_light.rar
│ │ ├── errors.rar
│ │ ├── impl_sheet.rar
│ │ ├── questionnary_publisher.rar
│ │ ├── questionnary_society.rar
│ │ ├── sender_id_code.rar
│ │ ├── specification.rar
│ │ ├── tables.rar
│ │ ├── tis_amend.rar
│ │ ├── tis_hierarchies.rar
│ │ ├── tis_territories.rar
│ │ └── user_manual.rar
│ ├── _static
│ ├── favicon.ico
│ └── img
│ │ ├── rules_tree_generic_example.png
│ │ └── rules_tree_group_header_example.png
│ ├── _templates
│ └── status.html
│ ├── conf.py
│ ├── contents_standard.rst
│ ├── cwr_standard
│ ├── acknowledgement_file.rst
│ ├── documents.rst
│ ├── field_format.rst
│ ├── file_structure.rst
│ ├── file_validation.rst
│ ├── glossary.rst
│ ├── index.rst
│ └── miscellany.rst
│ ├── cwr_structure
│ ├── acknowledgement_record.rst
│ ├── group_header.rst
│ ├── group_trailer.rst
│ ├── index.rst
│ ├── message_record.rst
│ ├── record_prefix.rst
│ ├── record_type_codes.rst
│ ├── transmission_header.rst
│ └── transmission_trailer.rst
│ ├── grammar
│ ├── config_dsl.rst
│ ├── index.rst
│ └── rules.rst
│ ├── index.rst
│ ├── other
│ ├── index.rst
│ └── ipi_number.rst
│ └── validation
│ ├── file_validation.rst
│ ├── index.rst
│ ├── record_prefix_validation.rst
│ └── validation_process.rst
├── make.bat
├── requirements.txt
├── setup.cfg
├── setup.py
├── tests
├── __init__.py
├── acknowledge
│ ├── __init__.py
│ ├── acknowledge.py
│ └── test.cwr
├── examples
│ └── ackexample.V21
├── grammar
│ ├── __init__.py
│ ├── config
│ │ ├── __init__.py
│ │ ├── test_id.py
│ │ ├── test_options.py
│ │ ├── test_rules_file.py
│ │ ├── test_rules_set.py
│ │ ├── test_rules_tree.py
│ │ └── test_terminal_rule.py
│ ├── factory
│ │ ├── __init__.py
│ │ ├── control
│ │ │ ├── __init__.py
│ │ │ ├── test_group.py
│ │ │ ├── test_group_header.py
│ │ │ ├── test_group_trailer.py
│ │ │ ├── test_group_transactions.py
│ │ │ ├── test_transmission.py
│ │ │ ├── test_transmission_groups.py
│ │ │ ├── test_transmission_header.py
│ │ │ └── test_transmission_trailer.py
│ │ ├── file
│ │ │ ├── __init__.py
│ │ │ └── test_filename.py
│ │ ├── record
│ │ │ ├── __init__.py
│ │ │ ├── test_acknowledgement.py
│ │ │ ├── test_additional_related_information.py
│ │ │ ├── test_agreement.py
│ │ │ ├── test_agreement_territory.py
│ │ │ ├── test_alternate_title.py
│ │ │ ├── test_component.py
│ │ │ ├── test_entire_work_title.py
│ │ │ ├── test_instrumentation_detail.py
│ │ │ ├── test_instrumentation_summary.py
│ │ │ ├── test_interested_party_agreement.py
│ │ │ ├── test_message.py
│ │ │ ├── test_nat.py
│ │ │ ├── test_now.py
│ │ │ ├── test_npa.py
│ │ │ ├── test_npn.py
│ │ │ ├── test_npr.py
│ │ │ ├── test_nra_work.py
│ │ │ ├── test_nwn.py
│ │ │ ├── test_original_work_title.py
│ │ │ ├── test_performing_artist.py
│ │ │ ├── test_publisher.py
│ │ │ ├── test_publisher_territory.py
│ │ │ ├── test_recording_detail.py
│ │ │ ├── test_work.py
│ │ │ ├── test_work_conflict.py
│ │ │ ├── test_work_origin.py
│ │ │ ├── test_writer.py
│ │ │ ├── test_writer_publisher.py
│ │ │ └── test_writer_territory.py
│ │ ├── test_default_rule_factory_stress.py
│ │ ├── test_default_rule_factory_times.py
│ │ ├── test_field_factory_times.py
│ │ ├── test_lookup_field_factory.py
│ │ ├── test_rule_factory_repeated_call.py
│ │ └── transaction
│ │ │ ├── __init__.py
│ │ │ ├── test_acknowledgement_transaction.py
│ │ │ ├── test_acquirer_information.py
│ │ │ ├── test_administrator_information.py
│ │ │ ├── test_agreement_transaction.py
│ │ │ ├── test_assignor_information.py
│ │ │ ├── test_controlled_publisher_information.py
│ │ │ ├── test_controlled_writer_information.py
│ │ │ ├── test_information_for_components.py
│ │ │ ├── test_information_for_excerpts.py
│ │ │ ├── test_information_for_versions.py
│ │ │ ├── test_instrumentation_information.py
│ │ │ ├── test_original_publisher_information.py
│ │ │ ├── test_subpublisher_information.py
│ │ │ ├── test_territory_information.py
│ │ │ └── test_work_transaction.py
│ └── field
│ │ ├── __init__.py
│ │ ├── record
│ │ ├── __init__.py
│ │ └── test_record.py
│ │ ├── special
│ │ ├── __init__.py
│ │ ├── test_avi.py
│ │ ├── test_date_time.py
│ │ ├── test_ean_13.py
│ │ ├── test_ipi_base_number.py
│ │ ├── test_isrc.py
│ │ ├── test_iswc.py
│ │ ├── test_percentage.py
│ │ └── test_visan.py
│ │ ├── test_alphanumeric.py
│ │ ├── test_boolean.py
│ │ ├── test_date.py
│ │ ├── test_flag.py
│ │ ├── test_lookup.py
│ │ ├── test_numeric.py
│ │ ├── test_numeric_float.py
│ │ └── test_time.py
├── model
│ ├── __init__.py
│ └── iswc.py
├── parser
│ ├── __init__.py
│ ├── cwrjson
│ │ ├── __init__.py
│ │ ├── decoder
│ │ │ ├── __init__.py
│ │ │ └── test_json.py
│ │ └── encoder
│ │ │ ├── __init__.py
│ │ │ └── test_json.py
│ ├── dictionary
│ │ ├── __init__.py
│ │ ├── decoder
│ │ │ ├── __init__.py
│ │ │ ├── control
│ │ │ │ ├── __init__.py
│ │ │ │ ├── test_group.py
│ │ │ │ ├── test_group_header.py
│ │ │ │ ├── test_group_trailer.py
│ │ │ │ ├── test_transmission.py
│ │ │ │ ├── test_transmission_header.py
│ │ │ │ └── test_transmission_trailer.py
│ │ │ ├── file
│ │ │ │ ├── __init__.py
│ │ │ │ ├── test_file.py
│ │ │ │ └── test_file_tag.py
│ │ │ ├── interested_party
│ │ │ │ ├── __init__.py
│ │ │ │ ├── test_publisher.py
│ │ │ │ └── test_writer.py
│ │ │ ├── other
│ │ │ │ ├── __init__.py
│ │ │ │ ├── test_avi_key.py
│ │ │ │ ├── test_ipi_base.py
│ │ │ │ ├── test_iswc.py
│ │ │ │ └── test_visan.py
│ │ │ ├── record
│ │ │ │ ├── __init__.py
│ │ │ │ ├── test_acknowledgement.py
│ │ │ │ ├── test_additional_related_information.py
│ │ │ │ ├── test_agreement.py
│ │ │ │ ├── test_agreement_territory.py
│ │ │ │ ├── test_alternate_title.py
│ │ │ │ ├── test_authored_work.py
│ │ │ │ ├── test_component.py
│ │ │ │ ├── test_instrumentation_detail.py
│ │ │ │ ├── test_instrumentation_summary.py
│ │ │ │ ├── test_interested_party_for_agreement.py
│ │ │ │ ├── test_ip_territory_of_control.py
│ │ │ │ ├── test_message.py
│ │ │ │ ├── test_non_roman_alphabet_agreement_party.py
│ │ │ │ ├── test_non_roman_alphabet_other_writer.py
│ │ │ │ ├── test_non_roman_alphabet_performance_data.py
│ │ │ │ ├── test_non_roman_alphabet_publisher_name.py
│ │ │ │ ├── test_non_roman_alphabet_title.py
│ │ │ │ ├── test_non_roman_alphabet_work.py
│ │ │ │ ├── test_non_roman_alphabet_writer_name.py
│ │ │ │ ├── test_performing_artist.py
│ │ │ │ ├── test_publisher.py
│ │ │ │ ├── test_publisher_for_writer.py
│ │ │ │ ├── test_recording_detail.py
│ │ │ │ ├── test_work.py
│ │ │ │ ├── test_work_origin.py
│ │ │ │ └── test_writer.py
│ │ │ └── table_value
│ │ │ │ ├── __init__.py
│ │ │ │ ├── test_instrument_value.py
│ │ │ │ ├── test_media_type_value.py
│ │ │ │ └── test_table_value.py
│ │ └── encoder
│ │ │ ├── __init__.py
│ │ │ ├── control
│ │ │ ├── __init__.py
│ │ │ ├── test_group.py
│ │ │ ├── test_group_header.py
│ │ │ ├── test_group_trailer.py
│ │ │ ├── test_transmission.py
│ │ │ ├── test_transmission_header.py
│ │ │ └── test_transmission_trailer.py
│ │ │ ├── file
│ │ │ ├── __init__.py
│ │ │ ├── test_file.py
│ │ │ └── test_file_tag.py
│ │ │ ├── interested_party
│ │ │ ├── __init__.py
│ │ │ ├── test_publisher.py
│ │ │ └── test_writer.py
│ │ │ ├── other
│ │ │ ├── __init__.py
│ │ │ ├── test_avi_key.py
│ │ │ ├── test_ipi_base.py
│ │ │ ├── test_iswc.py
│ │ │ └── test_visan.py
│ │ │ ├── record
│ │ │ ├── __init__.py
│ │ │ ├── test_acknowledgement.py
│ │ │ ├── test_additional_related_info.py
│ │ │ ├── test_agreement.py
│ │ │ ├── test_agreement_territory.py
│ │ │ ├── test_alternate_title.py
│ │ │ ├── test_authored_work.py
│ │ │ ├── test_component.py
│ │ │ ├── test_instrumentation_detail.py
│ │ │ ├── test_instrumentation_summary.py
│ │ │ ├── test_interested_party_agreement.py
│ │ │ ├── test_ip_territory_control.py
│ │ │ ├── test_message.py
│ │ │ ├── test_nat.py
│ │ │ ├── test_now.py
│ │ │ ├── test_npa.py
│ │ │ ├── test_npn.py
│ │ │ ├── test_npr.py
│ │ │ ├── test_nra_work.py
│ │ │ ├── test_nwn.py
│ │ │ ├── test_performing_artist.py
│ │ │ ├── test_publisher.py
│ │ │ ├── test_publisher_for_writer.py
│ │ │ ├── test_recording_detail.py
│ │ │ ├── test_work.py
│ │ │ ├── test_work_origin.py
│ │ │ └── test_writer.py
│ │ │ └── table_value
│ │ │ ├── __init__.py
│ │ │ ├── test_instrument_value.py
│ │ │ ├── test_media_type_value.py
│ │ │ └── test_table_value.py
│ └── file
│ │ ├── __init__.py
│ │ ├── decoder
│ │ ├── __init__.py
│ │ ├── test_file.py
│ │ └── test_filename.py
│ │ └── encoder
│ │ ├── __init__.py
│ │ ├── test_file.py
│ │ └── test_filename.py
├── utils
│ ├── __init__.py
│ └── grammar.py
└── visual
│ ├── __init__.py
│ ├── file_contents.py
│ └── file_json.py
└── tox.ini
/.coveragerc:
--------------------------------------------------------------------------------
1 | [report]
2 | omit =
3 | */python?.?/*
4 | */site-packages/nose/*
5 | *__init__*
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *.pyc
5 | *.pyo
6 |
7 | # C extensions
8 | *.so
9 |
10 | # Distribution / packaging
11 | .Python
12 | env/
13 | build/
14 | develop-eggs/
15 | dist/
16 | downloads/
17 | eggs/
18 | .eggs/
19 | lib/
20 | lib64/
21 | parts/
22 | sdist/
23 | var/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 | MANIFEST
28 |
29 | # PyInstaller
30 | # Usually these files are written by a python script from a template
31 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 | *.manifest
33 | *.spec
34 |
35 | # Installer logs
36 | pip-log.txt
37 | pip-delete-this-directory.txt
38 |
39 | # Unit test / coverage reports
40 | htmlcov/
41 | .tox/
42 | .coverage
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 |
47 | # Translations
48 | *.mo
49 | *.pot
50 |
51 | # Logs:
52 | *.log
53 | *.log.*
54 |
55 | # Sphinx documentation
56 | docs/_build/
57 | docs/build/
58 |
59 | # PyBuilder
60 | target/
61 |
62 | # Idea PyCharm
63 | .idea/
64 | .idea_modules/
65 | out/
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # Travis CI Configuration file
2 | # @link https://travis-ci.org/
3 |
4 | # Using Python for the project
5 | language: python
6 | python:
7 | - "3.4"
8 | - "3.5"
9 | # Python 3.6 is set to test and deploy the docs in the configuration matrix
10 | #- "3.6"
11 | # PyPy currently is not working with the required dependencies
12 | #- "pypy"
13 | #- "pypy3"
14 | env:
15 | - TEST_DOCS=true
16 | matrix:
17 | include:
18 | # Tests and deploys docs, also runs coverage report
19 | - python: "3.6"
20 | env: TEST_DOCS=true DEPLOY_DOCS=true
21 |
22 | before_install:
23 | # Gets scripts
24 | - git clone -b v0.4.1 --single-branch https://github.com/Bernardo-MG/ci-shell-scripts.git ~/.scripts
25 | # Sets scripts as executable
26 | - chmod -R +x ~/.scripts/*
27 | # Prepares CI environment
28 | - source ~/.scripts/travis/load-travis-environment.sh
29 | install:
30 | # tox is required for the tests
31 | - pip install tox
32 | # sphinx is required for the docs
33 | - pip install sphinx
34 | # Dependencies
35 | - pip install --upgrade -r requirements.txt
36 | script:
37 | # Tests are run
38 | - ~/.scripts/python/run_tests.sh true $PYTHON_VERSION_TEST
39 | # Documentation tests are run
40 | - ~/.scripts/python/run_tests.sh $DO_TEST_DOCS docs
41 | after_success:
42 | # Documentation deployment
43 | - ~/.scripts/rtd/deploy.sh $DO_DEPLOY_DOCS cwr
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 WESO
4 | Copyright (c) 2016 United Media Agency
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | # Miscellany files
2 | include LICENSE
3 | include README.rst
4 | include Makefile
5 | include make.bat
6 | include tox.ini
7 | include requirements.txt
8 | include .coveragerc
9 |
10 | # Tests
11 | recursive-exclude tests *.pyc
12 | recursive-exclude tests *.pyo
13 |
14 | recursive-include tests *.V21
15 | recursive-include tests *.cwr
16 |
17 | # Data files
18 | include data_cwr/*.py
19 | include data_cwr/*.csv
20 | include data_cwr/*.yml
21 |
22 | # Configuration files
23 | include config_cwr/*.yml
24 | include config_cwr/*.cml
25 |
26 | # Documentation
27 | recursive-include docs *
28 | recursive-exclude docs *.pyc
29 | recursive-exclude docs *.pyo
30 | prune docs/_build
--------------------------------------------------------------------------------
/config_cwr/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/config_cwr/__init__.py
--------------------------------------------------------------------------------
/config_cwr/acknowledge_config_example.yml:
--------------------------------------------------------------------------------
1 |
2 | sender_name: 'UMA EXAMPLE'
3 | sender_id: 999
4 | sender_type: 'SO'
5 | version: 2.1
6 | tis:
7 | world: 2136
8 | uzbekistan: 860
9 | ukraine: 804
10 | turkmenistan: 795
11 | tajikistan: 762
12 | russia: 643
13 | moldova: 498
14 | kazakhstan: 417
15 | kazahstan: 398
16 | georgia: 268
17 | belarus: 112
18 | armenia: 51
19 | azerbaijan: 32
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/config_cwr/default_values.yml:
--------------------------------------------------------------------------------
1 | default_version: 2.1
--------------------------------------------------------------------------------
/config_cwr/field_config_filename.yml:
--------------------------------------------------------------------------------
1 | delimiter_ip:
2 | type: lookup
3 | size: 1
4 | name: IPs separator
5 | values:
6 | - _
7 |
8 | delimiter_version:
9 | type: lookup
10 | size: 2
11 | name: Version Separator
12 | values:
13 | - .V
14 |
15 | delimiter_zip:
16 | type: filename_version
17 | size: 4
18 | name: ZIP extension
19 | results_name: version
20 | values:
21 | - .zip
22 |
23 | header:
24 | type: lookup
25 | size: 2
26 | name: Filename Header
27 | values:
28 | - CW
29 |
30 | receiver:
31 | type: alphanum_variable
32 | size: 3
33 | name: Receiver
34 | values:
35 | - 2
36 |
37 | sender:
38 | type: alphanum_variable
39 | size: 3
40 | name: Sender
41 | values:
42 | - 2
43 |
44 | sequence_n_new:
45 | type: numeric
46 | size: 4
47 | name: Sequence Number
48 | results_name: sequence_n
49 |
50 | sequence_n_old:
51 | type: numeric
52 | size: 2
53 | name: Sequence Number
54 | results_name: sequence_n
55 |
56 | version:
57 | type: numeric_float
58 | size: 2
59 | name: Version
60 | values:
61 | - 1
62 |
63 | year:
64 | type: year
65 | size: 2
66 | name: Year
--------------------------------------------------------------------------------
/config_cwr/group_config_common.cml:
--------------------------------------------------------------------------------
1 | group:
2 | id: groups
3 | rules:
4 | [
5 | group: group_info (at_least_1)
6 | ]
7 |
8 | group:
9 | id: group_info
10 | rules:
11 | [
12 | record: group_header
13 | group: transactions (optional)
14 | option
15 | [
16 | record: group_trailer_base
17 | record: group_trailer_short
18 | ]
19 | ]
20 |
21 | group:
22 | id: transactions
23 | rules:
24 | [
25 | option
26 | [
27 | group: agreement_transaction (grouped, at_least_1)
28 | group: work_transaction (grouped, at_least_1)
29 | group: acknowledgement_transaction (grouped, at_least_1)
30 | ]
31 | ]
32 |
33 | group:
34 | id: transmission
35 | rules:
36 | [
37 | record: transmission_header
38 | group: groups ( at_least_1)
39 | record: transmission_trailer
40 | ]
--------------------------------------------------------------------------------
/config_cwr/record_config_filename.cml:
--------------------------------------------------------------------------------
1 | filename:
2 | id: filename_old
3 | rules:
4 | [
5 | field: header (compulsory)
6 | field: year (compulsory)
7 | field: sequence_n_old (compulsory)
8 | field: sender (compulsory)
9 | field: delimiter_ip (compulsory)
10 | field: receiver (compulsory)
11 | option
12 | [
13 | sequence
14 | [
15 | field: delimiter_version (compulsory)
16 | field: version (compulsory)
17 | ]
18 | sequence
19 | [
20 | field: delimiter_zip (compulsory)
21 | ]
22 | ]
23 | ]
24 |
25 | filename:
26 | id: filename_new
27 | rules:
28 | [
29 | field: header (compulsory)
30 | field: year (compulsory)
31 | field: sequence_n_new (compulsory)
32 | field: sender (compulsory)
33 | field: delimiter_ip (compulsory)
34 | field: receiver (compulsory)
35 | option
36 | [
37 | sequence
38 | [
39 | field: delimiter_version (compulsory)
40 | field: version (compulsory)
41 | ]
42 | sequence
43 | [
44 | field: delimiter_zip (compulsory)
45 | ]
46 | ]
47 | ]
--------------------------------------------------------------------------------
/cwr/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | CWR Data API
4 | ~~~~~~~~~~~~
5 | API for Common Works Registrations.
6 | :copyright: (c) 2015 by WESO
7 | :license: MIT, see LICENSE for more details.
8 | """
9 |
10 | __version__ = '0.0.8'
11 | __license__ = 'MIT'
12 |
--------------------------------------------------------------------------------
/cwr/acknowledge/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'yaroslav'
2 |
--------------------------------------------------------------------------------
/cwr/grammar/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/cwr/grammar/__init__.py
--------------------------------------------------------------------------------
/cwr/grammar/factory/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/cwr/grammar/factory/__init__.py
--------------------------------------------------------------------------------
/cwr/grammar/field/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/cwr/grammar/field/__init__.py
--------------------------------------------------------------------------------
/cwr/grammar/field/filename.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import pyparsing as pp
4 |
5 | from cwr.grammar.field.basic import numeric, lookup
6 | from config_cwr.accessor import CWRConfiguration
7 |
8 | """
9 | CWR filename fields grammar.
10 | """
11 |
12 | __author__ = 'Bernardo Martínez Garrido'
13 | __license__ = 'MIT'
14 | __status__ = 'Development'
15 |
16 |
17 | def alphanum_variable(min_size, max_size, name=None):
18 | """
19 | Creates the grammar for an alphanumeric code where the size ranges between
20 | two values.
21 |
22 | :param min_size: minimum size
23 | :param max_size: maximum size
24 | :param name: name for the field
25 | :return: grammar for an alphanumeric field of a variable size
26 | """
27 |
28 | if name is None:
29 | name = 'Alphanumeric Field'
30 |
31 | if min_size < 0:
32 | # Can't have negative min
33 | raise BaseException()
34 | if max_size < min_size:
35 | # Max can't be lower than min
36 | raise BaseException()
37 |
38 | field = pp.Word(pp.alphanums, min=min_size, max=max_size)
39 |
40 | # Parse action
41 | field.setParseAction(lambda s: s[0].strip())
42 |
43 | # White spaces are not removed
44 | field.leaveWhitespace()
45 |
46 | # Name
47 | field.setName(name)
48 |
49 | return field
50 |
51 |
52 | def year(columns, name=None):
53 | """
54 | Creates the grammar for a field containing a year.
55 |
56 | :param columns: the number of columns for the year
57 | :param name: the name of the field
58 | :return:
59 | """
60 |
61 | if columns < 0:
62 | # Can't have negative size
63 | raise BaseException()
64 |
65 | field = numeric(columns, name)
66 |
67 | # Parse action
68 | field.addParseAction(_to_year)
69 |
70 | return field
71 |
72 |
73 | def filename_version(values, name=None):
74 | field = lookup(values, name)
75 |
76 | default_version = CWRConfiguration().default_version()
77 |
78 | # Parse action
79 | field.addParseAction(lambda n: default_version)
80 |
81 | return field
82 |
83 |
84 | def _to_year(parsed):
85 | """
86 | Transforms the parsed two digits integer into a valid year value.
87 |
88 | :param parsed: the parsed value
89 | """
90 | return 2000 + parsed[0]
91 |
--------------------------------------------------------------------------------
/cwr/grammar/field/record.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | from config_cwr.accessor import CWRConfiguration
4 | from cwr.grammar.field import basic
5 |
6 | """
7 | Grammar for Records.
8 |
9 | This stores general records fields.
10 | """
11 |
12 | __author__ = 'Bernardo Martínez Garrido'
13 | __license__ = 'MIT'
14 | __status__ = 'Development'
15 |
16 | # Acquires data sources
17 | _config = CWRConfiguration()
18 |
19 |
20 | # RECORD FIELDS
21 |
22 | # Prefix fields
23 |
24 |
25 | def record_type(values):
26 | """
27 | Creates a record type field.
28 |
29 | These serve as the header field on records, identifying them.
30 |
31 | Usually this field can be only an specific value, but sometimes a small
32 | range of codes is allowed. This is specified by the 'values' parameter.
33 |
34 | While it is possible to set this field as optional, it is expected to be
35 | compulsory.
36 |
37 | :param values: allowed record type codes
38 | :return: grammar for the record type field
39 | """
40 | field = basic.lookup(values, name='Record Type (one of %s)' % values)
41 |
42 | return field.setResultsName('record_type')
43 |
44 |
45 | # Record prefix
46 | def record_prefix(required_type, factory):
47 | """
48 | Creates a record prefix for the specified record type.
49 |
50 | :param required_type: the type of the record using this prefix
51 | :param factory: field factory
52 | :return: the record prefix
53 | """
54 | field = record_type(required_type)
55 | field += factory.get_rule('transaction_sequence_n')
56 | field += factory.get_rule('record_sequence_n')
57 |
58 | # field.leaveWhitespace()
59 |
60 | return field
61 |
--------------------------------------------------------------------------------
/cwr/grammar/field/table.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import pyparsing as pp
4 |
5 | from config_cwr.accessor import CWRConfiguration
6 | from data_cwr.accessor import CWRTables
7 |
8 | """
9 | Grammar rules for concrete CWR Table/List Lookup fields.
10 |
11 | These fields all apply the same kind of constraint: all the values not
12 | contained in a defined collection are rejected.
13 |
14 | The only exception is when the field is set as optional. Then an empty string
15 | composed of whitespaces is allowed.
16 |
17 | Additionally, the usual constraints of the Alphanumeric field (non lowercase
18 | ASCII) apply.
19 |
20 | All the values are read from the lists contained in the library, through the
21 | CWRTables class.
22 | """
23 |
24 | __author__ = 'Bernardo Martínez Garrido'
25 | __license__ = 'MIT'
26 | __status__ = 'Development'
27 |
28 | """
29 | Configuration classes.
30 | """
31 |
32 | # Acquires data sources
33 | _tables = CWRTables()
34 | _config = CWRConfiguration()
35 |
36 | """
37 | Fields.
38 | """
39 |
40 |
41 | def char_code(columns, name=None):
42 | """
43 | Character set code field.
44 |
45 | :param name: name for the field
46 | :return: an instance of the Character set code field rules
47 | """
48 | if name is None:
49 | name = 'Char Code Field (' + str(columns) + ' columns)'
50 |
51 | if columns <= 0:
52 | raise BaseException()
53 |
54 | char_sets = None
55 | for char_set in _tables.get_data('character_set'):
56 | regex = '[ ]{' + str(15 - len(char_set)) + '}' + char_set
57 | if char_sets is None:
58 | char_sets = regex
59 | else:
60 | char_sets += '|' + regex
61 |
62 | # Accepted sets
63 | _character_sets = pp.Regex(char_sets)
64 | _unicode_1_16b = pp.Regex('U\+0[0-8,A-F]{3}[ ]{' + str(columns - 6) + '}')
65 | _unicode_2_21b = pp.Regex('U\+0[0-8,A-F]{4}[ ]{' + str(columns - 7) + '}')
66 |
67 | # Basic field
68 | char_code_field = (_character_sets | _unicode_1_16b | _unicode_2_21b)
69 |
70 | # Parse action
71 | char_code_field = char_code_field.setParseAction(lambda s: s[0].strip())
72 |
73 | # Name
74 | char_code_field.setName(name)
75 |
76 | return char_code_field
77 |
--------------------------------------------------------------------------------
/cwr/parser/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/cwr/parser/__init__.py
--------------------------------------------------------------------------------
/cwr/parser/decoder/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/cwr/parser/decoder/__init__.py
--------------------------------------------------------------------------------
/cwr/parser/decoder/cwrjson.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import json
4 |
5 | from cwr.parser.decoder.common import Decoder
6 | from cwr.parser.decoder.dictionary import FileDictionaryDecoder
7 |
8 | """
9 | Classes for decoding CWR classes from JSON dictionaries.
10 | """
11 |
12 | __author__ = 'Bernardo Martínez Garrido'
13 | __license__ = 'MIT'
14 | __status__ = 'Development'
15 |
16 |
17 | class JSONDecoder(Decoder):
18 | def __init__(self):
19 | super(JSONDecoder, self).__init__()
20 | self._dict_decoder = FileDictionaryDecoder()
21 |
22 | def decode(self, data):
23 | decoded = json.loads(data)
24 |
25 | return self._dict_decoder.decode(decoded)
26 |
--------------------------------------------------------------------------------
/cwr/parser/encoder/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/cwr/parser/encoder/__init__.py
--------------------------------------------------------------------------------
/cwr/parser/encoder/common.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | from abc import ABCMeta, abstractmethod
4 |
5 | """
6 | Base classes for implementing encoder parsers.
7 |
8 | An encoder parser receives an instance of a model class and returns a data
9 | structure.
10 |
11 | For example, it may receive a CWRFile instance and return a JSON.
12 |
13 | All encoders are expected to implement the Encoder interface. This offers a
14 | single method which receives the class to encode, and returns an equivalent
15 | data structure.
16 | """
17 |
18 | __author__ = 'Bernardo Martínez Garrido'
19 | __license__ = 'MIT'
20 | __status__ = 'Development'
21 |
22 |
23 | class Encoder(object, metaclass=ABCMeta):
24 | """
25 | Interface for implementing encoder parsers. These parser receive a class
26 | from the domain model and return a data structure.
27 | """
28 |
29 | def __init__(self):
30 | pass
31 |
32 | @abstractmethod
33 | def encode(self, entity):
34 | """
35 | Encodes the data, creating a structure from an instance from the
36 | domain model.
37 |
38 | :param entity: the instance to encode
39 | :return: a data structure created from the received data
40 | """
41 | raise NotImplementedError('The encode method must be implemented')
42 |
--------------------------------------------------------------------------------
/cwr/parser/encoder/standart/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/cwr/parser/encoder/standart/__init__.py
--------------------------------------------------------------------------------
/cwr/utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/cwr/utils/__init__.py
--------------------------------------------------------------------------------
/cwr/validation/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | CWR Data API
4 | ~~~~~~~~~~~~
5 | API for Common Works Registrations.
6 | :copyright: (c) 2015 by WESO
7 | :license: MIT, see LICENSE for more details.
8 | """
9 |
10 | __version__ = '0.0.33'
11 | __license__ = 'MIT'
12 |
--------------------------------------------------------------------------------
/cwr/validation/common.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | from abc import ABCMeta, abstractmethod
4 |
5 | """
6 | Base classes for implementing validation rules.
7 |
8 | """
9 |
10 | __author__ = 'Yaroslav O. Golub'
11 | __license__ = 'MIT'
12 | __status__ = 'Development'
13 |
14 |
15 | class ValidationStatus(object):
16 |
17 | status = False
18 |
19 | message = []
20 |
21 | def __init__(self, code, message=''):
22 | self.code = code
23 | self.message = message
24 |
25 |
26 | class ASValidationStatus(ValidationStatus):
27 |
28 | def __init__(self, message = None):
29 | super().__init__()
30 | self.code = 'AS'
31 |
32 | class NPValidationStatus(ValidationStatus):
33 |
34 | def __init__(self, message = None):
35 | super().__init__()
36 | self.code = 'NP'
37 |
38 |
39 | class Validation(object):
40 | """
41 | Interface for implementing validation. This is abstract class.
42 | """
43 | __metaclass__ = ABCMeta
44 |
45 | data = None
46 |
47 | def __init__(self, data):
48 | self.data = data
49 |
50 | @abstractmethod
51 | def validate(self, entity):
52 | """
53 | Validate entity and return ValidationStatus
54 |
55 | :param entity: the instance to validate
56 | :return: ValidationStatus class
57 | """
58 | raise NotImplementedError('The validate method must be implemented')
59 |
--------------------------------------------------------------------------------
/cwr/validation/record.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 |
4 | from cwr.validation.common import Validation
5 |
6 | """
7 | Base classes for implementing validation rules.
8 |
9 | """
10 |
11 | __author__ = 'Yaroslav O. Golub'
12 | __license__ = 'MIT'
13 | __status__ = 'Development'
14 |
15 |
16 | class ValidationRecord(Validation):
17 | pass
18 |
--------------------------------------------------------------------------------
/cwr/validation/transaction.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | from apt_pkg import __init__
3 |
4 | from cwr.validation.common import Validation, ValidationStatus, ASValidationStatus
5 |
6 | """
7 | Base classes for implementing validation rules.
8 |
9 | """
10 |
11 | __author__ = 'Yaroslav O. Golub'
12 | __license__ = 'MIT'
13 | __status__ = 'Development'
14 |
15 |
16 | class ValidationTransaction(Validation):
17 |
18 | config = None
19 |
20 | def __init__(self, config):
21 | self.config = config
22 |
23 | def validate(self, transaction):
24 | return ASValidationStatus()
25 |
26 |
27 |
--------------------------------------------------------------------------------
/data_cwr/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/data_cwr/__init__.py
--------------------------------------------------------------------------------
/data_cwr/cwr_agreement_role_code.csv:
--------------------------------------------------------------------------------
1 | AC,AS
--------------------------------------------------------------------------------
/data_cwr/cwr_agreement_type.csv:
--------------------------------------------------------------------------------
1 | OG,OS,PG,PS
--------------------------------------------------------------------------------
/data_cwr/cwr_character_set.csv:
--------------------------------------------------------------------------------
1 | Big5,GB
--------------------------------------------------------------------------------
/data_cwr/cwr_composite_type.csv:
--------------------------------------------------------------------------------
1 | COS,MED,POT,UCO
--------------------------------------------------------------------------------
/data_cwr/cwr_excerpt_type.csv:
--------------------------------------------------------------------------------
1 | UEX,MOV
--------------------------------------------------------------------------------
/data_cwr/cwr_files_manufacture_clause.csv:
--------------------------------------------------------------------------------
1 | M,S
--------------------------------------------------------------------------------
/data_cwr/cwr_inclusion_exclusion_indicator.csv:
--------------------------------------------------------------------------------
1 | E,I
--------------------------------------------------------------------------------
/data_cwr/cwr_instrument_code.csv:
--------------------------------------------------------------------------------
1 | ACC,ACL,AFL,AHN,ALP,ALT,AMP,ARC,ASX,BAG,BAR,BAS,BBF,BBT,BCL,BDN,BDR,BEL,BFT,BGL,BGT,BHN,BKA,BNG,BNJ,BOB,BOY,BQF,BRC,BRT,BSN,BSP,BSS,BSX,BTN,CAL,CAR,CBC,CBN,CCL,CEL,CHM,CIM,CLR,CNB,CNG,CNT,COM,CST,CTN,CVD,CYM,DIJ,DIZ,DJM,DRK,DRM,DUL,EBG,EFC,EGT,EHN,ELL,ELP,EOG,ERH,EUP,FLG,FLT,FRN,GHM,GHP,GLS,GNG,GTR,HAR,HBL,HCK,HPS,HRM,HRN,HRP,HUR,KAZ,KEY,KLV,KOT,LUT,LYR,MAN,MAR,MBR,MCS,MEL,MEZ,MID,MSB,NAF,NAR,NHN,OBD,OBO,OND,ORG,PER,PIA,PIC,PPA,PRO,PRP,PWH,REC,RUA,SAM,SAX,SDM,SEQ,SHK,SHM,SHO,SHW,SIT,SNR,SNS,SOP,SOU,SPO,SRC,SSX,STD,SYN,TAB,TAM,TAP,TBA,TEN,THE,THN,TIM,TMB,TMN,TRC,TRI,TRM,TSX,TTM,TYP,UKE,VCL,VDG,VIB,VID,VLA,VLN,VOC,WBK,WHS,WTB,XYL,YQN,ZHG,ZIT
--------------------------------------------------------------------------------
/data_cwr/cwr_intended_purpose.csv:
--------------------------------------------------------------------------------
1 | COM,FIL,GEN,LIB,MUL,RAD,TEL,THR,VID
--------------------------------------------------------------------------------
/data_cwr/cwr_isrc_country_code.csv:
--------------------------------------------------------------------------------
1 | AC,AD,AE,AF,AG,AI,AL,AM,AN,AO,AR,AS,AT,AU,AW,AX,AZ,BA,BB,BD,BE,BF,BG,BH,BI,BJ,BL,BM,BN,BO,BR,BS,BT,BW,BY,BZ,CA,CB,CD,CF,CG,CH,CI,CK,CL,CM,CN,CO,CR,CU,CV,CY,CZ,DE,DJ,DK,DM,DO,DZ,EC,EE,EG,EH,EM,ER,ES,EU,ET,FI,FJ,FK,FM,FO,FR,GA,GB,GD,GE,GF,GG,GH,GI,GL,GM,GN,GP,GQ,GR,GT,GU,GW,GY,HK,HN,HR,HT,HU,ID,IE,IL,IM,IN,IQ,IR,IS,IT,JE,JM,JO,JP,KE,KG,KH,KI,KM,KN,Kosovo,KP,KR,KW,KY,KZ,LA,LB,LC,LI,LK,LR,LS,LT,LU,LV,LY,MA,MC,MD,ME,MF,MG,MH,MK,ML,MM,MN,MO,MP,MQ,MR,MS,MT,MU,MV,MW,MX,MY,MZ,NA,NC,NE,NF,NG,NI,NL,NO,NP,NR,NU,NZ,OECS,OM,PA,PE,PF,PG,PH,PK,PL,PM,PN,PR,PS,PT,PW,PY,QA,RE,RO,RS,RU,RW,SA,SB,SC,SD,SE,SG,SH,SI,SJ,SK,SL,SM,SN,SO,SR,ST,SV,SY,SZ,TC,TD,TG,TH,TJ,TK,TL,TM,TN,TO,TR,TT,TV,TW,TZ,UA,UG,UK,US,UY,UZ,VA,VC,VE,VG,VI,VN,VU,WF,WS,YE,YT,Yugoslavia,ZA,ZM,ZW,QR,QM,QZ,CP,DG,ZZ
--------------------------------------------------------------------------------
/data_cwr/cwr_language_code.csv:
--------------------------------------------------------------------------------
1 | AA,AB,AF,AM,AR,AS,AY,AZ,BA,BE,BG,BH,BI,BN,BO,BR,CA,CO,CS,CY,DA,DE,DZ,EL,EN,EO,ES,ET,EU,FA,FI,FJ,FO,FR,FY,GA,GD,GL,GN,GU,HA,HI,HR,HU,HW,HY,IA,IE,IK,IN,IS,IT,IW,JA,JI,JW,KA,KK,KL,KM,KN,KO,KS,KU,KY,LA,LN,LO,LT,LV,MG,MI,MK,ML,MN,MO,MR,MS,MT,MY,NA,ND,NE,NL,NO,NS,OC,OM,OR,PA,PL,PM,PS,PT,QU,RM,RN,RO,RU,RW,SA,SD,SG,SH,SI,SK,SL,SM,SN,SO,SQ,SR,SS,ST,SU,SV,SW,TA,TE,TG,TH,TI,TK,TL,TN,TO,TR,TS,TT,TW,UK,UR,UZ,VE,VI,VO,WO,XH,YO,ZH,ZU
--------------------------------------------------------------------------------
/data_cwr/cwr_lyric_adaptation.csv:
--------------------------------------------------------------------------------
1 | ADL,MOD,NEW,NON,ORI,REP,TRA,UNS
--------------------------------------------------------------------------------
/data_cwr/cwr_media_type.csv:
--------------------------------------------------------------------------------
1 | CD,CD2,CDM,CDS,CE,CE2,CEP,CES,CXM,CXS,DC,DC2,DL,DM,DMC,DS,DV1,DV2,DV3,DV4,DW,EMC,EP,EPM,LP,LP2,LP3,LP4,MC,MC2,MC3,MC4,MCP,MD,MD2,MDP,MDR,MDS,MLP,MMC,RCD,RCE,RDS,RMC,RMS,S,SA,SA2,SCD,SM2,SMC
--------------------------------------------------------------------------------
/data_cwr/cwr_message_level.csv:
--------------------------------------------------------------------------------
1 | E,F,G,R,T
--------------------------------------------------------------------------------
/data_cwr/cwr_message_type.csv:
--------------------------------------------------------------------------------
1 | E,F,G,R,T
--------------------------------------------------------------------------------
/data_cwr/cwr_music_arrangement.csv:
--------------------------------------------------------------------------------
1 | ARR,ADM,NEW,ORI,UNS
--------------------------------------------------------------------------------
/data_cwr/cwr_musical_work_distribution_category.csv:
--------------------------------------------------------------------------------
1 | JAZ,POP,SER,UNC
--------------------------------------------------------------------------------
/data_cwr/cwr_post_term_collection_status.csv:
--------------------------------------------------------------------------------
1 | D,N,O
--------------------------------------------------------------------------------
/data_cwr/cwr_prior_royalty_status.csv:
--------------------------------------------------------------------------------
1 | A,D,N
--------------------------------------------------------------------------------
/data_cwr/cwr_publisher_type.csv:
--------------------------------------------------------------------------------
1 | AQ,AM,PA,E , E,ES,SE
--------------------------------------------------------------------------------
/data_cwr/cwr_record_type.csv:
--------------------------------------------------------------------------------
1 | GRH,GRT,HDR,TRL,ACK,AGR,EXC,NWR,ISW,REV,ALT,ARI,COM,EWT,IPA,IND,INS,MSG,NAT,NCT,NET,NOW,NPN,NVT,NWN,OPU,ORN,OWR,PER,PWR,REC,SPT,SPU,SWR,SWT,TER,VER
--------------------------------------------------------------------------------
/data_cwr/cwr_recording_format.csv:
--------------------------------------------------------------------------------
1 | A,V
--------------------------------------------------------------------------------
/data_cwr/cwr_recording_technique.csv:
--------------------------------------------------------------------------------
1 | A,D,U
--------------------------------------------------------------------------------
/data_cwr/cwr_sales_manufacture_clause.csv:
--------------------------------------------------------------------------------
1 | M,S
--------------------------------------------------------------------------------
/data_cwr/cwr_sender_type.csv:
--------------------------------------------------------------------------------
1 | PB,SO,AA,WR
--------------------------------------------------------------------------------
/data_cwr/cwr_society_code.csv:
--------------------------------------------------------------------------------
1 | 0,00,000,001,002,003,004,005,006,007,008,009,01,010,011,012,013,014,015,016,017,018,019,02,020,021,022,023,024,025,026,027,028,029,03,030,031,032,033,034,035,036,037,038,039,04,040,041,042,043,044,045,046,047,048,049,05,050,051,052,053,054,055,056,057,058,059,06,060,061,062,063,064,065,066,067,068,069,07,070,071,072,073,074,075,076,077,078,079,08,080,081,082,083,084,085,086,087,088,089,09,090,091,092,093,094,095,096,097,098,099,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,300,301,302,303,304,305,306,307,308,309,310
--------------------------------------------------------------------------------
/data_cwr/cwr_special_agreement_indicator.csv:
--------------------------------------------------------------------------------
1 | B,L,N,R,U,Y
--------------------------------------------------------------------------------
/data_cwr/cwr_standard_instrumentation_type.csv:
--------------------------------------------------------------------------------
1 | AUD,BBA,BCH,BND,BQN,BQU,BRC,BTR,BXT,CAO,CBA,CCH,CEN,CHO,CLC,COR,CQN,DCH,FLC,GML,GQT,HNC,JZE,MCH,MXC,OQU,ORC,PCE,PDU,PFH,PQN,PQU,PTR,SBA,SGT,SOC,SOR,SQN,SQT,SQU,TBC,TCH,TPC,TUC,UCH,WCH,WEN,WQN,WQR,YCH
--------------------------------------------------------------------------------
/data_cwr/cwr_subject_code.csv:
--------------------------------------------------------------------------------
1 | DL,DW,IQ,RQ,SC
--------------------------------------------------------------------------------
/data_cwr/cwr_text_music_relationship.csv:
--------------------------------------------------------------------------------
1 | MUS,MTX,TXT
--------------------------------------------------------------------------------
/data_cwr/cwr_tis_code.csv:
--------------------------------------------------------------------------------
1 | 0004,0008,0012,0020,0024,0028,0031,0032,0036,0040,0044,0048,0050,0051,0052,0056,0064,0068,0070,0072,0076,0084,0090,0096,0100,0104,0108,0112,0116,0120,0124,0132,0140,0144,0148,0152,0156,0158,0170,0174,0178,0180,0188,0191,0192,0196,0200,0203,0204,0208,0212,0214,0218,0222,0226,0230,0231,0232,0233,0242,0246,0250,0258,0262,0266,0268,0270,0276,0278,0280,0288,0296,0300,0308,0320,0324,0328,0332,0336,0340,0344,0348,0352,0356,0360,0364,0368,0372,0376,0380,0384,0388,0392,0398,0400,0404,0408,0410,0414,0417,0418,0422,0426,0428,0430,0434,0438,0440,0442,0450,0454,0458,0462,0466,0470,0478,0480,0484,0492,0496,0498,0499,0504,0508,0512,0516,0520,0524,0528,0540,0548,0554,0558,0562,0566,0578,0583,0584,0585,0586,0591,0598,0600,0604,0608,0616,0620,0624,0626,0630,0634,0642,0643,0646,0659,0662,0670,0674,0678,0682,0686,0688,0690,0694,0702,0703,0704,0705,0706,0710,0716,0720,0724,0728,0729,0732,0736,0740,0748,0752,0756,0760,0762,0764,0768,0776,0780,0784,0788,0792,0795,0798,0800,0804,0807,0810,0818,0826,0834,0840,0854,0858,0860,0862,0882,0886,0887,0890,0891,0894,4,8,12,20,24,28,31,32,36,40,44,48,50,51,52,56,64,68,70,72,76,84,90,96,100,104,108,112,116,120,124,132,140,144,148,152,156,158,170,174,178,180,188,191,192,196,200,203,204,208,212,214,218,222,226,230,231,232,233,242,246,250,258,262,266,268,270,276,278,280,288,296,300,308,320,324,328,332,336,340,344,348,352,356,360,364,368,372,376,380,384,388,392,398,400,404,408,410,414,417,418,422,426,428,430,434,438,440,442,450,454,458,462,466,470,478,480,484,492,496,498,499,504,508,512,516,520,524,528,540,548,554,558,562,566,578,583,584,585,586,591,598,600,604,608,616,620,624,626,630,634,642,643,646,659,662,670,674,678,682,686,688,690,694,702,703,704,705,706,710,716,720,724,728,729,732,736,740,748,752,756,760,762,764,768,776,780,784,788,792,795,798,800,804,807,810,818,826,834,840,854,858,860,862,882,886,887,890,891,894,2100,2101,2102,2103,2104,2105,2106,2107,2108,2109,2110,2111,2112,2113,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,2125,2126,2127,2128,2129,2130,2131,2132,2133,2134,2136
--------------------------------------------------------------------------------
/data_cwr/cwr_title_type.csv:
--------------------------------------------------------------------------------
1 | AL,AT,ET,FT,IT,OL,OT,PT,RT,TE,TT
--------------------------------------------------------------------------------
/data_cwr/cwr_transaction_status.csv:
--------------------------------------------------------------------------------
1 | AC,AS,CO,DU,NP,RA,RC,RJ
--------------------------------------------------------------------------------
/data_cwr/cwr_transaction_type.csv:
--------------------------------------------------------------------------------
1 | ACK,AGR,COP,EXC,ISW,NWR,REV
--------------------------------------------------------------------------------
/data_cwr/cwr_type_of_right.csv:
--------------------------------------------------------------------------------
1 | ALL,MEC,PER,SYN
--------------------------------------------------------------------------------
/data_cwr/cwr_usa_license_indicator.csv:
--------------------------------------------------------------------------------
1 | A,B,S
--------------------------------------------------------------------------------
/data_cwr/cwr_version_type.csv:
--------------------------------------------------------------------------------
1 | MOD,ORI
--------------------------------------------------------------------------------
/data_cwr/cwr_work_type.csv:
--------------------------------------------------------------------------------
1 | AC,AL,AM,AR,BD,BG,BL,CC,CD,CL,CT,DN,FK,FM,JG,JZ,LA,LN,NA,OP,PK,PP,RB,RK,RP,SD,SG,SY,TA
--------------------------------------------------------------------------------
/data_cwr/cwr_writer_designation_code.csv:
--------------------------------------------------------------------------------
1 | A , A,AD,AR,C , C,CA,PA,SA,SR,TR
--------------------------------------------------------------------------------
/docs/diagrams/readme.txt:
--------------------------------------------------------------------------------
1 | These files are UMLet diagram files.
2 |
3 | Get UMLet at http://www.umlet.com/
4 |
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/charset_rules.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/charset_rules.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/cwr_light.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/cwr_light.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/errors.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/errors.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/impl_sheet.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/impl_sheet.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/questionnary_publisher.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/questionnary_publisher.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/questionnary_society.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/questionnary_society.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/sender_id_code.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/sender_id_code.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/specification.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/specification.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/tables.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/tables.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/tis_amend.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/tis_amend.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/tis_hierarchies.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/tis_hierarchies.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/tis_territories.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/tis_territories.rar
--------------------------------------------------------------------------------
/docs/source/_downloads/cwr_files/user_manual.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_downloads/cwr_files/user_manual.rar
--------------------------------------------------------------------------------
/docs/source/_static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_static/favicon.ico
--------------------------------------------------------------------------------
/docs/source/_static/img/rules_tree_generic_example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_static/img/rules_tree_generic_example.png
--------------------------------------------------------------------------------
/docs/source/_static/img/rules_tree_group_header_example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/docs/source/_static/img/rules_tree_group_header_example.png
--------------------------------------------------------------------------------
/docs/source/_templates/status.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/source/contents_standard.rst:
--------------------------------------------------------------------------------
1 | CWR Standard
2 | ============
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 |
7 | cwr_standard/index
8 | other/index
9 | cwr_structure/index
10 | validation/index
--------------------------------------------------------------------------------
/docs/source/cwr_standard/acknowledgement_file.rst:
--------------------------------------------------------------------------------
1 | ====================
2 | Acknowledgement file
3 | ====================
4 |
5 | After receiving and processing the CWR file, the recipient will create and
6 | return an acknowledgement file, containing most of the original file
7 | information, and adding Acknowledgement Transactions.
8 |
9 | These transactions will include all additional information that may be needed,
10 | such as the reasons for rejecting a transaction, or the CAE/IPI numbers where
11 | they may be missing.
12 |
13 | Information that is not relevant to the creator of the Acknowledgment file will
14 | not appear on it. For example, a society will generally not return SPU/SPT
15 | records for sub-publishers in territories it does not control.
16 |
17 | Note that when validating the original CWR file the process won't stop at the
18 | first error encountered, but will continue to report all errors, unless a
19 | severe error makes further processing inadvisable.
20 |
21 | ----------------------
22 | Acknowledgement report
23 | ----------------------
24 |
25 | According to the CWR standard, along the Acknowledgment file a form must be
26 | fulfilled and sent back to the submitter.
27 |
28 | This contains the transmission participants:
29 |
30 | - Society
31 | - Sender (of the original CWR file)
32 |
33 | And also a series of details:
34 |
35 | - File name
36 | - Location
37 | - Description
38 | - File size
39 | - Date or time stamp (YYYYMMDD and HHMMSS format)
40 | - Number of transactions and records
41 |
42 | Along a series of boolean flags:
43 |
44 | - The file has been received and is awaiting validation/processing
45 | - The file has been received and has been successfully validated/processed
46 | - The file is no longer required and can be deleted
47 | - The file has been received and has failed validation/processing (It should be sent again and details of failure are to be indicated to the sender)
48 |
49 | ---------------------------
50 | Acknowledgement transaction
51 | ---------------------------
52 |
53 | Information on the Acknowledgement file is added with the use of
54 | Acknowledgement transactions.
55 |
56 | These mark the Transactions on the original file, adding any needed information
57 | about them, such as if it has been rejected.
58 |
59 | It follows the structure: [ACK, MSG*, AGR | NWR | REV | EXC]
--------------------------------------------------------------------------------
/docs/source/cwr_standard/file_validation.rst:
--------------------------------------------------------------------------------
1 | ===================
2 | CWR file validation
3 | ===================
4 |
5 | ---------------------
6 | File level validation
7 | ---------------------
8 |
9 | ===== ============================================== =============
10 | ID Constraint Failure level
11 | ===== ============================================== =============
12 | 1 File should be readable ER
13 | 2 First record should be HDR ER
14 | 3 Second record should be GRH ER
15 | 4 Groups open with GRH and close with GRT ER
16 | 5 Last record is TRL ER
17 | 6 GRH should be followed by a Transaction header ER
18 | 7 GRT should be followed by a GRH or TRL ER
19 | 7 Only a single HDR and a single TRL exist ER
20 | ===== ============================================== =============
--------------------------------------------------------------------------------
/docs/source/cwr_standard/glossary.rst:
--------------------------------------------------------------------------------
1 | ============
2 | CWR Glossary
3 | ============
4 |
5 | .. glossary::
6 |
7 | Group
8 | A collection with all the transactions of a type in the transmission.
9 |
10 | Control Records
11 | Records used to ensure the data has not been damaged or tampered. These are the Transmission and Group Header and Trailer.
12 |
13 | File
14 | In the CWR context, a file is one following the CWR standard, meaning it has the correct naming scheme and contents.
15 |
16 | Transaction
17 | A collection of new information for things such as work registrations or agreeements.
18 |
19 | Transaction Header
20 | Initial record on a Transaction, which indicates the type of this transaction.
21 |
22 | Transmission
23 | All the collected records in the file. It can be considered as the logical representation of all this data.
--------------------------------------------------------------------------------
/docs/source/cwr_standard/index.rst:
--------------------------------------------------------------------------------
1 | ================
2 | The CWR standard
3 | ================
4 |
5 | The CWR file standard has been created by `CISAC`_ as a way
6 | for publishers and societies to share discographic information.
7 |
8 | CWR files containing updated information are created, sent by a sending party
9 | to a receiver, and then processed before an acknowledgement file is returned.
10 |
11 |
12 | .. toctree::
13 | :maxdepth: 1
14 |
15 | documents
16 | file_structure
17 | field_format
18 | file_validation
19 | acknowledgement_file
20 | miscellany
21 | glossary
22 |
23 | .. _CISAC: www.cisac.org
--------------------------------------------------------------------------------
/docs/source/cwr_standard/miscellany.rst:
--------------------------------------------------------------------------------
1 | ============
2 | Other topics
3 | ============
4 |
5 | -------------------------
6 | About the volumes of work
7 | -------------------------
8 |
9 | How many files may be sent and received, and how often?
10 | -------------------------------------------------------
11 |
12 | As far as we know, the yearly volume is commonly quite low.
13 |
14 | The current format allows sending up to ten thousand files between each
15 | submitter and recipient, which was increased from an original one hundred, but
16 | probably no submitter will send so many files.
17 |
18 | CWR files are commonly sent by publishers each trimester, but can amount to up
19 | to four per year.
20 |
21 | Societies on the other hand may not send a single CWR file in a year, but may
22 | reply to any and all received files with an acknowledgement file.
23 |
24 | How many transactions may bew contained in a file?
25 | --------------------------------------------------
26 |
27 | A single group may contain up to ten million transactions, and there can be a
28 | hundred thousand groups. But again, this limit seems hard to reach.
29 |
30 | A big file will contain around a hundred thousand agreements, which will mean a
31 | few hundred thousand lines. While a smaller one will just have less than ten
32 | thousand lines.
--------------------------------------------------------------------------------
/docs/source/cwr_structure/acknowledgement_record.rst:
--------------------------------------------------------------------------------
1 | ============================
2 | Acknowledgement Record (ACK)
3 | ============================
4 |
5 | This record indicates the transaction status after its validation, along any
6 | information needed to link this transaction with the original one.
7 |
8 | =========================================================== ======================================= ======== ===========
9 | Field Type Required Description
10 | =========================================================== ======================================= ======== ===========
11 | Original Transaction Sequence # Numeric Yes The sequence number of the original transaction
12 | Original Transaction Type Table Lookup (Transaction Type Table) Yes The type of the original transaction
13 | Processing Date Date Yes The date the file was received
14 | Transaction Status Table Lookup (Transaction Status Table) Yes Current status for the Transaction
15 | Creation Title Alphanumeric No If the original transaction reffers to a work, its title should be here
16 | Submitter Creation # Numeric No ID assigned by the submitter. Required if the original Transaction was accepted
17 | Recipient Creation # Numeric No ID assigned by the recipient. Required if the original Transaction was accepted
18 | =========================================================== ======================================= ======== ===========
19 |
--------------------------------------------------------------------------------
/docs/source/cwr_structure/group_header.rst:
--------------------------------------------------------------------------------
1 | ==================
2 | Group Header (GRH)
3 | ==================
4 |
5 | The Group header indicates the begginning of a batch CWR transactions on the
6 | file.
7 |
8 | It contains the following fields:
9 |
10 | ================ ===================================== ======== ===========
11 | Field Type Required Description
12 | ================ ===================================== ======== ===========
13 | Record Type Alphanumeric Yes It is always 'GRH'
14 | Transaction Type Table Lookup (Transaction Type table) Yes All the transactions in the group are of this type
15 | Group ID Numeric Yes Sequential ID starting on 1
16 | Version Number Alphanumeric Yes CWR version of the transaction. By default it is '02.10' for CWR 2.1
17 | Batch request Numeric No ID used by the submitter to internally identify this batch
18 | ================ ===================================== ======== ===========
--------------------------------------------------------------------------------
/docs/source/cwr_structure/group_trailer.rst:
--------------------------------------------------------------------------------
1 | ===================
2 | Group Trailer (GRT)
3 | ===================
4 |
5 | The Group Trailer closes a batch of transactions, and contains validation
6 | information.
7 |
8 | This validation data is the number of transactions and records which should
9 | have been processed.
10 |
11 | It contains the following fields:
12 |
13 | ================= ============ ======== ===========
14 | Field Type Required Description
15 | ================= ============ ======== ===========
16 | Record Type Alphanumeric Yes It is always 'GRT'
17 | Group ID Numeric Yes The same as the header
18 | Transaction Count Numeric Yes Number of transactions in the group
19 | Record Count Numeric Yes Number of records in the group
20 | ================= ============ ======== ===========
--------------------------------------------------------------------------------
/docs/source/cwr_structure/index.rst:
--------------------------------------------------------------------------------
1 | ================================
2 | The CWR file structure in detail
3 | ================================
4 |
5 | This section contains a more detailed view of how is data stored inside a CWR
6 | file.
7 |
8 |
9 | .. toctree::
10 | :maxdepth: 1
11 |
12 | record_type_codes
13 | record_prefix
14 | transmission_header
15 | transmission_trailer
16 | group_header
17 | group_trailer
18 | acknowledgement_record
19 | message_record
--------------------------------------------------------------------------------
/docs/source/cwr_structure/message_record.rst:
--------------------------------------------------------------------------------
1 | ====================
2 | Message Record (MSG)
3 | ====================
4 |
5 | Indicates the results of validation and accompanies Acknowledgement records.
6 |
7 | ========================== ============ ======== ===========
8 | Field Type Required Description
9 | ========================== ============ ======== ===========
10 | Record Prefix Alphanumeric Yes The type is always 'MSG'
11 | Message Type List Lookup Yes One of 'F'/'R'/'T'/'G'/'E'
12 | Original Record Sequence # Numeric Yes The Record Sequence Number which caused this message
13 | Record Type Alphanumeric Yes The Record Type which caused this message
14 | Message Level List Lookup Yes One of 'E'/'G'/'T'/'R'/'F'
15 | Validation Number Alphanumeric Yes Identifies the specific edit condition that generated this message
16 | Message Text Alphanumeric Yes The text associated with this message
17 | ========================== ============ ======== ===========
18 |
--------------------------------------------------------------------------------
/docs/source/cwr_structure/transmission_header.rst:
--------------------------------------------------------------------------------
1 | =========================
2 | Transmission Header (HDR)
3 | =========================
4 |
5 | The Transmission header indicates the begginning of the CWR data on the file,
6 | and contains information about it's creation and sender.
7 |
8 | It contains the following fields:
9 |
10 | =========================== ============ ======== ===========
11 | Field Type Required Description
12 | =========================== ============ ======== ===========
13 | Record Type Alphanumeric Yes It is always 'HDR'
14 | Sender Type Alphanumeric Yes Indicates the role of the sender. Only 'AA', 'PB', 'SO' or 'WR' are accepted.
15 | Sender ID Numeric Yes Code identifying the sender
16 | Sender Name Alphanumeric Yes Name of the sender
17 | EDI Standard Version Number Alphanumeric Yes Version of the header and trailer. '01.10' for CWR 2.1
18 | Creation Date Date Yes The date that this file was created
19 | Creation Time Time Yes The time of day that this file was created
20 | Transmission Date Time Yes The date that this file was transmitted to all receiving entities
21 | Character Set Time No To be used if this file contains data in a character set other than ASCII
22 | =========================== ============ ======== ===========
--------------------------------------------------------------------------------
/docs/source/cwr_structure/transmission_trailer.rst:
--------------------------------------------------------------------------------
1 | ==========================
2 | Transmission Trailer (TRL)
3 | ==========================
4 |
5 | The Group Trailer closes a CWR file, and contains validation information.
6 |
7 | This validation data is the number of groups, transactions and records which
8 | should have been processed.
9 |
10 | It contains the following fields:
11 |
12 | ================= ============ ======== ===========
13 | Field Type Required Description
14 | ================= ============ ======== ===========
15 | Record Type Alphanumeric Yes It is always 'TRL'
16 | Group Count Numeric Yes Number of transactions in the Transmission
17 | Transaction Count Numeric Yes Number of transactions in the Transmission
18 | Record Count Numeric Yes Number of records in the Transmission
19 | ================= ============ ======== ===========
--------------------------------------------------------------------------------
/docs/source/grammar/index.rst:
--------------------------------------------------------------------------------
1 | ===========
2 | CWR grammar
3 | ===========
4 |
5 | This section contains a more detailed view of how is the grammar for CWR files
6 | created.
7 |
8 | .. toctree::
9 | :maxdepth: 1
10 |
11 | rules
12 | config_dsl
--------------------------------------------------------------------------------
/docs/source/grammar/rules.rst:
--------------------------------------------------------------------------------
1 | #####
2 | Rules
3 | #####
4 |
5 | Depending on their scope, there are three kinds of rules:
6 |
7 | - Terminal rules. These are fields, and are not composed by other rules.
8 | - Record. These are the lines from the CWR files, and are composed of terminal rules.
9 | - Group. These are aggregations of records. They may be composed of of any combination of rules, including other groups.
10 |
11 | In practice only terminal rules are different. These are stored in Python
12 | modules, and so are static, while the other rules are generated dynamically from
13 | configuration files.
14 |
15 | ***************************
16 | Rules aggregation and trees
17 | ***************************
18 |
19 | Except for terminal rules, all rules are an aggregation of smaller rules,
20 | creating a small tree.
21 |
22 | These trees are read in pre-order.
23 |
24 | Examples
25 | ========
26 |
27 | Generic rules tree
28 | ------------------
29 |
30 | The following example is a generic rules tree:
31 |
32 | .. image:: ../_static/img/rules_tree_generic_example.png
33 | :alt: Generic rules tree example
34 |
35 | Rules nodes will be substituted by the rules they contain.
36 |
37 | Note that the rule in the second level has a loop. This means that the rules
38 | it contains may appear multiple times.
39 |
40 | As trees are read in pre-order, this would read as:
41 |
42 | "Rule composed of terminal rule 1, followed by terminal rule 2, followed by
43 | terminal rule 4 multiple times, followed by terminal rule 3, followed by
44 | terminal rule 1."
45 |
46 | Group Header
47 | ------------
48 |
49 | The following example represents the Group Header Record:
50 |
51 | .. image:: ../_static/img/rules_tree_group_header_example.png
52 | :alt: Group Header rules tree example
53 |
54 |
--------------------------------------------------------------------------------
/docs/source/index.rst:
--------------------------------------------------------------------------------
1 | ###############
2 | CWR API library
3 | ###############
4 |
5 | :Author: Bernardo Martínez Garrido
6 | :Copyright: WESO 2015
7 | :License: `MIT `_
8 | :Interpreters: Python 2.6, 2.7, 3.2, 3.3, 3.4, Pypy, Pypy3
9 |
10 | The CWR API library offers a model to represent the content of files following
11 | the CISAC CWR standard.
12 |
13 | With this model, and various helper classes, it is not only possible to read
14 | and show those files, but also to operate
15 | with the data they contain.
16 |
17 | This library has been developed based on CWR specification version 2.1 revision
18 | 3, from December 10th 2004.
19 |
20 | *******************
21 | Getting the library
22 | *******************
23 |
24 | .. raw:: html
25 |
26 |
27 |
29 |
30 |
31 |
32 |
33 | The library can be found at Pypi, making its installation it very easy::
34 |
35 | $ pip install cwr-api
36 |
37 | ********
38 | Contents
39 | ********
40 |
41 | Documentation for CWR-DataApi
42 | =============================
43 |
44 | Contents:
45 |
46 | .. toctree::
47 | :maxdepth: 2
48 |
49 | contents_standard
50 |
51 | CWR Data API
52 | ============
53 |
54 | .. toctree::
55 | :maxdepth: 2
56 |
57 | grammar/index
58 |
59 |
60 | Indices and tables
61 | ==================
62 |
63 | * :ref:`genindex`
64 | * :ref:`search`
--------------------------------------------------------------------------------
/docs/source/other/index.rst:
--------------------------------------------------------------------------------
1 | =======================================
2 | Other standards and related information
3 | =======================================
4 |
5 | The CWR standard makes use of other standards or sources of data, which are
6 | documented on this section.
7 |
8 |
9 | .. toctree::
10 | :maxdepth: 1
11 |
12 | ipi_number
--------------------------------------------------------------------------------
/docs/source/other/ipi_number.rst:
--------------------------------------------------------------------------------
1 | ==========
2 | IPI Number
3 | ==========
4 |
5 | There are two fields which appear commonly in records refering to interested
6 | parties: IPI Name Number and IPI Base Number. These are references to ISAC's
7 | Interested Parties Information system, used by CISAC identify Interested
8 | Parties on collective rights management data, and are stored on their
9 | databases.
10 |
11 | Sometimes this is refered as IPI/CAE number. But the CAE (Composer, Author and
12 | Publisher, the E standing for 'Editeur') system is obsolete since 2001.
13 |
14 | These codes are used along ISWC (International Standard Musical Work Code)
15 | codes.
16 |
17 | As previously indicated, IPI numbers are divided into two types:
18 |
19 | - IPI Name Number
20 | - IPI Base Number
21 |
22 | ---------------
23 | IPI Name Number
24 | ---------------
25 |
26 | The IPI Name Number, is just composed of eleven numbers.
27 |
28 | ---------------
29 | IPI Base Number
30 | ---------------
31 |
32 | The IPI Base Number, follows the pattern H-NNNNNNNNN-C, where each digit means:
33 |
34 | - H: header, which is a single letter
35 | - N: identification number. Nine numeric digits.
36 | - C: check digit. A single number.
--------------------------------------------------------------------------------
/docs/source/validation/file_validation.rst:
--------------------------------------------------------------------------------
1 | ===============
2 | File validation
3 | ===============
4 |
5 | File level validation
6 | ---------------------
7 |
8 | == ============================================== =============
9 | ID Constraint Failure level
10 | == ============================================== =============
11 | 1 File should be readable ER
12 | 2 First record should be HDR ER
13 | 3 Second record should be GRH ER
14 | 4 Groups open with GRH and close with GRT ER
15 | 5 Last record is TRL ER
16 | 6 GRH should be followed by a Transaction header ER
17 | 7 GRT should be followed by a GRH or TRL ER
18 | 7 Only a single HDR and a single TRL exist ER
19 | == ============================================== =============
--------------------------------------------------------------------------------
/docs/source/validation/index.rst:
--------------------------------------------------------------------------------
1 | ===================
2 | CWR file validation
3 | ===================
4 |
5 | This section contains a more detailed view of how is a CWR file validated.
6 |
7 | .. toctree::
8 | :maxdepth: 1
9 |
10 | validation_process
11 | file_validation
12 | record_prefix_validation
--------------------------------------------------------------------------------
/docs/source/validation/record_prefix_validation.rst:
--------------------------------------------------------------------------------
1 | ========================
2 | Record Prefix validation
3 | ========================
4 |
5 | ----------------------
6 | Field level validation
7 | ----------------------
8 |
9 | ========= ====================== ============================================================= =============
10 | ID Field Constraint Failure level
11 | ========= ====================== ============================================================= =============
12 | 1 Record Type Should be one from the Record Type or Transaction Type tables ER
13 | 2,3,4,7,8 Transaction Sequence # See below TR/ER
14 | 5,6 Record Sequence # See below ER
15 | ========= ====================== ============================================================= =============
16 |
17 | ------------------------------
18 | Transaction sequence numbering
19 | ------------------------------
20 |
21 | - For the first Transaction header of a group it should be 0 (id 2, fl ER)
22 | - For Transaction headers not being the first in the group, this is equal to the previous transaction number plus one (id 3, fl TR)
23 | - For detail records the code is the same as the last transaction header (id 4, fl TR)
24 | - Transactions sequence numbers should be sequential (id 7, fl ER)
25 | - Detail records on a Transaction should have this Transaction's sequence number (id 8, fl ER)
26 |
27 | -------------------------
28 | Record sequence numbering
29 | -------------------------
30 |
31 | - For Transaction headers it should be 0 (id 5, fl ER)
32 | - For details records this is equal to the previous record number plus one (id 6, fl ER)
--------------------------------------------------------------------------------
/docs/source/validation/validation_process.rst:
--------------------------------------------------------------------------------
1 | ==================
2 | Validation process
3 | ==================
4 |
5 | Once received, the file undergoes a validation process.
6 |
7 | Three levels of validation are applied:
8 |
9 | - Transaction level
10 | - Record level
11 | - Field level
12 |
13 | The Transaction validation ensures the overall relationship between the
14 | records is correct. This checks mainly the order, numbering and counts of
15 | records.
16 |
17 | Record validation checks a concrete relationship between records. For example,
18 | a TER agreement should follow an AGR or TER agreement.
19 |
20 | Field level validation ensures each field contains the correct information.
21 | This checks things such as the size of the field, the pattern it must follow,
22 | or that the references IDs exist somewhere.
23 |
24 | --------------
25 | Failure levels
26 | --------------
27 |
28 | Each validation constraint has a failure level assigned.
29 |
30 | ==== ============
31 | Code Failure name
32 | ==== ============
33 | ER Entire file is rejected
34 | GR Entire group is rejected
35 | TR Entire transaction is rejected
36 | RR Entire record is rejected
37 | FR Record is rejected and set to the default value
38 | ==== ============
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | # Parsing
2 | pyparsing==2.2.0
3 | pyyaml==3.11
4 |
5 | # Deployment
6 | setuptools==26.1.1
7 | twine==1.8.1
8 |
9 | # Documentation
10 | sphinx_bootstrap_theme>=0.4.6
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [wheel]
2 | # This flag says that the code is written to work on both Python 2 and Python
3 | # 3. If at all possible, it is good practice to do this. If you cannot, you
4 | # will need to generate wheels for each Python version that you support.
5 | universal = 1
6 |
7 | [flake8]
8 | max-line-length = 80
9 | exclude = tests/*
--------------------------------------------------------------------------------
/tests/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/acknowledge/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'yaroslav'
2 |
--------------------------------------------------------------------------------
/tests/acknowledge/acknowledge.py:
--------------------------------------------------------------------------------
1 | __author__ = 'yaroslav'
2 |
--------------------------------------------------------------------------------
/tests/acknowledge/test.cwr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/weso/CWR-DataApi/89d537fe0ae87ee9a5e2a9e671b587333332f27b/tests/acknowledge/test.cwr
--------------------------------------------------------------------------------
/tests/grammar/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/grammar/config/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/grammar/config/test_id.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.grammar.factory.config import rule_id
6 |
7 | __author__ = 'Bernardo Martínez Garrido'
8 | __license__ = 'MIT'
9 | __status__ = 'Development'
10 |
11 |
12 | class TestConfigId(unittest.TestCase):
13 | def setUp(self):
14 | self._rule = rule_id
15 |
16 | def test_common(self):
17 | line = ' id: the id'
18 |
19 | result = self._rule.parseString(line)[0]
20 |
21 | self.assertEqual('the id', result)
22 |
--------------------------------------------------------------------------------
/tests/grammar/config/test_options.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.grammar.factory.config import rule_options
6 |
7 | __author__ = 'Bernardo Martínez Garrido'
8 | __license__ = 'MIT'
9 | __status__ = 'Development'
10 |
11 |
12 | class TestConfigOptions(unittest.TestCase):
13 | def setUp(self):
14 | self._rule = rule_options
15 |
16 | def test_zero_options(self):
17 | line = '()'
18 |
19 | result = self._rule.parseString(line)
20 |
21 | self.assertEqual(1, len(result))
22 |
23 | self.assertEqual('', result[0])
24 |
25 | def test_one_options(self):
26 | line = '(option2)'
27 |
28 | result = self._rule.parseString(line)
29 |
30 | self.assertEqual(1, len(result))
31 |
32 | self.assertEqual('option2', result[0])
33 |
34 | def test_two_options(self):
35 | line = '(option1, option2)'
36 |
37 | result = self._rule.parseString(line)
38 |
39 | self.assertEqual(2, len(result))
40 |
41 | self.assertEqual('option1', result[0])
42 | self.assertEqual('option2', result[1])
43 |
--------------------------------------------------------------------------------
/tests/grammar/config/test_rules_file.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.grammar.factory.config import rule_config_file
6 |
7 | __author__ = 'Bernardo Martínez Garrido'
8 | __license__ = 'MIT'
9 | __status__ = 'Development'
10 |
11 |
12 | class TestConfigTerminalRule(unittest.TestCase):
13 | def setUp(self):
14 | self._rule = rule_config_file
15 |
16 | def test_common(self):
17 | rule_data = 'filename:' + '\n' + \
18 | ' id: filename_old' + '\n' + \
19 | ' rules:' + '\n' + \
20 | ' [' + '\n' + \
21 | ' sequence' + '\n' + \
22 | ' [' + '\n' + \
23 | ' field: header (compulsory)' + '\n' + \
24 | ' field: year (compulsory)' + '\n' + \
25 | ' field: sequence_n_old (compulsory)' + '\n' + \
26 | ' field: sender (compulsory)' + '\n' + \
27 | ' field: delimiter_ip (compulsory)' + '\n' + \
28 | ' field: receiver (compulsory)' + '\n' + \
29 | ' ]' + '\n' + \
30 | ' option' + '\n' + \
31 | ' [' + '\n' + \
32 | ' sequence' + '\n' + \
33 | ' [' + '\n' + \
34 | ' field: delimiter_version (compulsory)' + '\n' + \
35 | ' field: version (compulsory)' + '\n' + \
36 | ' ]' + '\n' + \
37 | ' sequence' + '\n' + \
38 | ' [' + '\n' + \
39 | ' field: delimiter_zip (compulsory)' + '\n' + \
40 | ' ]' + '\n' + \
41 | ' ]' + '\n' + \
42 | ' ]'
43 |
44 | rule_data = rule_data + '\n' + rule_data
45 |
46 | result = self._rule.parseString(rule_data)
47 |
48 | self.assertEqual(2, len(result))
49 |
--------------------------------------------------------------------------------
/tests/grammar/config/test_terminal_rule.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.grammar.factory.config import rule_terminal
6 |
7 | __author__ = 'Bernardo Martínez Garrido'
8 | __license__ = 'MIT'
9 | __status__ = 'Development'
10 |
11 |
12 | class TestConfigTerminalRule(unittest.TestCase):
13 | def setUp(self):
14 | self._rule = rule_terminal
15 |
16 | def test_not_options(self):
17 | line = 'field: header'
18 |
19 | result = self._rule.parseString(line)
20 |
21 | self.assertEqual('field', result.rule_type)
22 | self.assertEqual('header', result.rule_name)
23 |
24 | def test_one_option(self):
25 | line = 'field: header (compulsory)'
26 |
27 | result = self._rule.parseString(line)
28 |
29 | self.assertEqual('field', result.rule_type)
30 | self.assertEqual('header', result.rule_name)
31 |
32 | self.assertEqual(1, len(result.rule_options))
33 |
34 | self.assertEqual('compulsory', result.rule_options[0])
35 |
36 | def test_two_options(self):
37 | line = 'field: header (compulsory, optional)'
38 |
39 | result = self._rule.parseString(line)
40 |
41 | self.assertEqual('field', result.rule_type)
42 | self.assertEqual('header', result.rule_name)
43 |
44 | self.assertEqual(2, len(result.rule_options))
45 |
46 | self.assertEqual('compulsory', result.rule_options[0])
47 | self.assertEqual('optional', result.rule_options[1])
48 |
49 | def test_two_options_tabbed(self):
50 | line = ' field: header (compulsory, optional)'
51 |
52 | result = self._rule.parseString(line)
53 |
54 | self.assertEqual('field', result.rule_type)
55 | self.assertEqual('header', result.rule_name)
56 |
57 | self.assertEqual(2, len(result.rule_options))
58 |
59 | self.assertEqual('compulsory', result.rule_options[0])
60 | self.assertEqual('optional', result.rule_options[1])
61 |
--------------------------------------------------------------------------------
/tests/grammar/factory/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/grammar/factory/control/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/grammar/factory/control/test_transmission_trailer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from tests.utils.grammar import get_record_grammar
7 |
8 | """
9 | CWR Transaction Header grammar tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestTransmissionTrailerGrammar(unittest.TestCase):
20 | def setUp(self):
21 | self.grammar = get_record_grammar('transmission_trailer')
22 |
23 | def test_valid_full(self):
24 | record = 'TRL000020000053200005703'
25 |
26 | result = self.grammar.parseString(record)[0]
27 |
28 | self.assertEqual('TRL', result.record_type)
29 | self.assertEqual(2, result.group_count)
30 | self.assertEqual(532, result.transaction_count)
31 | self.assertEqual(5703, result.record_count)
32 |
33 |
34 | class TestParseTransmissionTrailerException(unittest.TestCase):
35 | """
36 | Tests that TransmissionTrailerDecoder throws exceptions with incorrectly formatted strings.
37 | """
38 |
39 | def setUp(self):
40 | self.grammar = get_record_grammar('transmission_header')
41 |
42 | def test_empty(self):
43 | record = ''
44 |
45 | self.assertRaises(ParseException, self.grammar.parseString, record)
46 |
47 | def test_invalid(self):
48 | record = 'This is an invalid string'
49 |
50 | self.assertRaises(ParseException, self.grammar.parseString, record)
51 |
--------------------------------------------------------------------------------
/tests/grammar/factory/file/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/grammar/factory/record/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/grammar/factory/record/test_additional_related_information.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from tests.utils.grammar import get_record_grammar
7 |
8 | """
9 | CWR Additional Related Information grammar tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestAdditionalRelatedInformationGrammar(unittest.TestCase):
20 | """
21 | Tests that the Additional Related Information grammar decodes correctly formatted strings
22 | """
23 |
24 | def setUp(self):
25 | self.grammar = get_record_grammar('additional_related_information')
26 |
27 | def test_valid_full(self):
28 | record = 'ARI0000123400000023001ABCD0123456789ALLDWNOTE '
29 |
30 | result = self.grammar.parseString(record)[0]
31 |
32 | self.assertEqual('ARI', result.record_type)
33 | self.assertEqual(1234, result.transaction_sequence_n)
34 | self.assertEqual(23, result.record_sequence_n)
35 | self.assertEqual(1, result.society_n)
36 | self.assertEqual('ABCD0123456789', result.work_n)
37 | self.assertEqual('ALL', result.type_of_right)
38 | self.assertEqual('DW', result.subject_code)
39 | self.assertEqual('NOTE', result.note)
40 |
41 |
42 | class TestAdditionalRelatedInformationGrammarException(unittest.TestCase):
43 | def setUp(self):
44 | self.grammar = get_record_grammar('additional_related_information')
45 |
46 | def test_empty(self):
47 | """
48 | Tests that a exception is thrown when the Original Transaction Type is NWR and not Creation Title is set.
49 | """
50 | record = ''
51 |
52 | self.assertRaises(ParseException, self.grammar.parseString, record)
53 |
54 | def test_invalid(self):
55 | record = 'This is an invalid string'
56 |
57 | self.assertRaises(ParseException, self.grammar.parseString, record)
58 |
--------------------------------------------------------------------------------
/tests/grammar/factory/record/test_agreement_territory.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from tests.utils.grammar import get_record_grammar
7 |
8 | """
9 | CWR Territory in Agreement grammar tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestAgreementTerritoryGrammar(unittest.TestCase):
20 | """
21 | Tests that the Territory in Agreement grammar decodes correctly formatted strings
22 | """
23 |
24 | def setUp(self):
25 | self.grammar = get_record_grammar('territory_in_agreement')
26 |
27 | def test_valid(self):
28 | """
29 | Tests that Territory in Agreement grammar decodes correctly formatted record prefixes.
30 | """
31 | record = 'TER0000123400000023I0020'
32 |
33 | result = self.grammar.parseString(record)[0]
34 |
35 | self.assertEqual('TER', result.record_type)
36 | self.assertEqual(1234, result.transaction_sequence_n)
37 | self.assertEqual(23, result.record_sequence_n)
38 | self.assertEqual('I', result.inclusion_exclusion_indicator)
39 | self.assertEqual(20, result.tis_numeric_code)
40 |
41 |
42 | class TestAgreementTerritoryGrammarException(unittest.TestCase):
43 | def setUp(self):
44 | self.grammar = get_record_grammar('territory_in_agreement')
45 |
46 | def test_empty(self):
47 | """
48 | Tests that a exception is thrown when the the works number is zero.
49 | """
50 | record = ''
51 |
52 | self.assertRaises(ParseException, self.grammar.parseString, record)
53 |
54 | def test_invalid(self):
55 | record = 'This is an invalid string'
56 |
57 | self.assertRaises(ParseException, self.grammar.parseString, record)
58 |
--------------------------------------------------------------------------------
/tests/grammar/factory/record/test_alternate_title.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from tests.utils.grammar import get_record_grammar
7 |
8 | """
9 | CWR Alternate Title grammar tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestAlternateTitleGrammar(unittest.TestCase):
20 | def setUp(self):
21 | self.grammar = get_record_grammar('work_alternate_title')
22 |
23 | def test_extended_character(self):
24 | record = 'ALT0000028200001380PA\xc6\x8f AT '
25 |
26 | result = self.grammar.parseString(record)[0]
27 |
28 | self.assertEqual('ALT', result.record_type)
29 | self.assertEqual(282, result.transaction_sequence_n)
30 | self.assertEqual(1380, result.record_sequence_n)
31 | self.assertEqual('PA\xc6\x8f', result.alternate_title)
32 | self.assertEqual('AT', result.title_type)
33 | self.assertEqual(None, result.language_code)
34 |
35 | def test_valid_full(self):
36 | record = 'ALT0000123400000023THE TITLE ATES'
37 |
38 | result = self.grammar.parseString(record)[0]
39 |
40 | self.assertEqual('ALT', result.record_type)
41 | self.assertEqual(1234, result.transaction_sequence_n)
42 | self.assertEqual(23, result.record_sequence_n)
43 | self.assertEqual('THE TITLE', result.alternate_title)
44 | self.assertEqual('AT', result.title_type)
45 | self.assertEqual('ES', result.language_code)
46 |
47 |
48 | class TestAlternateTitleGrammarException(unittest.TestCase):
49 | def setUp(self):
50 | self.grammar = get_record_grammar('work_alternate_title')
51 |
52 | def test_empty(self):
53 | """
54 | Tests that a exception is thrown when the the works number is zero.
55 | """
56 | record = ''
57 |
58 | self.assertRaises(ParseException, self.grammar.parseString, record)
59 |
60 | def test_invalid(self):
61 | record = 'This is an invalid string'
62 |
63 | self.assertRaises(ParseException, self.grammar.parseString, record)
64 |
--------------------------------------------------------------------------------
/tests/grammar/factory/record/test_instrumentation_detail.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from tests.utils.grammar import get_record_grammar
7 |
8 | """
9 | CWR Instrumentation Detail grammar tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestInstrumentationDetailGrammar(unittest.TestCase):
20 | """
21 | Tests that the Instrumentation Detail grammar decodes correctly formatted strings
22 | """
23 |
24 | def setUp(self):
25 | self.grammar = get_record_grammar('instrumentation_detail')
26 |
27 | def test_valid_full(self):
28 | """
29 | Tests that NWN grammar decodes correctly formatted record prefixes.
30 |
31 | This test contains all the optional fields.
32 | """
33 | record = 'IND0000123400000023ALT123'
34 |
35 | result = self.grammar.parseString(record)[0]
36 |
37 | self.assertEqual('IND', result.record_type)
38 | self.assertEqual(1234, result.transaction_sequence_n)
39 | self.assertEqual(23, result.record_sequence_n)
40 | self.assertEqual('ALT', result.instrument_code)
41 | self.assertEqual(123, result.number_players)
42 |
43 |
44 | class TestInstrumentationDetailGrammarException(unittest.TestCase):
45 | def setUp(self):
46 | self.grammar = get_record_grammar('instrumentation_detail')
47 |
48 | def test_empty(self):
49 | """
50 | Tests that a exception is thrown when the the works number is zero.
51 | """
52 | record = ''
53 |
54 | self.assertRaises(ParseException, self.grammar.parseString, record)
55 |
56 | def test_invalid(self):
57 | record = 'This is an invalid string'
58 |
59 | self.assertRaises(ParseException, self.grammar.parseString, record)
60 |
--------------------------------------------------------------------------------
/tests/grammar/factory/record/test_instrumentation_summary.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from tests.utils.grammar import get_record_grammar
7 |
8 | """
9 | CWR Instrumentation Summary grammar tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestInstrumentationSummaryGrammar(unittest.TestCase):
20 | """
21 | Tests that the Instrumentation Summary grammar decodes correctly formatted strings
22 | """
23 |
24 | def setUp(self):
25 | self.grammar = get_record_grammar('instrumentation_summary')
26 |
27 | def test_valid_full(self):
28 | """
29 | Tests that NWN grammar decodes correctly formatted record prefixes.
30 |
31 | This test contains all the optional fields.
32 | """
33 | record = 'INS0000123400000023012BBADESCRIPTION '
34 |
35 | result = self.grammar.parseString(record)[0]
36 |
37 | self.assertEqual('INS', result.record_type)
38 | self.assertEqual(1234, result.transaction_sequence_n)
39 | self.assertEqual(23, result.record_sequence_n)
40 | self.assertEqual(12, result.number_voices)
41 | self.assertEqual('BBA', result.standard_instrumentation_type)
42 | self.assertEqual('DESCRIPTION', result.instrumentation_description)
43 |
44 |
45 | class TestInstrumentationSummaryGrammarException(unittest.TestCase):
46 | def setUp(self):
47 | self.grammar = get_record_grammar('instrumentation_summary')
48 |
49 | def test_empty(self):
50 | """
51 | Tests that a exception is thrown when the the works number is zero.
52 | """
53 | record = ''
54 |
55 | self.assertRaises(ParseException, self.grammar.parseString, record)
56 |
57 | def test_invalid(self):
58 | record = 'This is an invalid string'
59 |
60 | self.assertRaises(ParseException, self.grammar.parseString, record)
61 |
--------------------------------------------------------------------------------
/tests/grammar/factory/record/test_message.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from tests.utils.grammar import get_record_grammar
7 |
8 | """
9 | CWR Message grammar tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestMessageGrammar(unittest.TestCase):
20 | """
21 | Tests that the Message grammar decodes correctly formatted strings
22 | """
23 |
24 | def setUp(self):
25 | self.grammar = get_record_grammar('message')
26 |
27 | def test_valid_full(self):
28 | """
29 | Tests that NWN grammar decodes correctly formatted record prefixes.
30 |
31 | This test contains all the optional fields.
32 | """
33 | record = 'MSG0000123400000023F00001235AGRE123MESSAGE '
34 |
35 | result = self.grammar.parseString(record)[0]
36 |
37 | self.assertEqual('MSG', result.record_type)
38 | self.assertEqual(1234, result.transaction_sequence_n)
39 | self.assertEqual(23, result.record_sequence_n)
40 | self.assertEqual('F', result.message_type)
41 | self.assertEqual(1235, result.original_record_sequence_n)
42 | self.assertEqual('AGR', result.message_record_type)
43 | self.assertEqual('E', result.message_level)
44 | self.assertEqual(123, result.validation_n)
45 | self.assertEqual('MESSAGE', result.message_text)
46 |
47 |
48 | class TestMessageGrammarException(unittest.TestCase):
49 | def setUp(self):
50 | self.grammar = get_record_grammar('message')
51 |
52 | def test_empty(self):
53 | """
54 | Tests that a exception is thrown when the the works number is zero.
55 | """
56 | record = ''
57 |
58 | self.assertRaises(ParseException, self.grammar.parseString, record)
59 |
60 | def test_invalid(self):
61 | record = 'This is an invalid string'
62 |
63 | self.assertRaises(ParseException, self.grammar.parseString, record)
64 |
--------------------------------------------------------------------------------
/tests/grammar/factory/record/test_performing_artist.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from tests.utils.grammar import get_record_grammar
7 |
8 | """
9 | CWR Performing Artist grammar tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestPerformingArtistGrammar(unittest.TestCase):
20 | def setUp(self):
21 | self.grammar = get_record_grammar('performing_artist')
22 |
23 | def test_valid_full(self):
24 | record = 'PER0000123400000023LAST NAME FIRST NAME 00014107338I-000000229-7'
25 |
26 | result = self.grammar.parseString(record)[0]
27 |
28 | self.assertEqual('PER', result.record_type)
29 | self.assertEqual(1234, result.transaction_sequence_n)
30 | self.assertEqual(23, result.record_sequence_n)
31 | self.assertEqual('LAST NAME', result.performing_artist_last_name)
32 | self.assertEqual('FIRST NAME', result.performing_artist_first_name)
33 | self.assertEqual(14107338, result.performing_artist_ipi_name_n)
34 | self.assertEqual('I-000000229-7', result.performing_artist_ipi_base_n)
35 |
36 |
37 | class TestPerformingArtistGrammarException(unittest.TestCase):
38 | def setUp(self):
39 | self.grammar = get_record_grammar('performing_artist')
40 |
41 | def test_empty(self):
42 | """
43 | Tests that a exception is thrown when the the works number is zero.
44 | """
45 | record = ''
46 |
47 | self.assertRaises(ParseException, self.grammar.parseString, record)
48 |
49 | def test_invalid(self):
50 | record = 'This is an invalid string'
51 |
52 | self.assertRaises(ParseException, self.grammar.parseString, record)
53 |
--------------------------------------------------------------------------------
/tests/grammar/factory/record/test_writer_publisher.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from tests.utils.grammar import get_record_grammar
7 |
8 | """
9 | CWR Publisher For Writer grammar tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestWriterPublisherGrammar(unittest.TestCase):
20 | """
21 | Tests that the Writer grammar decodes correctly formatted strings
22 | """
23 |
24 | def setUp(self):
25 | self.grammar = get_record_grammar('writer_publisher')
26 |
27 | def test_valid_full(self):
28 | """
29 | Tests that Writer grammar decodes correctly formatted record prefixes.
30 |
31 | This test contains all the optional fields.
32 | """
33 | record = 'PWR0000123400000023A12345678THE PUBLISHER C1234567890123D1234567890123A12345678'
34 |
35 | result = self.grammar.parseString(record)[0]
36 |
37 | self.assertEqual('PWR', result.record_type)
38 | self.assertEqual(1234, result.transaction_sequence_n)
39 | self.assertEqual(23, result.record_sequence_n)
40 | self.assertEqual('A12345678', result.publisher_ip_n)
41 | # self.assertEqual('THE PUBLISHER', result.publisher_name)
42 | self.assertEqual('C1234567890123', result.submitter_agreement_n)
43 | self.assertEqual('D1234567890123', result.society_assigned_agreement_n)
44 | self.assertEqual('A12345678', result.writer_ip_n)
45 |
46 |
47 | class TestWriterPublisherGrammarException(unittest.TestCase):
48 | def setUp(self):
49 | self.grammar = get_record_grammar('writer_publisher')
50 |
51 | def test_empty(self):
52 | """
53 | Tests that a exception is thrown when the the works number is zero.
54 | """
55 | record = ''
56 |
57 | self.assertRaises(ParseException, self.grammar.parseString, record)
58 |
59 | def test_invalid(self):
60 | record = 'This is an invalid string'
61 |
62 | self.assertRaises(ParseException, self.grammar.parseString, record)
63 |
--------------------------------------------------------------------------------
/tests/grammar/factory/test_default_rule_factory_times.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 | import time
4 | import sys
5 |
6 | from cwr.parser.decoder.file import default_grammar_factory
7 |
8 | """
9 | Tests for the DefaultFieldFactory.
10 | """
11 |
12 | __author__ = 'Bernardo Martínez Garrido'
13 | __license__ = 'MIT'
14 | __status__ = 'Development'
15 |
16 |
17 | class TestDefaultRuleFactory(unittest.TestCase):
18 | def setUp(self):
19 | self._factory = default_grammar_factory()
20 |
21 | def test_10000(self):
22 | start = time.clock()
23 | if sys.version_info[0] == 2:
24 | for x in range(10000):
25 | self._factory.get_rule('transmission')
26 | else:
27 | for x in range(10000):
28 | self._factory.get_rule('transmission')
29 | end = time.clock()
30 |
31 | time_parse = (end - start)
32 |
33 | self.assertTrue(time_parse < 2)
34 |
--------------------------------------------------------------------------------
/tests/grammar/factory/test_field_factory_times.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 | import time
4 | import sys
5 |
6 | from cwr.grammar.factory.rule import FieldRuleFactory
7 | from cwr.grammar.factory.adapter import NumericAdapter
8 |
9 | """
10 | Tests for the DefaultFieldFactory.
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | def _factory():
19 | adapters = {'numeric': NumericAdapter()}
20 |
21 | config_fields = {
22 | 'test_field': {'type': 'numeric', 'name': 'Test Field',
23 | 'size': 3}}
24 |
25 | return FieldRuleFactory(config_fields, adapters)
26 |
27 |
28 | class TestFieldRuleFactory(unittest.TestCase):
29 | def setUp(self):
30 | self._factory = _factory()
31 |
32 | def test_10000(self):
33 | start = time.clock()
34 | if sys.version_info[0] == 2:
35 | for x in range(10000):
36 | self._factory.get_rule('test_field')
37 | else:
38 | for x in range(10000):
39 | self._factory.get_rule('test_field')
40 | end = time.clock()
41 |
42 | time_parse = (end - start)
43 |
44 | self.assertTrue(time_parse < 1)
45 |
--------------------------------------------------------------------------------
/tests/grammar/factory/test_rule_factory_repeated_call.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from cwr.grammar.factory.rule import FieldRuleFactory
5 | from cwr.grammar.factory.adapter import NumericAdapter
6 | from cwr.parser.decoder.file import default_grammar_factory
7 |
8 | """
9 | Tests for the DefaultFieldFactory.
10 | """
11 |
12 | __author__ = 'Bernardo Martínez Garrido'
13 | __license__ = 'MIT'
14 | __status__ = 'Development'
15 |
16 |
17 | def _field_factory():
18 | adapters = {'numeric': NumericAdapter()}
19 |
20 | config_fields = {
21 | 'test_field': {'type': 'numeric', 'name': 'Test Field',
22 | 'size': 3}}
23 |
24 | return FieldRuleFactory(config_fields, adapters)
25 |
26 |
27 | class TestFieldRuleFactory(unittest.TestCase):
28 | def setUp(self):
29 | self._factory = _field_factory()
30 |
31 | def test_repeat(self):
32 | rule = self._factory.get_rule('test_field')
33 | rule_2 = self._factory.get_rule('test_field')
34 |
35 | self.assertEqual(rule, rule_2)
36 |
37 |
38 | class TestDefaultRuleFactory(unittest.TestCase):
39 | def setUp(self):
40 | self._factory = default_grammar_factory()
41 |
42 | def test_repeat(self):
43 | rule = self._factory.get_rule('transmission')
44 | rule_2 = self._factory.get_rule('transmission')
45 |
46 | self.assertEqual(rule, rule_2)
47 |
--------------------------------------------------------------------------------
/tests/grammar/factory/transaction/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/grammar/factory/transaction/test_assignor_information.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from tests.utils.grammar import get_record_grammar
7 |
8 | """
9 | CWR Acquirer Information grammar tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestAssignorInformationGrammar(unittest.TestCase):
20 | def setUp(self):
21 | self.grammar = get_record_grammar('ipa_information')
22 |
23 | def test_full(self):
24 | ipa = 'IPA0000123400000023AC01234567890I-000000229-7A12345678LAST NAME FIRST NAME 009020500100300001102312'
25 | npa = 'NPA0000123400000023012345678PARTY NAME PARTY WRITER NAME ES'
26 |
27 | record = ipa + '\n' + npa
28 |
29 | result = self.grammar.parseString(record)
30 |
31 | self.assertEqual('IPA', result[0].record_type)
32 | self.assertEqual('NPA', result[1].record_type)
33 |
34 | def test_min(self):
35 | ipa = 'IPA0000123400000023AC01234567890I-000000229-7A12345678LAST NAME FIRST NAME 009020500100300001102312'
36 |
37 | record = ipa
38 |
39 | result = self.grammar.parseString(record)
40 |
41 | self.assertEqual('IPA', result[0].record_type)
42 |
43 |
44 | class TestAssignorInformationGrammarException(unittest.TestCase):
45 | def setUp(self):
46 | self.grammar = get_record_grammar('ipa_information')
47 |
48 | def test_empty(self):
49 | """
50 | Tests that a exception is thrown when the the works number is zero.
51 | """
52 | record = ''
53 |
54 | self.assertRaises(ParseException, self.grammar.parseString, record)
55 |
56 | def test_invalid(self):
57 | record = 'This is an invalid string'
58 |
59 | self.assertRaises(ParseException, self.grammar.parseString, record)
60 |
--------------------------------------------------------------------------------
/tests/grammar/factory/transaction/test_instrumentation_information.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from tests.utils.grammar import get_record_grammar
7 |
8 | """
9 | CWR Instrumentation Information grammar tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestInstrumentationInformationGrammar(unittest.TestCase):
20 | def setUp(self):
21 | self.grammar = get_record_grammar('instrumentation_information')
22 |
23 | def test_valid_full(self):
24 | summary = 'INS0000123400000023012BBADESCRIPTION '
25 | detail_1 = 'IND0000123400000023ALT123'
26 | detail_2 = 'IND0000123400000023ALT123'
27 |
28 | record = summary + '\n' + detail_1 + '\n' + detail_2
29 |
30 | result = self.grammar.parseString(record)
31 |
32 | self.assertEqual(3, len(result))
33 |
34 | self.assertEqual('INS', result[0].record_type)
35 | self.assertEqual('IND', result[1].record_type)
36 | self.assertEqual('IND', result[2].record_type)
37 |
38 | def test_min(self):
39 | summary = 'INS0000123400000023012BBADESCRIPTION '
40 |
41 | record = summary
42 |
43 | result = self.grammar.parseString(record)
44 |
45 | self.assertEqual(1, len(result))
46 |
47 | self.assertEqual('INS', result[0].record_type)
48 |
49 |
50 | class TestInstrumentationInformationGrammarException(unittest.TestCase):
51 | def setUp(self):
52 | self.grammar = get_record_grammar('instrumentation_information')
53 |
54 | def test_empty(self):
55 | """
56 | Tests that a exception is thrown when the the works number is zero.
57 | """
58 | record = ''
59 |
60 | self.assertRaises(ParseException, self.grammar.parseString, record)
61 |
62 | def test_invalid(self):
63 | record = 'This is an invalid string'
64 |
65 | self.assertRaises(ParseException, self.grammar.parseString, record)
66 |
--------------------------------------------------------------------------------
/tests/grammar/field/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/grammar/field/record/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/grammar/field/special/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/grammar/field/special/test_avi.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from cwr.grammar.field import special
5 |
6 | """
7 | Tests for V-ISAN field.
8 | """
9 |
10 | __author__ = 'Bernardo Martínez Garrido'
11 | __license__ = 'MIT'
12 | __status__ = 'Development'
13 |
14 |
15 | class TestAVIValid(unittest.TestCase):
16 | def setUp(self):
17 | self.ean = special.audio_visual_key()
18 |
19 | def test_common(self):
20 | """
21 | Tests an average code.
22 | """
23 | code = '012012345678901234'
24 |
25 | result = self.ean.parseString(code)[0]
26 |
27 | self.assertEqual(12, result.society_code)
28 | self.assertEqual('012345678901234', result.av_number)
29 |
30 |
31 | class TestAVIResultName(unittest.TestCase):
32 | """
33 | Tests that the IPI Base Number accepts and parses valid values.
34 | """
35 |
36 | def setUp(self):
37 | self.ean = special.audio_visual_key()
38 |
39 | def test_common(self):
40 | code = '012012345678901234'
41 |
42 | result = self.ean.parseString(code)
43 |
44 | self.assertEqual(12, result.audio_visual_key.society_code)
45 | self.assertEqual('012345678901234', result.audio_visual_key.av_number)
46 |
--------------------------------------------------------------------------------
/tests/grammar/field/special/test_date_time.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from cwr.grammar.field import special
5 |
6 | """
7 | Tests for the Date and Time field.
8 | """
9 |
10 | __author__ = 'Bernardo Martínez Garrido'
11 | __license__ = 'MIT'
12 | __status__ = 'Development'
13 |
14 |
15 | class TestDateTimeValid(unittest.TestCase):
16 | def setUp(self):
17 | self.ean = special.date_time()
18 |
19 | def test_common(self):
20 | """
21 | Tests an average code.
22 | """
23 | date = '20120115123000'
24 |
25 | result = self.ean.parseString(date)[0]
26 |
27 | self.assertEqual(2012, result.year)
28 | self.assertEqual(1, result.month)
29 | self.assertEqual(15, result.day)
30 | self.assertEqual(12, result.hour)
31 | self.assertEqual(30, result.minute)
32 | self.assertEqual(0, result.second)
33 |
--------------------------------------------------------------------------------
/tests/grammar/field/special/test_ean_13.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from cwr.grammar.field import special
5 |
6 | """
7 | Tests for EAN 13 fields.
8 | """
9 |
10 | __author__ = 'Bernardo Martínez Garrido'
11 | __license__ = 'MIT'
12 | __status__ = 'Development'
13 |
14 |
15 | class TestEAN13Valid(unittest.TestCase):
16 | def setUp(self):
17 | self.ean = special.ean_13()
18 |
19 | def test_common(self):
20 | """
21 | Tests an average code.
22 | """
23 | code = '1234567890123'
24 |
25 | result = self.ean.parseString(code)[0]
26 |
27 | self.assertEqual(1234567890123, result)
28 |
29 |
30 | class TestEAN13ResultName(unittest.TestCase):
31 | """
32 | Tests that the IPI Base Number accepts and parses valid values.
33 | """
34 |
35 | def setUp(self):
36 | self.ean = special.ean_13()
37 |
38 | def test_common(self):
39 | code = '1234567890123'
40 |
41 | result = self.ean.parseString(code)
42 |
43 | self.assertEqual(1234567890123, result.ean_13)
44 |
--------------------------------------------------------------------------------
/tests/grammar/field/special/test_isrc.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from pyparsing import ParseException
5 |
6 | from cwr.grammar.field import special
7 |
8 | """
9 | Tests for ISRC fields.
10 | """
11 |
12 | __author__ = 'Bernardo Martínez Garrido'
13 | __license__ = 'MIT'
14 | __status__ = 'Development'
15 |
16 |
17 | class TestISRCShort(unittest.TestCase):
18 | def setUp(self):
19 | self.isrc = special.isrc()
20 |
21 | def test_common(self):
22 | """
23 | Tests an average code.
24 | """
25 | code = 'ES-A2B-12-12'
26 |
27 | result = self.isrc.parseString(code)[0]
28 |
29 | self.assertEqual('ES-A2B-12-12', result)
30 |
31 | def test_zeros(self):
32 | code = 'ES-A2B-00-00'
33 |
34 | result = self.isrc.parseString(code)
35 |
36 | self.assertEqual('ES-A2B-00-00', result.isrc)
37 |
38 |
39 | class TestISRCLong(unittest.TestCase):
40 | def setUp(self):
41 | self.isrc = special.isrc()
42 |
43 | def test_common(self):
44 | """
45 | Tests an average code.
46 | """
47 | code = 'ESABC9100055'
48 |
49 | result = self.isrc.parseString(code)[0]
50 |
51 | self.assertEqual('ESABC9100055', result)
52 |
53 |
54 | class TestISRCExceptionShort(unittest.TestCase):
55 | def setUp(self):
56 | self.isrc = special.isrc()
57 |
58 | def test_invalid_country(self):
59 | """
60 | Tests an average code.
61 | """
62 | code = 'AA-A2B-12-12'
63 |
64 | self.assertRaises(ParseException, self.isrc.parseString, code)
65 |
66 | def test_only_text(self):
67 | """
68 | Tests an average code.
69 | """
70 | code = 'AABABBCCCDDD'
71 |
72 | self.assertRaises(ParseException, self.isrc.parseString, code)
73 |
74 |
75 | class TestISRCExceptionLong(unittest.TestCase):
76 | def setUp(self):
77 | self.isrc = special.isrc()
78 |
79 | def test_invalid_country(self):
80 | """
81 | Tests an average code.
82 | """
83 | code = 'AAABC9100055'
84 |
85 | self.assertRaises(ParseException, self.isrc.parseString, code)
86 |
--------------------------------------------------------------------------------
/tests/grammar/field/special/test_visan.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import unittest
3 |
4 | from cwr.grammar.field import special
5 |
6 | """
7 | Tests for V-ISAN field.
8 | """
9 |
10 | __author__ = 'Bernardo Martínez Garrido'
11 | __license__ = 'MIT'
12 | __status__ = 'Development'
13 |
14 |
15 | class TestVISANValid(unittest.TestCase):
16 | def setUp(self):
17 | self.ean = special.visan()
18 |
19 | def test_common(self):
20 | """
21 | Tests an average code.
22 | """
23 | code = '0123456701234567891201231'
24 |
25 | result = self.ean.parseString(code)[0]
26 |
27 | self.assertEqual('0123456701234567891201231', result)
28 |
29 |
30 | class TestVISANResultName(unittest.TestCase):
31 | """
32 | Tests that the IPI Base Number accepts and parses valid values.
33 | """
34 |
35 | def setUp(self):
36 | self.ean = special.visan()
37 |
38 | def test_common(self):
39 | code = '0123456701234567891201231'
40 |
41 | result = self.ean.parseString(code)
42 |
43 | self.assertEqual('0123456701234567891201231', result.visan)
44 |
--------------------------------------------------------------------------------
/tests/model/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/model/iswc.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.other import ISWCCode
6 |
7 | """
8 | Tests for miscellany model classes.
9 | """
10 |
11 | __author__ = 'Bernardo Martínez Garrido'
12 | __license__ = 'MIT'
13 | __status__ = 'Development'
14 |
15 |
16 | class TestISWCCode(unittest.TestCase):
17 | """
18 | Tests the ISWCCode class.
19 | """
20 |
21 | def test_printable_text(self):
22 | iswc = ISWCCode(123, 1)
23 |
24 | self.assertEqual('ISWC T-000.000.123-1', str(iswc))
25 |
26 | def test_printable_text_full(self):
27 | iswc = ISWCCode(123456789, 1)
28 |
29 | self.assertEqual('ISWC T-123.456.789-1', str(iswc))
30 |
--------------------------------------------------------------------------------
/tests/parser/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/cwrjson/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/cwrjson/decoder/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/cwrjson/encoder/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/control/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/control/test_group_header.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import GroupHeaderDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestGroupHeaderDictionaryEncoding(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = GroupHeaderDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'GRH'
26 | data['group_id'] = 5
27 | data['transaction_type'] = 'AGR'
28 | data['version_number'] = '02.10'
29 | data['batch_request_id'] = 123456789
30 |
31 | record = self._decoder.decode(data)
32 |
33 | self.assertEqual('GRH', record.record_type)
34 | self.assertEqual(5, record.group_id)
35 | self.assertEqual('AGR', record.transaction_type)
36 | self.assertEqual('02.10', record.version_number)
37 | self.assertEqual(123456789, record.batch_request_id)
38 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/control/test_group_trailer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import GroupTrailerDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestGroupTrailerDictionaryEncoding(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = GroupTrailerDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'GRH'
26 | data['group_id'] = 5
27 | data['transaction_type'] = 'AGR'
28 | data['transaction_count'] = 111
29 | data['record_count'] = 222
30 |
31 | record = self._decoder.decode(data)
32 |
33 | self.assertEqual('GRH', record.record_type)
34 | self.assertEqual(5, record.group_id)
35 | self.assertEqual(111, record.transaction_count)
36 | self.assertEqual(222, record.record_count)
37 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/control/test_transmission_header.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 | import datetime
5 |
6 | from cwr.parser.decoder.dictionary import TransmissionHeaderDictionaryDecoder
7 |
8 | """
9 | Dictionary to Message decoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestTransmissionHeaderDecoder(unittest.TestCase):
20 | def setUp(self):
21 | self._decoder = TransmissionHeaderDictionaryDecoder()
22 |
23 | def test_encoded(self):
24 | data = {}
25 |
26 | data['record_type'] = 'HDR'
27 | data['sender_id'] = 'SND123'
28 | data['sender_name'] = 'THE SENDER'
29 | data['sender_type'] = 'SO'
30 | data['creation_date_time'] = datetime.datetime.strptime('20030216',
31 | '%Y%m%d').date()
32 | data['transmission_date'] = datetime.datetime.strptime('20030217',
33 | '%Y%m%d').date()
34 | data['edi_standard'] = '01.10'
35 | data['character_set'] = 'ASCII'
36 |
37 | record = self._decoder.decode(data)
38 |
39 | self.assertEqual('HDR', record.record_type)
40 | self.assertEqual('SND123', record.sender_id)
41 | self.assertEqual('THE SENDER', record.sender_name)
42 | self.assertEqual('SO', record.sender_type)
43 | self.assertEqual(
44 | datetime.datetime.strptime('20030216', '%Y%m%d').date(),
45 | record.creation_date_time)
46 | self.assertEqual(
47 | datetime.datetime.strptime('20030217', '%Y%m%d').date(),
48 | record.transmission_date)
49 | self.assertEqual('01.10', record.edi_standard)
50 | self.assertEqual('ASCII', record.character_set)
51 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/control/test_transmission_trailer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import TransmissionTrailerDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestTransmissionTrailerDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = TransmissionTrailerDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'TRL'
26 | data['group_count'] = 11
27 | data['transaction_count'] = 22
28 | data['record_count'] = 33
29 |
30 | record = self._decoder.decode(data)
31 |
32 | self.assertEqual('TRL', record.record_type)
33 | self.assertEqual(11, record.group_count)
34 | self.assertEqual(22, record.transaction_count)
35 | self.assertEqual(33, record.record_count)
36 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/file/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/file/test_file_tag.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import FileTagDictionaryDecoder
6 |
7 | """
8 | Group Header to dictionary encoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestFileTagDictionaryDecoding(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = FileTagDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['year'] = 2015
26 | data['sequence_n'] = 123
27 | data['sender'] = 'SND'
28 | data['receiver'] = 'RCV'
29 | data['version'] = 2.1
30 |
31 | tag = self._decoder.decode(data)
32 |
33 | self.assertEqual(2015, tag.year)
34 | self.assertEqual(123, tag.sequence_n)
35 | self.assertEqual('SND', tag.sender)
36 | self.assertEqual('RCV', tag.receiver)
37 | self.assertEqual(2.1, tag.version)
38 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/interested_party/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/interested_party/test_publisher.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import PublisherDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestPublisherDictionaryEncoding(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = PublisherDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['ip_n'] = 'IP123'
26 | data['publisher_name'] = 'NAME'
27 | data['ipi_name_n'] = 250165006
28 | data['ipi_base_n'] = 'I-000000229-7'
29 | data['tax_id'] = 923703412
30 |
31 | record = self._decoder.decode(data)
32 |
33 | self.assertEqual('IP123', record.ip_n)
34 | self.assertEqual('NAME', record.publisher_name)
35 | self.assertEqual(250165006, record.ipi_name_n)
36 | self.assertEqual(923703412, record.tax_id)
37 |
38 | self.assertEqual('I-000000229-7', record.ipi_base_n)
39 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/interested_party/test_writer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import WriterDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestWorkDictionaryDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = WriterDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['ip_n'] = 'ABC15'
26 | data['personal_number'] = 'ABC1234'
27 | data['ipi_name_n'] = 14107338
28 | data['ipi_base_n'] = 'I-000000229-7'
29 | data['writer_first_name'] = 'NAME'
30 | data['writer_last_name'] = 'LAST NAME'
31 | data['tax_id'] = 923703412
32 |
33 | record = self._decoder.decode(data)
34 |
35 | self.assertEqual('ABC15', record.ip_n)
36 | self.assertEqual('ABC1234', record.personal_number)
37 | self.assertEqual(14107338, record.ipi_name_n)
38 | self.assertEqual('NAME', record.writer_first_name)
39 | self.assertEqual('LAST NAME', record.writer_last_name)
40 | self.assertEqual(923703412, record.tax_id)
41 |
42 | self.assertEqual('I-000000229-7', record.ipi_base_n)
43 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/other/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/other/test_avi_key.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import AVIKeyDictionaryDecoder
6 |
7 | """
8 | Acknowledgement to dictionary encoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestAVIKeyDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = AVIKeyDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['society_code'] = 1
26 | data['av_number'] = 2
27 |
28 | record = self._decoder.decode(data)
29 |
30 | self.assertEqual(1, record.society_code)
31 | self.assertEqual(2, record.av_number)
32 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/other/test_ipi_base.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import IPIBaseDictionaryDecoder
6 |
7 | """
8 | Acknowledgement to dictionary encoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestIPIBaseDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = IPIBaseDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | record = self._decoder.decode('I-000000229-7')
24 |
25 | self.assertEqual('I-000000229-7', record)
26 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/other/test_iswc.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import ISWCDictionaryDecoder
6 |
7 | """
8 | Acknowledgement to dictionary encoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestISWCDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = ISWCDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | record = self._decoder.decode('T0123456789')
24 |
25 | self.assertEqual('T0123456789', record)
26 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/other/test_visan.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import VISANDictionaryDecoder
6 |
7 | """
8 | Acknowledgement to dictionary encoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestVISANDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = VISANDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['version'] = 1
26 | data['isan'] = 2
27 | data['episode'] = 3
28 | data['check_digit'] = 4
29 |
30 | record = self._decoder.decode(1234)
31 |
32 | self.assertEqual(1234, record)
33 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_acknowledgement.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 | import datetime
5 |
6 | from cwr.parser.decoder.dictionary import AcknowledgementDictionaryDecoder
7 |
8 | """
9 | Dictionary to Acknowledgement decoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestAcknowledgementRecordDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._decoder = AcknowledgementDictionaryDecoder()
22 |
23 | def test_encoded(self):
24 | data = {}
25 |
26 | data['record_type'] = 'ACK'
27 | data['transaction_sequence_n'] = 3
28 | data['record_sequence_n'] = 15
29 | data['original_group_id'] = 4
30 | data['original_transaction_sequence_n'] = 5
31 | data['original_transaction_type'] = 'AGR'
32 | data['transaction_status'] = 'AS'
33 | data['creation_date_time'] = datetime.datetime.strptime('20030215',
34 | '%Y%m%d').date()
35 | data['processing_date'] = datetime.datetime.strptime('20030216',
36 | '%Y%m%d').date()
37 | data['creation_title'] = 'TITLE'
38 | data['submitter_creation_n'] = 'A123'
39 | data['recipient_creation_n'] = 'B124'
40 |
41 | record = self._decoder.decode(data)
42 |
43 | self.assertEqual('ACK', record.record_type)
44 | self.assertEqual(3, record.transaction_sequence_n)
45 | self.assertEqual(15, record.record_sequence_n)
46 | self.assertEqual(4, record.original_group_id)
47 | self.assertEqual(5, record.original_transaction_sequence_n)
48 | self.assertEqual('AGR', record.original_transaction_type)
49 | self.assertEqual('AS', record.transaction_status)
50 | self.assertEqual(
51 | datetime.datetime.strptime('20030215', '%Y%m%d').date(),
52 | record.creation_date_time)
53 | self.assertEqual(
54 | datetime.datetime.strptime('20030216', '%Y%m%d').date(),
55 | record.processing_date)
56 | self.assertEqual('TITLE', record.creation_title)
57 | self.assertEqual('A123', record.submitter_creation_n)
58 | self.assertEqual('B124', record.recipient_creation_n)
59 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_additional_related_information.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import \
6 | AdditionalRelatedInformationDictionaryDecoder
7 |
8 | """
9 | Dictionary to Message decoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestAdditionalRelatedInformationRecordDictionaryEncoding(
20 | unittest.TestCase):
21 | def setUp(self):
22 | self._decoder = AdditionalRelatedInformationDictionaryDecoder()
23 |
24 | def test_encoded(self):
25 | data = {}
26 |
27 | data['record_type'] = 'ARI'
28 | data['transaction_sequence_n'] = 3
29 | data['record_sequence_n'] = 15
30 | data['society_n'] = 1
31 | data['type_of_right'] = 'PER'
32 | data['work_n'] = 'WORK123'
33 | data['subject_code'] = 'SUB123'
34 | data['note'] = 'A NOTE'
35 |
36 | record = self._decoder.decode(data)
37 |
38 | self.assertEqual('ARI', record.record_type)
39 | self.assertEqual(3, record.transaction_sequence_n)
40 | self.assertEqual(15, record.record_sequence_n)
41 | self.assertEqual(1, record.society_n)
42 | self.assertEqual('PER', record.type_of_right)
43 | self.assertEqual('WORK123', record.work_n)
44 | self.assertEqual('SUB123', record.subject_code)
45 | self.assertEqual('A NOTE', record.note)
46 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_agreement_territory.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import AgreementTerritoryDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestAgreementTerritoryRecordDictionaryEncoding(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = AgreementTerritoryDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'TER'
26 | data['transaction_sequence_n'] = 3
27 | data['record_sequence_n'] = 15
28 | data['tis_numeric_code'] = 28
29 | data['inclusion_exclusion_indicator'] = 'I'
30 |
31 | record = self._decoder.decode(data)
32 |
33 | self.assertEqual('TER', record.record_type)
34 | self.assertEqual(3, record.transaction_sequence_n)
35 | self.assertEqual(15, record.record_sequence_n)
36 | self.assertEqual(28, record.tis_numeric_code)
37 | self.assertEqual('I', record.inclusion_exclusion_indicator)
38 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_alternate_title.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import AlternateTitleDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestAlternateTitleDictionaryDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = AlternateTitleDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'ALT'
26 | data['transaction_sequence_n'] = 3
27 | data['record_sequence_n'] = 15
28 | data['alternate_title'] = 'ALTERNATE TITLE'
29 | data['title_type'] = 'FT'
30 | data['language_code'] = 'ES'
31 |
32 | record = self._decoder.decode(data)
33 |
34 | self.assertEqual('ALT', record.record_type)
35 | self.assertEqual(3, record.transaction_sequence_n)
36 | self.assertEqual(15, record.record_sequence_n)
37 | self.assertEqual('ALTERNATE TITLE', record.alternate_title)
38 | self.assertEqual('FT', record.title_type)
39 | self.assertEqual('ES', record.language_code)
40 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_instrumentation_detail.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import InstrumentationDetailDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestInstrumentationDetailDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = InstrumentationDetailDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'IND'
26 | data['transaction_sequence_n'] = 3
27 | data['record_sequence_n'] = 15
28 | data['instrument_code'] = 'AHN'
29 | data['number_players'] = 2
30 |
31 | record = self._decoder.decode(data)
32 |
33 | self.assertEqual('IND', record.record_type)
34 | self.assertEqual(3, record.transaction_sequence_n)
35 | self.assertEqual(15, record.record_sequence_n)
36 | self.assertEqual('AHN', record.instrument_code)
37 | self.assertEqual(2, record.number_players)
38 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_instrumentation_summary.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import \
6 | InstrumentationSummaryDictionaryDecoder
7 |
8 | """
9 | Dictionary to Message decoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestInstrumentationSummaryDecoder(unittest.TestCase):
20 | def setUp(self):
21 | self._decoder = InstrumentationSummaryDictionaryDecoder()
22 |
23 | def test_encoded(self):
24 | data = {}
25 |
26 | data['record_type'] = 'SWR'
27 | data['transaction_sequence_n'] = 3
28 | data['record_sequence_n'] = 15
29 | data['number_voices'] = 2
30 | data['standard_instrumentation_type'] = 'BQU'
31 | data['instrumentation_description'] = 'DESCRIPTION'
32 |
33 | record = self._decoder.decode(data)
34 |
35 | self.assertEqual('SWR', record.record_type)
36 | self.assertEqual(3, record.transaction_sequence_n)
37 | self.assertEqual(15, record.record_sequence_n)
38 | self.assertEqual(2, record.number_voices)
39 | self.assertEqual('BQU', record.standard_instrumentation_type)
40 | self.assertEqual('DESCRIPTION', record.instrumentation_description)
41 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_interested_party_for_agreement.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import \
6 | InterestedPartyForAgreementDictionaryDecoder
7 |
8 | """
9 | Dictionary to Message decoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestInterestedPartyForAgreementDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._decoder = InterestedPartyForAgreementDictionaryDecoder()
22 |
23 | def test_encoded(self):
24 | data = {}
25 |
26 | data['record_type'] = 'IPA'
27 | data['transaction_sequence_n'] = 3
28 | data['record_sequence_n'] = 15
29 | data['ip_n'] = 'IP123'
30 | data['ip_last_name'] = 'LAST NAME'
31 | data['agreement_role_code'] = 'AS'
32 | data['ip_writer_first_name'] = 'FIRST NAME'
33 | data['ipi_name_n'] = 250165006
34 | data['ipi_base_n'] = 'I-000000229-7'
35 | data['pr_society'] = 1
36 | data['pr_share'] = 50.1
37 | data['mr_society'] = 2
38 | data['mr_share'] = 50.2
39 | data['sr_society'] = 3
40 | data['sr_share'] = 50.3
41 |
42 | record = self._decoder.decode(data)
43 |
44 | self.assertEqual('IPA', record.record_type)
45 | self.assertEqual(3, record.transaction_sequence_n)
46 | self.assertEqual(15, record.record_sequence_n)
47 | self.assertEqual('IP123', record.ip_n)
48 | self.assertEqual('LAST NAME', record.ip_last_name)
49 | self.assertEqual('AS', record.agreement_role_code)
50 | self.assertEqual('FIRST NAME', record.ip_writer_first_name)
51 | self.assertEqual(250165006, record.ipi_name_n)
52 | self.assertEqual(1, record.pr_society)
53 | self.assertEqual(50.1, record.pr_share)
54 | self.assertEqual(2, record.mr_society)
55 | self.assertEqual(50.2, record.mr_share)
56 | self.assertEqual(3, record.sr_society)
57 | self.assertEqual(50.3, record.sr_share)
58 |
59 | self.assertEqual('I-000000229-7', record.ipi_base_n)
60 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_ip_territory_of_control.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import IPTerritoryOfControlDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestIPTerritoryOfControlDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = IPTerritoryOfControlDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'SPT'
26 | data['transaction_sequence_n'] = 3
27 | data['record_sequence_n'] = 15
28 | data['ip_n'] = 'IP123'
29 | data['inclusion_exclusion_indicator'] = 'I'
30 | data['tis_numeric_code'] = 12
31 | data['sequence_n'] = 13
32 | data['pr_collection_share'] = 50.1
33 | data['mr_collection_share'] = 50.2
34 | data['sr_collection_share'] = 50.3
35 | data['shares_change'] = 'Y'
36 |
37 | record = self._decoder.decode(data)
38 |
39 | self.assertEqual('SPT', record.record_type)
40 | self.assertEqual(3, record.transaction_sequence_n)
41 | self.assertEqual(15, record.record_sequence_n)
42 | self.assertEqual('IP123', record.ip_n)
43 | self.assertEqual('I', record.inclusion_exclusion_indicator)
44 | self.assertEqual(12, record.tis_numeric_code)
45 | self.assertEqual(13, record.sequence_n)
46 | self.assertEqual(50.1, record.pr_collection_share)
47 | self.assertEqual(50.2, record.mr_collection_share)
48 | self.assertEqual(50.3, record.sr_collection_share)
49 | self.assertEqual('Y', record.shares_change)
50 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_message.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import MessageDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestMessageRecordDictionaryEncoding(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = MessageDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'MSG'
26 | data['transaction_sequence_n'] = 3
27 | data['record_sequence_n'] = 15
28 | data['message_level'] = 'F'
29 | data['validation_n'] = 'AB3'
30 | data['message_type'] = 'G'
31 | data['message_text'] = 'THE MESSAGE'
32 | data['original_record_sequence_n'] = 124
33 | data['message_record_type'] = 'AGR'
34 |
35 | record = self._decoder.decode(data)
36 |
37 | self.assertEqual('MSG', record.record_type)
38 | self.assertEqual(3, record.transaction_sequence_n)
39 | self.assertEqual(15, record.record_sequence_n)
40 | self.assertEqual('F', record.message_level)
41 | self.assertEqual('G', record.message_type)
42 | self.assertEqual('THE MESSAGE', record.message_text)
43 | self.assertEqual('AGR', record.message_record_type)
44 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_non_roman_alphabet_agreement_party.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import \
6 | NonRomanAlphabetAgreementPartyDictionaryDecoder
7 |
8 | """
9 | Dictionary to Message decoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestAgreementTerritoryRecordDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._decoder = NonRomanAlphabetAgreementPartyDictionaryDecoder()
22 |
23 | def test_encoded(self):
24 | data = {}
25 |
26 | data['record_type'] = 'NPA'
27 | data['transaction_sequence_n'] = 3
28 | data['record_sequence_n'] = 15
29 | data['ip_name'] = 'NAME'
30 | data['ip_writer_name'] = 'WRITER'
31 | data['ip_n'] = 'IP123'
32 | data['language_code'] = 'ES'
33 |
34 | record = self._decoder.decode(data)
35 |
36 | self.assertEqual('NPA', record.record_type)
37 | self.assertEqual(3, record.transaction_sequence_n)
38 | self.assertEqual(15, record.record_sequence_n)
39 | self.assertEqual('NAME', record.ip_name)
40 | self.assertEqual('WRITER', record.ip_writer_name)
41 | self.assertEqual('IP123', record.ip_n)
42 | self.assertEqual('ES', record.language_code)
43 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_non_roman_alphabet_other_writer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import \
6 | NonRomanAlphabetOtherWriterDictionaryDecoder
7 |
8 | """
9 | Dictionary to Message decoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestNonRomanAlphabetOtherWriterDictionaryDecoder(unittest.TestCase):
20 | def setUp(self):
21 | self._decoder = NonRomanAlphabetOtherWriterDictionaryDecoder()
22 |
23 | def test_encoded(self):
24 | data = {}
25 |
26 | data['record_type'] = 'NOW'
27 | data['transaction_sequence_n'] = 3
28 | data['record_sequence_n'] = 15
29 | data['writer_first_name'] = 'FIRST NAME'
30 | data['writer_name'] = 'NAME'
31 | data['position'] = 21
32 | data['language_code'] = 'ES'
33 |
34 | record = self._decoder.decode(data)
35 |
36 | self.assertEqual('NOW', record.record_type)
37 | self.assertEqual(3, record.transaction_sequence_n)
38 | self.assertEqual(15, record.record_sequence_n)
39 | self.assertEqual('FIRST NAME', record.writer_first_name)
40 | self.assertEqual('NAME', record.writer_name)
41 | self.assertEqual(21, record.position)
42 | self.assertEqual('ES', record.language_code)
43 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_non_roman_alphabet_performance_data.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import \
6 | NonRomanAlphabetPerformanceDataDictionaryDecoder
7 |
8 | """
9 | Dictionary to Message decoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestNonRomanAlphabetPerformanceDataDictionaryDecoder(unittest.TestCase):
20 | def setUp(self):
21 | self._decoder = NonRomanAlphabetPerformanceDataDictionaryDecoder()
22 |
23 | def test_encoded(self):
24 | data = {}
25 |
26 | data['record_type'] = 'NPR'
27 | data['transaction_sequence_n'] = 3
28 | data['record_sequence_n'] = 15
29 | data['performing_artist_first_name'] = 'FIRST NAME'
30 | data['performing_artist_name'] = 'NAME'
31 | data['performing_artist_ipi_name_n'] = 250165006
32 | data['performing_artist_ipi_base_n'] = 'I-000000229-7'
33 | data['language_code'] = 'ES'
34 | data['performance_language'] = 'EN'
35 | data['performance_dialect'] = 'EUS'
36 |
37 | record = self._decoder.decode(data)
38 |
39 | self.assertEqual('NPR', record.record_type)
40 | self.assertEqual(3, record.transaction_sequence_n)
41 | self.assertEqual(15, record.record_sequence_n)
42 | self.assertEqual('FIRST NAME', record.performing_artist_first_name)
43 | self.assertEqual('NAME', record.performing_artist_name)
44 | self.assertEqual(250165006, record.performing_artist_ipi_name_n)
45 | self.assertEqual('ES', record.language_code)
46 | self.assertEqual('EN', record.performance_language)
47 | self.assertEqual('EUS', record.performance_dialect)
48 |
49 | self.assertEqual('I-000000229-7', record.performing_artist_ipi_base_n)
50 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_non_roman_alphabet_publisher_name.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import \
6 | NonRomanAlphabetPublisherNameDictionaryDecoder
7 |
8 | """
9 | Dictionary to Message decoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestNonRomanAlphabetPublisherNameDictionaryDecoder(unittest.TestCase):
20 | def setUp(self):
21 | self._decoder = NonRomanAlphabetPublisherNameDictionaryDecoder()
22 |
23 | def test_encoded(self):
24 | data = {}
25 |
26 | data['record_type'] = 'NPN'
27 | data['transaction_sequence_n'] = 3
28 | data['record_sequence_n'] = 15
29 | data['publisher_sequence_n'] = 5
30 | data['ip_n'] = 'IP123'
31 | data['publisher_name'] = 'NAME'
32 | data['language_code'] = 'ES'
33 |
34 | record = self._decoder.decode(data)
35 |
36 | self.assertEqual('NPN', record.record_type)
37 | self.assertEqual(3, record.transaction_sequence_n)
38 | self.assertEqual(15, record.record_sequence_n)
39 | self.assertEqual(5, record.publisher_sequence_n)
40 | self.assertEqual('IP123', record.ip_n)
41 | self.assertEqual('NAME', record.publisher_name)
42 | self.assertEqual('ES', record.language_code)
43 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_non_roman_alphabet_title.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import NonRomanAlphabetTitleDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestNonRomanAlphabetTitleDictionaryDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = NonRomanAlphabetTitleDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'NAT'
26 | data['transaction_sequence_n'] = 3
27 | data['record_sequence_n'] = 15
28 | data['title'] = 'TITLE'
29 | data['title_type'] = 'OL'
30 | data['language_code'] = 'ES'
31 |
32 | record = self._decoder.decode(data)
33 |
34 | self.assertEqual('NAT', record.record_type)
35 | self.assertEqual(3, record.transaction_sequence_n)
36 | self.assertEqual(15, record.record_sequence_n)
37 | self.assertEqual('TITLE', record.title)
38 | self.assertEqual('OL', record.title_type)
39 | self.assertEqual('ES', record.language_code)
40 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_non_roman_alphabet_work.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import NonRomanAlphabetWorkDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestNonRomanAlphabetWorkDictionaryDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = NonRomanAlphabetWorkDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'NPR'
26 | data['transaction_sequence_n'] = 3
27 | data['record_sequence_n'] = 15
28 | data['title'] = 'TITLE'
29 | data['language_code'] = 'ES'
30 |
31 | record = self._decoder.decode(data)
32 |
33 | self.assertEqual('NPR', record.record_type)
34 | self.assertEqual(3, record.transaction_sequence_n)
35 | self.assertEqual(15, record.record_sequence_n)
36 | self.assertEqual('TITLE', record.title)
37 | self.assertEqual('ES', record.language_code)
38 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_non_roman_alphabet_writer_name.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import \
6 | NonRomanAlphabetWriterNameDictionaryDecoder
7 |
8 | """
9 | Dictionary to Message decoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestNonRomanAlphabetWriterNameDictionaryDecoder(unittest.TestCase):
20 | def setUp(self):
21 | self._decoder = NonRomanAlphabetWriterNameDictionaryDecoder()
22 |
23 | def test_encoded(self):
24 | data = {}
25 |
26 | data['record_type'] = 'NPN'
27 | data['transaction_sequence_n'] = 3
28 | data['record_sequence_n'] = 15
29 | data['writer_first_name'] = 'FIRST NAME'
30 | data['writer_last_name'] = 'LAST NAME'
31 | data['ip_n'] = 'IP123'
32 | data['language_code'] = 'ES'
33 |
34 | record = self._decoder.decode(data)
35 |
36 | self.assertEqual('NPN', record.record_type)
37 | self.assertEqual(3, record.transaction_sequence_n)
38 | self.assertEqual(15, record.record_sequence_n)
39 | self.assertEqual('FIRST NAME', record.writer_first_name)
40 | self.assertEqual('LAST NAME', record.writer_last_name)
41 | self.assertEqual('IP123', record.ip_n)
42 | self.assertEqual('ES', record.language_code)
43 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_performing_artist.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import PerformingArtistDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestPerformingArtistDictionaryDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = PerformingArtistDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'PER'
26 | data['transaction_sequence_n'] = 3
27 | data['record_sequence_n'] = 15
28 | data['performing_artist_last_name'] = 'LAST NAME'
29 | data['performing_artist_first_name'] = 'FIRST NAME'
30 | data['performing_artist_ipi_name_n'] = 250165006
31 | data['performing_artist_ipi_base_n'] = 'I-000000229-7'
32 |
33 | record = self._decoder.decode(data)
34 |
35 | self.assertEqual('PER', record.record_type)
36 | self.assertEqual(3, record.transaction_sequence_n)
37 | self.assertEqual(15, record.record_sequence_n)
38 | self.assertEqual('LAST NAME', record.performing_artist_last_name)
39 | self.assertEqual('FIRST NAME', record.performing_artist_first_name)
40 | self.assertEqual(250165006, record.performing_artist_ipi_name_n)
41 |
42 | self.assertEqual('I-000000229-7', record.performing_artist_ipi_base_n)
43 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_publisher_for_writer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import PublisherForWriterDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestPublisherForWriterDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = PublisherForWriterDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['record_type'] = 'SPU'
26 | data['transaction_sequence_n'] = 3
27 | data['record_sequence_n'] = 15
28 | data['publisher_ip_n'] = '111'
29 | data['writer_ip_n'] = '222'
30 | data['submitter_agreement_n'] = '333'
31 | data['society_assigned_agreement_n'] = '444'
32 |
33 | record = self._decoder.decode(data)
34 |
35 | self.assertEqual('SPU', record.record_type)
36 | self.assertEqual(3, record.transaction_sequence_n)
37 | self.assertEqual(15, record.record_sequence_n)
38 | self.assertEqual('111', record.publisher_ip_n)
39 | self.assertEqual('222', record.writer_ip_n)
40 | self.assertEqual('333', record.submitter_agreement_n)
41 | self.assertEqual('444', record.society_assigned_agreement_n)
42 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/record/test_work_origin.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import WorkOriginDictionaryDecoder
6 | from cwr.other import VISAN
7 |
8 | """
9 | Dictionary to Message decoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestWorkOriginDictionaryDecoder(unittest.TestCase):
20 | def setUp(self):
21 | self._decoder = WorkOriginDictionaryDecoder()
22 |
23 | def test_encoded(self):
24 | data = {}
25 |
26 | data['record_type'] = 'ORN'
27 | data['transaction_sequence_n'] = 3
28 | data['record_sequence_n'] = 15
29 | data['intended_purpose'] = 'PURPOSE'
30 | data['production_title'] = 'TITLE'
31 | data['cd_identifier'] = 'ID134'
32 | data['cut_number'] = 5
33 | data['library'] = 'LIB467'
34 | data['bltvr'] = 'BLTVR'
35 | data['visan'] = 1234567123456789121231
36 | data['production_n'] = 'PROD145'
37 | data['episode_title'] = 'EPISODE'
38 | data['episode_n'] = 'EP145'
39 | data['year_production'] = 1994
40 | data['audio_visual_key'] = 'KEY'
41 |
42 | record = self._decoder.decode(data)
43 |
44 | self.assertEqual('ORN', record.record_type)
45 | self.assertEqual(3, record.transaction_sequence_n)
46 | self.assertEqual(15, record.record_sequence_n)
47 | self.assertEqual('PURPOSE', record.intended_purpose)
48 | self.assertEqual('TITLE', record.production_title)
49 | self.assertEqual('ID134', record.cd_identifier)
50 | self.assertEqual(5, record.cut_number)
51 | self.assertEqual('LIB467', record.library)
52 | self.assertEqual('BLTVR', record.bltvr)
53 | self.assertEqual(1234567123456789121231, record.visan)
54 | self.assertEqual('PROD145', record.production_n)
55 | self.assertEqual('EPISODE', record.episode_title)
56 | self.assertEqual('EP145', record.episode_n)
57 | self.assertEqual(1994, record.year_production)
58 | self.assertEqual('KEY', record.audio_visual_key)
59 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/table_value/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/table_value/test_instrument_value.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import InstrumentValueDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestInstrumentValueDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = InstrumentValueDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['code'] = 'BBF'
26 | data['name'] = 'Bamboo Flute'
27 | data['family'] = 'National/Folk'
28 | data['description'] = 'same as Dizi or D\'Tzu'
29 |
30 | record = self._decoder.decode(data)
31 |
32 | self.assertEqual('BBF', record.code)
33 | self.assertEqual('Bamboo Flute', record.name)
34 | self.assertEqual('National/Folk', record.family)
35 | self.assertEqual('same as Dizi or D\'Tzu', record.description)
36 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/table_value/test_media_type_value.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import MediaTypeValueDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestMediaTypeValueDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = MediaTypeValueDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['code'] = 'EP'
26 | data['name'] = '45 rpm 17 cm EP'
27 | data['media_type'] = 'VINYL'
28 | data['duration_max'] = 16
29 | data['works_max'] = 4
30 | data['fragments_max'] = 12
31 |
32 | record = self._decoder.decode(data)
33 |
34 | self.assertEqual('EP', record.code)
35 | self.assertEqual('45 rpm 17 cm EP', record.name)
36 | self.assertEqual('VINYL', record.media_type)
37 | self.assertEqual(16, record.duration_max)
38 | self.assertEqual(4, record.works_max)
39 | self.assertEqual(12, record.fragments_max)
40 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/decoder/table_value/test_table_value.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.dictionary import TableValueDictionaryDecoder
6 |
7 | """
8 | Dictionary to Message decoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestTableValueDecoder(unittest.TestCase):
19 | def setUp(self):
20 | self._decoder = TableValueDictionaryDecoder()
21 |
22 | def test_encoded(self):
23 | data = {}
24 |
25 | data['code'] = 'AS'
26 | data['name'] = 'Assignor'
27 | data[
28 | 'description'] = 'The entitled party who is assigning the rights to a musical work within an agreement'
29 |
30 | record = self._decoder.decode(data)
31 |
32 | self.assertEqual('AS', record.code)
33 | self.assertEqual('Assignor', record.name)
34 | self.assertEqual(
35 | 'The entitled party who is assigning the rights to a musical work within an agreement',
36 | record.description)
37 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/control/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/control/test_group_header.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import GroupHeaderDictionaryEncoder
6 | from cwr.group import GroupHeader
7 |
8 | """
9 | Group Header to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestGroupHeaderDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = GroupHeaderDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = GroupHeader(record_type='GRH',
25 | group_id=3,
26 | transaction_type='AGR',
27 | version_number='02.10',
28 | batch_request_id=15)
29 |
30 | encoded = self._encoder.encode(data)
31 |
32 | self.assertEqual('GRH', encoded['record_type'])
33 | self.assertEqual(3, encoded['group_id'])
34 | self.assertEqual('AGR', encoded['transaction_type'])
35 | self.assertEqual('02.10', encoded['version_number'])
36 | self.assertEqual(15, encoded['batch_request_id'])
37 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/control/test_group_trailer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import GroupTrailerDictionaryEncoder
6 | from cwr.group import GroupTrailer
7 |
8 | """
9 | Group Trailer to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestGroupTrailerDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = GroupTrailerDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = GroupTrailer(record_type='GRT',
25 | group_id=3,
26 | transaction_count=15,
27 | record_count=20)
28 |
29 | encoded = self._encoder.encode(data)
30 |
31 | self.assertEqual('GRT', encoded['record_type'])
32 | self.assertEqual(3, encoded['group_id'])
33 | self.assertEqual(15, encoded['transaction_count'])
34 | self.assertEqual(20, encoded['record_count'])
35 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/control/test_transmission_header.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 | import datetime
5 |
6 | from cwr.parser.encoder.dictionary import TransmissionHeaderDictionaryEncoder
7 | from cwr.transmission import TransmissionHeader
8 |
9 | """
10 | TransmissionHeader to dictionary encoding tests.
11 |
12 | The following cases are tested:
13 | """
14 |
15 | __author__ = 'Bernardo Martínez Garrido'
16 | __license__ = 'MIT'
17 | __status__ = 'Development'
18 |
19 |
20 | class TestTransmissionHeaderDictionaryEncoding(unittest.TestCase):
21 | def setUp(self):
22 | self._encoder = TransmissionHeaderDictionaryEncoder()
23 |
24 | def test_encoded(self):
25 | data = TransmissionHeader(record_type='HDR',
26 | sender_id='ABC334',
27 | sender_name='SENDER',
28 | sender_type='SO',
29 | creation_date_time=datetime.datetime.strptime(
30 | '20030216', '%Y%m%d').date(),
31 | transmission_date=datetime.datetime.strptime(
32 | '20030217', '%Y%m%d').date(),
33 | edi_standard='01.10',
34 | character_set='ASCII')
35 |
36 | encoded = self._encoder.encode(data)
37 |
38 | self.assertEqual('HDR', encoded['record_type'])
39 | self.assertEqual('ABC334', encoded['sender_id'])
40 | self.assertEqual('SENDER', encoded['sender_name'])
41 | self.assertEqual('SO', encoded['sender_type'])
42 | self.assertEqual(
43 | datetime.datetime.strptime('20030216', '%Y%m%d').date(),
44 | encoded['creation_date_time'])
45 | self.assertEqual(
46 | datetime.datetime.strptime('20030217', '%Y%m%d').date(),
47 | encoded['transmission_date'])
48 | self.assertEqual('01.10', encoded['edi_standard'])
49 | self.assertEqual('ASCII', encoded['character_set'])
50 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/control/test_transmission_trailer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import TransmissionTrailerDictionaryEncoder
6 | from cwr.transmission import TransmissionTrailer
7 |
8 | """
9 | TransmissionTrailer to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestTransmissionTrailerDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = TransmissionTrailerDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = TransmissionTrailer(record_type='TRL',
25 | group_count=155,
26 | transaction_count=245,
27 | record_count=568)
28 |
29 | encoded = self._encoder.encode(data)
30 |
31 | self.assertEqual('TRL', encoded['record_type'])
32 | self.assertEqual(155, encoded['group_count'])
33 | self.assertEqual(245, encoded['transaction_count'])
34 | self.assertEqual(568, encoded['record_count'])
35 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/file/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/file/test_file_tag.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import FileTagDictionaryEncoder
6 | from cwr.file import FileTag
7 |
8 | """
9 | Group Header to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestFileTagDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = FileTagDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = FileTag(year=2015,
25 | sequence_n=123,
26 | sender='SND',
27 | receiver='RCV',
28 | version=2.1)
29 |
30 | encoded = self._encoder.encode(data)
31 |
32 | self.assertEqual(2015, encoded['year'])
33 | self.assertEqual(123, encoded['sequence_n'])
34 | self.assertEqual('SND', encoded['sender'])
35 | self.assertEqual('RCV', encoded['receiver'])
36 | self.assertEqual(2.1, encoded['version'])
37 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/interested_party/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/interested_party/test_publisher.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import PublisherDictionaryEncoder
6 | from cwr.interested_party import Publisher
7 |
8 | """
9 | Publisher to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestPublisherDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = PublisherDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = Publisher(ip_n='ABC15',
25 | publisher_name='NAME',
26 | ipi_name_n=14107338,
27 | ipi_base_n='I-000000229-7',
28 | tax_id=923703412)
29 |
30 | encoded = self._encoder.encode(data)
31 |
32 | self.assertEqual('ABC15', encoded['ip_n'])
33 | self.assertEqual('NAME', encoded['publisher_name'])
34 | self.assertEqual(14107338, encoded['ipi_name_n'])
35 | self.assertEqual(923703412, encoded['tax_id'])
36 |
37 | self.assertEqual('I-000000229-7', encoded['ipi_base_n'])
38 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/interested_party/test_writer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import WriterDictionaryEncoder
6 | from cwr.interested_party import Writer
7 |
8 | """
9 | Writer to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestWriterDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = WriterDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = Writer(ip_n='ABC15',
25 | personal_number='ABC1234',
26 | ipi_name_n=14107338,
27 | ipi_base_n='I-000000229-7',
28 | writer_first_name='NAME',
29 | writer_last_name='LAST NAME',
30 | tax_id=923703412)
31 |
32 | encoded = self._encoder.encode(data)
33 |
34 | self.assertEqual('ABC15', encoded['ip_n'])
35 | self.assertEqual('ABC1234', encoded['personal_number'])
36 | self.assertEqual(14107338, encoded['ipi_name_n'])
37 | self.assertEqual('NAME', encoded['writer_first_name'])
38 | self.assertEqual('LAST NAME', encoded['writer_last_name'])
39 | self.assertEqual(923703412, encoded['tax_id'])
40 |
41 | self.assertEqual('I-000000229-7', encoded['ipi_base_n'])
42 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/other/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/other/test_avi_key.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import AVIKeyDictionaryEncoder
6 | from cwr.other import AVIKey
7 |
8 | """
9 | Acknowledgement to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestAVIKeyEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = AVIKeyDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = AVIKey(1, 2)
25 |
26 | encoded = self._encoder.encode(data)
27 |
28 | self.assertEqual(1, encoded['society_code'])
29 | self.assertEqual(2, encoded['av_number'])
30 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/other/test_ipi_base.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import IPIBaseDictionaryEncoder
6 |
7 | """
8 | Acknowledgement to dictionary encoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestIPIBaseEncoding(unittest.TestCase):
19 | def setUp(self):
20 | self._encoder = IPIBaseDictionaryEncoder()
21 |
22 | def test_encoded(self):
23 | encoded = self._encoder.encode('T-123456789-1')
24 |
25 | self.assertEqual('T-123456789-1', encoded)
26 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/other/test_iswc.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import ISWCDictionaryEncoder
6 |
7 | """
8 | Acknowledgement to dictionary encoding tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestISWCodeEncoding(unittest.TestCase):
19 | def setUp(self):
20 | self._encoder = ISWCDictionaryEncoder()
21 |
22 | def test_encoded(self):
23 | encoded = self._encoder.encode('T0123456789')
24 |
25 | self.assertEqual('T0123456789', encoded)
26 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/other/test_visan.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import VISANDictionaryEncoder
6 | from cwr.other import VISAN
7 |
8 | """
9 | Acknowledgement to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestVISANEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = VISANDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | encoded = self._encoder.encode(1234)
25 |
26 | self.assertEqual(1234, encoded)
27 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_additional_related_info.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import \
6 | AdditionalRecordRelatedInfoDictionaryEncoder
7 | from cwr.info import AdditionalRelatedInfoRecord
8 |
9 | """
10 | Additional Related Info to dictionary encoding tests.
11 |
12 | The following cases are tested:
13 | """
14 |
15 | __author__ = 'Bernardo Martínez Garrido'
16 | __license__ = 'MIT'
17 | __status__ = 'Development'
18 |
19 |
20 | class TestAdditionalRelatedInfoRecordDictionaryEncoding(unittest.TestCase):
21 | def setUp(self):
22 | self._encoder = AdditionalRecordRelatedInfoDictionaryEncoder()
23 |
24 | def test_encoded(self):
25 | data = AdditionalRelatedInfoRecord(record_type='GRH',
26 | transaction_sequence_n=3,
27 | record_sequence_n=15,
28 | society_n=18,
29 | type_of_right='PER',
30 | work_n=12,
31 | subject_code='RQ',
32 | note='NOTE')
33 |
34 | encoded = self._encoder.encode(data)
35 |
36 | self.assertEqual('GRH', encoded['record_type'])
37 | self.assertEqual(3, encoded['transaction_sequence_n'])
38 | self.assertEqual(15, encoded['record_sequence_n'])
39 | self.assertEqual(18, encoded['society_n'])
40 | self.assertEqual('PER', encoded['type_of_right'])
41 | self.assertEqual(12, encoded['work_n'])
42 | self.assertEqual('RQ', encoded['subject_code'])
43 | self.assertEqual('NOTE', encoded['note'])
44 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_agreement_territory.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import AgreementTerritoryDictionaryEncoder
6 | from cwr.agreement import AgreementTerritoryRecord
7 |
8 | """
9 | AgreementRecord to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestAgreementTerritoryRecordDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = AgreementTerritoryDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = AgreementTerritoryRecord(record_type='TER',
25 | transaction_sequence_n=3,
26 | record_sequence_n=15,
27 | tis_numeric_code=51,
28 | inclusion_exclusion_indicator='I')
29 |
30 | encoded = self._encoder.encode(data)
31 |
32 | self.assertEqual('TER', encoded['record_type'])
33 | self.assertEqual(3, encoded['transaction_sequence_n'])
34 | self.assertEqual(15, encoded['record_sequence_n'])
35 | self.assertEqual(51, encoded['tis_numeric_code'])
36 | self.assertEqual('I', encoded['inclusion_exclusion_indicator'])
37 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_alternate_title.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import AlternateTitleDictionaryEncoder
6 | from cwr.work import AlternateTitleRecord
7 |
8 | """
9 | AlternateTitleRecord to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestAuthoredWorkRecordDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = AlternateTitleDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = AlternateTitleRecord(record_type='SWR',
25 | transaction_sequence_n=3,
26 | record_sequence_n=15,
27 | alternate_title='ALTERNATE',
28 | title_type='FT',
29 | language_code='ES')
30 |
31 | encoded = self._encoder.encode(data)
32 |
33 | self.assertEqual('SWR', encoded['record_type'])
34 | self.assertEqual(3, encoded['transaction_sequence_n'])
35 | self.assertEqual(15, encoded['record_sequence_n'])
36 | self.assertEqual('ALTERNATE', encoded['alternate_title'])
37 | self.assertEqual('FT', encoded['title_type'])
38 | self.assertEqual('ES', encoded['language_code'])
39 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_instrumentation_detail.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import InstrumentationDetailDictionaryEncoder
6 | from cwr.work import InstrumentationDetailRecord
7 |
8 | """
9 | InstrumentationDetailRecord to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestRecordingDetailRecordDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = InstrumentationDetailDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = InstrumentationDetailRecord(record_type='IND',
25 | transaction_sequence_n=3,
26 | record_sequence_n=15,
27 | instrument_code='AHN',
28 | number_players=2)
29 |
30 | encoded = self._encoder.encode(data)
31 |
32 | self.assertEqual('IND', encoded['record_type'])
33 | self.assertEqual(3, encoded['transaction_sequence_n'])
34 | self.assertEqual(15, encoded['record_sequence_n'])
35 | self.assertEqual('AHN', encoded['instrument_code'])
36 | self.assertEqual(2, encoded['number_players'])
37 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_instrumentation_summary.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import \
6 | InstrumentationSummaryDictionaryEncoder
7 | from cwr.work import InstrumentationSummaryRecord
8 |
9 | """
10 | InstrumentationSummaryRecord to dictionary encoding tests.
11 |
12 | The following cases are tested:
13 | """
14 |
15 | __author__ = 'Bernardo Martínez Garrido'
16 | __license__ = 'MIT'
17 | __status__ = 'Development'
18 |
19 |
20 | class TestRecordingDetailRecordDictionaryEncoding(unittest.TestCase):
21 | def setUp(self):
22 | self._encoder = InstrumentationSummaryDictionaryEncoder()
23 |
24 | def test_encoded(self):
25 | data = InstrumentationSummaryRecord(record_type='SWR',
26 | transaction_sequence_n=3,
27 | record_sequence_n=15,
28 | number_voices=2,
29 | standard_instrumentation_type='BQU',
30 | instrumentation_description='DESCRIPTION')
31 |
32 | encoded = self._encoder.encode(data)
33 |
34 | self.assertEqual('SWR', encoded['record_type'])
35 | self.assertEqual(3, encoded['transaction_sequence_n'])
36 | self.assertEqual(15, encoded['record_sequence_n'])
37 | self.assertEqual(2, encoded['number_voices'])
38 | self.assertEqual('BQU', encoded['standard_instrumentation_type'])
39 | self.assertEqual('DESCRIPTION', encoded['instrumentation_description'])
40 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_ip_territory_control.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import IPTerritoryOfControlDictionaryEncoder
6 | from cwr.interested_party import IPTerritoryOfControlRecord
7 |
8 | """
9 | Publisher or Writer Territory of Control to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestIPTerritoryOfControlRecordDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = IPTerritoryOfControlDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = IPTerritoryOfControlRecord(record_type='MSG',
25 | transaction_sequence_n=3,
26 | record_sequence_n=15,
27 | ip_n='FG14',
28 | inclusion_exclusion_indicator='I',
29 | tis_numeric_code=76,
30 | sequence_n=135,
31 | pr_collection_share=50.5,
32 | mr_collection_share=60.5,
33 | sr_collection_share=70.5,
34 | shares_change=True)
35 |
36 | encoded = self._encoder.encode(data)
37 |
38 | self.assertEqual('MSG', encoded['record_type'])
39 | self.assertEqual(3, encoded['transaction_sequence_n'])
40 | self.assertEqual(15, encoded['record_sequence_n'])
41 | self.assertEqual('FG14', encoded['ip_n'])
42 | self.assertEqual('I', encoded['inclusion_exclusion_indicator'])
43 | self.assertEqual(76, encoded['tis_numeric_code'])
44 | self.assertEqual(135, encoded['sequence_n'])
45 | self.assertEqual(50.5, encoded['pr_collection_share'])
46 | self.assertEqual(60.5, encoded['mr_collection_share'])
47 | self.assertEqual(70.5, encoded['sr_collection_share'])
48 | self.assertEqual(True, encoded['shares_change'])
49 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_message.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import MessageDictionaryEncoder
6 | from cwr.acknowledgement import MessageRecord
7 |
8 | """
9 | Message to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestMessageRecordDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = MessageDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = MessageRecord(record_type='MSG',
25 | transaction_sequence_n=3,
26 | record_sequence_n=15,
27 | message_level='F',
28 | validation_n='AB3',
29 | message_type='G',
30 | message_text='THE MESSAGE',
31 | original_record_sequence_n=124,
32 | message_record_type='AGR')
33 |
34 | encoded = self._encoder.encode(data)
35 |
36 | self.assertEqual('MSG', encoded['record_type'])
37 | self.assertEqual(3, encoded['transaction_sequence_n'])
38 | self.assertEqual(15, encoded['record_sequence_n'])
39 | self.assertEqual('F', encoded['message_level'])
40 | self.assertEqual('AB3', encoded['validation_n'])
41 | self.assertEqual('G', encoded['message_type'])
42 | self.assertEqual('THE MESSAGE', encoded['message_text'])
43 | self.assertEqual(124, encoded['original_record_sequence_n'])
44 | self.assertEqual('AGR', encoded['message_record_type'])
45 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_nat.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import NonRomanAlphabetTitleDictionaryEncoder
6 | from cwr.non_roman_alphabet import NonRomanAlphabetTitleRecord
7 |
8 | """
9 | NATRecord to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestNATRecordDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = NonRomanAlphabetTitleDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = NonRomanAlphabetTitleRecord(record_type='NAT',
25 | transaction_sequence_n=3,
26 | record_sequence_n=15,
27 | title='THE TITLE',
28 | title_type='FT',
29 | language_code='ES')
30 |
31 | encoded = self._encoder.encode(data)
32 |
33 | self.assertEqual('NAT', encoded['record_type'])
34 | self.assertEqual(3, encoded['transaction_sequence_n'])
35 | self.assertEqual(15, encoded['record_sequence_n'])
36 | self.assertEqual('THE TITLE', encoded['title'])
37 | self.assertEqual('FT', encoded['title_type'])
38 | self.assertEqual('ES', encoded['language_code'])
39 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_now.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import \
6 | NonRomanAlphabetOtherWriterDictionaryEncoder
7 | from cwr.non_roman_alphabet import NonRomanAlphabetOtherWriterRecord
8 |
9 | """
10 | NOWRecord to dictionary encoding tests.
11 |
12 | The following cases are tested:
13 | """
14 |
15 | __author__ = 'Bernardo Martínez Garrido'
16 | __license__ = 'MIT'
17 | __status__ = 'Development'
18 |
19 |
20 | class TestNOWRecordDictionaryEncoding(unittest.TestCase):
21 | def setUp(self):
22 | self._encoder = NonRomanAlphabetOtherWriterDictionaryEncoder()
23 |
24 | def test_encoded(self):
25 | data = NonRomanAlphabetOtherWriterRecord(record_type='NOW',
26 | transaction_sequence_n=3,
27 | record_sequence_n=15,
28 | writer_first_name='FIRST NAME',
29 | writer_name='NAME',
30 | position=5,
31 | language_code='ES')
32 |
33 | encoded = self._encoder.encode(data)
34 |
35 | self.assertEqual('NOW', encoded['record_type'])
36 | self.assertEqual(3, encoded['transaction_sequence_n'])
37 | self.assertEqual(15, encoded['record_sequence_n'])
38 | self.assertEqual('FIRST NAME', encoded['writer_first_name'])
39 | self.assertEqual('NAME', encoded['writer_name'])
40 | self.assertEqual(5, encoded['position'])
41 | self.assertEqual('ES', encoded['language_code'])
42 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_npa.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import \
6 | NonRomanAlphabetAgreementPartyDictionaryEncoder
7 | from cwr.non_roman_alphabet import NonRomanAlphabetAgreementPartyRecord
8 |
9 | """
10 | NOWRecord to dictionary encoding tests.
11 |
12 | The following cases are tested:
13 | """
14 |
15 | __author__ = 'Bernardo Martínez Garrido'
16 | __license__ = 'MIT'
17 | __status__ = 'Development'
18 |
19 |
20 | class TestNPARecordDictionaryEncoding(unittest.TestCase):
21 | def setUp(self):
22 | self._encoder = NonRomanAlphabetAgreementPartyDictionaryEncoder()
23 |
24 | def test_encoded(self):
25 | data = NonRomanAlphabetAgreementPartyRecord(record_type='NPA',
26 | transaction_sequence_n=3,
27 | record_sequence_n=15,
28 | ip_name='NAME',
29 | ip_writer_name='WRITER NAME',
30 | ip_n='ABC123',
31 | language_code='ES')
32 |
33 | encoded = self._encoder.encode(data)
34 |
35 | self.assertEqual('NPA', encoded['record_type'])
36 | self.assertEqual(3, encoded['transaction_sequence_n'])
37 | self.assertEqual(15, encoded['record_sequence_n'])
38 | self.assertEqual('NAME', encoded['ip_name'])
39 | self.assertEqual('WRITER NAME', encoded['ip_writer_name'])
40 | self.assertEqual('ABC123', encoded['ip_n'])
41 | self.assertEqual('ES', encoded['language_code'])
42 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_npn.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import \
6 | NonRomanAlphabetPublisherNameDictionaryEncoder
7 | from cwr.non_roman_alphabet import NonRomanAlphabetPublisherNameRecord
8 |
9 | """
10 | NPNRecord to dictionary encoding tests.
11 |
12 | The following cases are tested:
13 | """
14 |
15 | __author__ = 'Bernardo Martínez Garrido'
16 | __license__ = 'MIT'
17 | __status__ = 'Development'
18 |
19 |
20 | class TestNPNRecordDictionaryEncoding(unittest.TestCase):
21 | def setUp(self):
22 | self._encoder = NonRomanAlphabetPublisherNameDictionaryEncoder()
23 |
24 | def test_encoded(self):
25 | data = NonRomanAlphabetPublisherNameRecord(record_type='NPN',
26 | transaction_sequence_n=3,
27 | record_sequence_n=15,
28 | publisher_sequence_n=17,
29 | ip_n='ABC123',
30 | publisher_name='NAME',
31 | language_code='ES')
32 |
33 | encoded = self._encoder.encode(data)
34 |
35 | self.assertEqual('NPN', encoded['record_type'])
36 | self.assertEqual(3, encoded['transaction_sequence_n'])
37 | self.assertEqual(15, encoded['record_sequence_n'])
38 | self.assertEqual(17, encoded['publisher_sequence_n'])
39 | self.assertEqual('ABC123', encoded['ip_n'])
40 | self.assertEqual('NAME', encoded['publisher_name'])
41 | self.assertEqual('ES', encoded['language_code'])
42 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_npr.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import \
6 | NonRomanAlphabetPerformanceDataDictionaryEncoder
7 | from cwr.non_roman_alphabet import NonRomanAlphabetPerformanceDataRecord
8 |
9 | """
10 | NPRRecord to dictionary encoding tests.
11 |
12 | The following cases are tested:
13 | """
14 |
15 | __author__ = 'Bernardo Martínez Garrido'
16 | __license__ = 'MIT'
17 | __status__ = 'Development'
18 |
19 |
20 | class TestNPRRecordDictionaryEncoding(unittest.TestCase):
21 | def setUp(self):
22 | self._encoder = NonRomanAlphabetPerformanceDataDictionaryEncoder()
23 |
24 | def test_encoded(self):
25 | data = NonRomanAlphabetPerformanceDataRecord(record_type='NPA',
26 | transaction_sequence_n=3,
27 | record_sequence_n=15,
28 | performing_artist_first_name='FIRST NAME',
29 | performing_artist_name='NAME',
30 | performing_artist_ipi_name_n=14107338,
31 | performing_artist_ipi_base_n='I-000000229-7',
32 | language_code='ES',
33 | performance_language='EN',
34 | performance_dialect='SC')
35 |
36 | encoded = self._encoder.encode(data)
37 |
38 | self.assertEqual('NPA', encoded['record_type'])
39 | self.assertEqual(3, encoded['transaction_sequence_n'])
40 | self.assertEqual(15, encoded['record_sequence_n'])
41 | self.assertEqual('FIRST NAME', encoded['performing_artist_first_name'])
42 | self.assertEqual('NAME', encoded['performing_artist_name'])
43 | self.assertEqual(14107338, encoded['performing_artist_ipi_name_n'])
44 | self.assertEqual('ES', encoded['language_code'])
45 | self.assertEqual('EN', encoded['performance_language'])
46 | self.assertEqual('SC', encoded['performance_dialect'])
47 |
48 | self.assertEqual('I-000000229-7',
49 | encoded['performing_artist_ipi_base_n'])
50 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_nra_work.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import NonRomanAlphabetWorkDictionaryEncoder
6 | from cwr.non_roman_alphabet import NonRomanAlphabetWorkRecord
7 |
8 | """
9 | NRAWorkRecord to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestNRAWorkRecordDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = NonRomanAlphabetWorkDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = NonRomanAlphabetWorkRecord(record_type='NET',
25 | transaction_sequence_n=3,
26 | record_sequence_n=15,
27 | title='THE TITLE',
28 | language_code='ES')
29 |
30 | encoded = self._encoder.encode(data)
31 |
32 | self.assertEqual('NET', encoded['record_type'])
33 | self.assertEqual(3, encoded['transaction_sequence_n'])
34 | self.assertEqual(15, encoded['record_sequence_n'])
35 | self.assertEqual('THE TITLE', encoded['title'])
36 | self.assertEqual('ES', encoded['language_code'])
37 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_nwn.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import \
6 | NonRomanAlphabetWriterNameDictionaryEncoder
7 | from cwr.non_roman_alphabet import NonRomanAlphabetWriterNameRecord
8 |
9 | """
10 | NWNRecord to dictionary encoding tests.
11 |
12 | The following cases are tested:
13 | """
14 |
15 | __author__ = 'Bernardo Martínez Garrido'
16 | __license__ = 'MIT'
17 | __status__ = 'Development'
18 |
19 |
20 | class TestNPRRecordDictionaryEncoding(unittest.TestCase):
21 | def setUp(self):
22 | self._encoder = NonRomanAlphabetWriterNameDictionaryEncoder()
23 |
24 | def test_encoded(self):
25 | data = NonRomanAlphabetWriterNameRecord(record_type='NWN',
26 | transaction_sequence_n=3,
27 | record_sequence_n=15,
28 | writer_first_name='FIRST NAME',
29 | writer_last_name='LAST NAME',
30 | ip_n='ABC123',
31 | language_code='ES')
32 |
33 | encoded = self._encoder.encode(data)
34 |
35 | self.assertEqual('NWN', encoded['record_type'])
36 | self.assertEqual(3, encoded['transaction_sequence_n'])
37 | self.assertEqual(15, encoded['record_sequence_n'])
38 | self.assertEqual('FIRST NAME', encoded['writer_first_name'])
39 | self.assertEqual('LAST NAME', encoded['writer_last_name'])
40 | self.assertEqual('ABC123', encoded['ip_n'])
41 | self.assertEqual('ES', encoded['language_code'])
42 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_performing_artist.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import PerformingArtistDictionaryEncoder
6 | from cwr.work import PerformingArtistRecord
7 |
8 | """
9 | PerformingArtistRecord to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestPerformingArtistRecordRecordDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = PerformingArtistDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = PerformingArtistRecord(record_type='PER',
25 | transaction_sequence_n=3,
26 | record_sequence_n=15,
27 | performing_artist_last_name='LAST NAME',
28 | performing_artist_first_name='FIRST NAME',
29 | performing_artist_ipi_name_n=14107338,
30 | performing_artist_ipi_base_n='I-000000229-7')
31 |
32 | encoded = self._encoder.encode(data)
33 |
34 | self.assertEqual('PER', encoded['record_type'])
35 | self.assertEqual(3, encoded['transaction_sequence_n'])
36 | self.assertEqual(15, encoded['record_sequence_n'])
37 | self.assertEqual('LAST NAME', encoded['performing_artist_last_name'])
38 | self.assertEqual('FIRST NAME', encoded['performing_artist_first_name'])
39 | self.assertEqual(14107338, encoded['performing_artist_ipi_name_n'])
40 |
41 | self.assertEqual('I-000000229-7',
42 | encoded['performing_artist_ipi_base_n'])
43 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/record/test_publisher_for_writer.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import PublisherForWriterDictionaryEncoder
6 | from cwr.interested_party import PublisherForWriterRecord
7 |
8 | """
9 | Publisher for Writer record to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestPublisherForWriterRecordDictionaryEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = PublisherForWriterDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = PublisherForWriterRecord(record_type='SPU',
25 | transaction_sequence_n=3,
26 | record_sequence_n=15,
27 | publisher_ip_n='111',
28 | writer_ip_n='222',
29 | submitter_agreement_n='333',
30 | society_assigned_agreement_n='444')
31 |
32 | encoded = self._encoder.encode(data)
33 |
34 | self.assertEqual('SPU', encoded['record_type'])
35 | self.assertEqual(3, encoded['transaction_sequence_n'])
36 | self.assertEqual(15, encoded['record_sequence_n'])
37 | self.assertEqual('111', encoded['publisher_ip_n'])
38 | self.assertEqual('222', encoded['writer_ip_n'])
39 | self.assertEqual('333', encoded['submitter_agreement_n'])
40 | self.assertEqual('444', encoded['society_assigned_agreement_n'])
41 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/table_value/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/table_value/test_instrument_value.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import InstrumentValueDictionaryEncoder
6 | from cwr.table_value import InstrumentValue
7 |
8 | """
9 | Acknowledgement to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestInstrumentValueEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = InstrumentValueDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = InstrumentValue('BBF', 'Bamboo Flute', 'National/Folk',
25 | 'same as Dizi or D\'Tzu')
26 |
27 | encoded = self._encoder.encode(data)
28 |
29 | self.assertEqual('BBF', encoded['code'])
30 | self.assertEqual('Bamboo Flute', encoded['name'])
31 | self.assertEqual('National/Folk', encoded['family'])
32 | self.assertEqual('same as Dizi or D\'Tzu', encoded['description'])
33 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/table_value/test_media_type_value.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import MediaTypeDictionaryEncoder
6 | from cwr.table_value import MediaTypeValue
7 |
8 | """
9 | Acknowledgement to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestMediaTypeValueEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = MediaTypeDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = MediaTypeValue('EP', '45 rpm 17 cm EP', 'VINYL', 16, 4, 12)
25 |
26 | encoded = self._encoder.encode(data)
27 |
28 | self.assertEqual('EP', encoded['code'])
29 | self.assertEqual('45 rpm 17 cm EP', encoded['name'])
30 | self.assertEqual('VINYL', encoded['media_type'])
31 | self.assertEqual(16, encoded['duration_max'])
32 | self.assertEqual(4, encoded['works_max'])
33 | self.assertEqual(12, encoded['fragments_max'])
34 |
--------------------------------------------------------------------------------
/tests/parser/dictionary/encoder/table_value/test_table_value.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.encoder.dictionary import TableValueDictionaryEncoder
6 | from cwr.table_value import TableValue
7 |
8 | """
9 | Acknowledgement to dictionary encoding tests.
10 |
11 | The following cases are tested:
12 | """
13 |
14 | __author__ = 'Bernardo Martínez Garrido'
15 | __license__ = 'MIT'
16 | __status__ = 'Development'
17 |
18 |
19 | class TestTableValueEncoding(unittest.TestCase):
20 | def setUp(self):
21 | self._encoder = TableValueDictionaryEncoder()
22 |
23 | def test_encoded(self):
24 | data = TableValue('AS', 'Assignor',
25 | 'The entitled party who is assigning the rights to a musical work within an agreement')
26 |
27 | encoded = self._encoder.encode(data)
28 |
29 | self.assertEqual('AS', encoded['code'])
30 | self.assertEqual('Assignor', encoded['name'])
31 | self.assertEqual(
32 | 'The entitled party who is assigning the rights to a musical work within an agreement',
33 | encoded['description'])
34 |
--------------------------------------------------------------------------------
/tests/parser/file/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/file/decoder/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/file/decoder/test_filename.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import unittest
4 |
5 | from cwr.parser.decoder.file import default_filename_decoder
6 |
7 | """
8 | CWR file name encoder tests.
9 |
10 | The following cases are tested:
11 | """
12 |
13 | __author__ = 'Bernardo Martínez Garrido'
14 | __license__ = 'MIT'
15 | __status__ = 'Development'
16 |
17 |
18 | class TestFileNameCWRDecodeValid(unittest.TestCase):
19 | def setUp(self):
20 | self._parser = default_filename_decoder()
21 |
22 | def test_old(self):
23 | result = self._parser.decode('CW122311_22.V21')
24 |
25 | self.assertEqual(2012, result.year)
26 | self.assertEqual(23, result.sequence_n)
27 | self.assertEqual('11', result.sender)
28 | self.assertEqual('22', result.receiver)
29 | self.assertEqual(2.1, result.version)
30 |
31 | def test_new(self):
32 | result = self._parser.decode('CW12012311_22.V21')
33 |
34 | self.assertEqual(2012, result.year)
35 | self.assertEqual(123, result.sequence_n)
36 | self.assertEqual('11', result.sender)
37 | self.assertEqual('22', result.receiver)
38 | self.assertEqual(2.1, result.version)
39 |
40 |
41 | class TestFileNameCWRDecodeInvalid(unittest.TestCase):
42 | def setUp(self):
43 | self._parser = default_filename_decoder()
44 |
45 | def test_invalid(self):
46 | result = self._parser.decode('CW130001059_201_.txt')
47 |
48 | self.assertEqual(0, result.year)
49 | self.assertEqual(0, result.sequence_n)
50 | self.assertEqual('', result.sender)
51 | self.assertEqual('', result.receiver)
52 | self.assertEqual('', result.version)
53 |
--------------------------------------------------------------------------------
/tests/parser/file/encoder/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/parser/file/encoder/test_file.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import codecs
3 | import os
4 |
5 | import unittest
6 | import datetime
7 | import json
8 | import sys
9 | from cwr.parser.decoder.file import default_file_decoder
10 |
11 | from cwr.parser.encoder.file import CwrFileEncoder, default_file_encoder
12 | from cwr.file import FileTag, CWRFile
13 | from cwr.group import GroupHeader, GroupTrailer, Group
14 | from cwr.work import WorkRecord
15 | from cwr.agreement import AgreementRecord
16 | from cwr.transmission import TransmissionTrailer, TransmissionHeader, \
17 | Transmission
18 |
19 | """
20 | Group from cwr encoding tests.
21 |
22 | The following cases are tested:
23 | """
24 |
25 | __author__ = 'Yaroslav O. Holub'
26 | __license__ = 'MIT'
27 | __status__ = 'Development'
28 |
29 |
30 | class TestCwrEncoding(unittest.TestCase):
31 | def setUp(self):
32 | self._encoder = default_file_encoder()
33 | self._decoder = default_file_decoder()
34 |
35 | def get_data(self):
36 | current_dir = os.path.dirname(__file__)
37 | example_path = os.path.join(current_dir, '..', '..', '..', 'examples', 'ackexample.V21')
38 | data = {}
39 | data['filename'] = os.path.basename(example_path)
40 | data['contents'] = codecs.open(example_path, 'r', 'latin-1').read()
41 | return data
42 |
43 | def test_file_encoding(self):
44 | decoder = default_file_decoder()
45 | data = self.get_data()
46 |
47 | original_lines = data['contents'].splitlines()
48 | for i in range(len(original_lines)):
49 | print(original_lines[i])
50 |
51 | entities = decoder.decode(data)
52 | file_encoder = default_file_encoder()
53 | result = file_encoder.encode(entities.transmission)
54 | original_lines = data['contents'].split("\n")
55 | encoded_lines = result.split("\n")
56 |
57 | self.assertEqual(len(original_lines), len(encoded_lines))
58 | for i in range(1, len(original_lines)):
59 | self.assertEquals(original_lines[i].strip(), encoded_lines[i].strip())
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/tests/utils/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/utils/grammar.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | from cwr.parser.decoder.file import default_grammar_factory, \
4 | default_filename_grammar_factory
5 |
6 | """
7 | Grammar utilities for the test classes.
8 | """
9 |
10 | __author__ = 'Bernardo Martínez Garrido'
11 | __license__ = 'MIT'
12 | __status__ = 'Development'
13 |
14 | _group_rule_factory = default_grammar_factory()
15 |
16 | _group_rule_factory_filename = default_filename_grammar_factory()
17 |
18 |
19 | def get_record_grammar(rule_id):
20 | return _group_rule_factory.get_rule(rule_id)
21 |
22 |
23 | def get_filename_grammar(rule_id):
24 | return _group_rule_factory_filename.get_rule(rule_id)
25 |
--------------------------------------------------------------------------------
/tests/visual/__init__.py:
--------------------------------------------------------------------------------
1 | __author__ = 'Bernardo'
2 |
--------------------------------------------------------------------------------
/tests/visual/file_contents.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import codecs
3 | import time
4 | import logging
5 | import os
6 |
7 | from cwr.parser.decoder.file import default_file_decoder
8 | from cwr.utils.printer import CWRPrinter
9 |
10 | """
11 | Visual test for checking a file contents.
12 |
13 | This is used to make sure a file contents are correctly printed with a visual or manual check.
14 |
15 | All the file contents will be printed on the console.
16 | """
17 |
18 | __author__ = 'Bernardo Martínez Garrido'
19 | __license__ = 'MIT'
20 | __status__ = 'Development'
21 |
22 | if __name__ == '__main__':
23 | print('File contents parsing test')
24 | path = input(
25 | 'Please enter the full path to a CWR file (e.g. c:/documents/file.cwr): ')
26 | output = input(
27 | 'Please enter the full path to the file where the results will be stored: ')
28 | log = input(
29 | 'Please enter the full path to the file where parsing log will be saved: ')
30 | print('\n')
31 | print('Reading file %s' % path)
32 | print('Storing output on %s' % output)
33 | print('Saving log on %s' % log)
34 | print('\n')
35 |
36 | logging.basicConfig(filename=log,
37 | level=logging.DEBUG,
38 | format='%(asctime)s.%(msecs)d %(levelname)s %(module)s - %(funcName)s: %(message)s')
39 | logger = logging.getLogger(__name__)
40 |
41 | decoder = default_file_decoder()
42 |
43 | data = {}
44 | data['filename'] = os.path.basename(path)
45 | data['contents'] = codecs.open(path, 'r', 'latin-1').read()
46 |
47 | start = time.clock()
48 | data = decoder.decode(data)
49 | end = time.clock()
50 | time_parse = (end - start)
51 |
52 | print('Parsed the file in %s seconds' % time_parse)
53 | print('\n')
54 |
55 | logger.info('Finished parsing n %s seconds' % time_parse)
56 |
57 | output = codecs.open(output, 'w', 'latin-1')
58 |
59 | printer = CWRPrinter()
60 | printer.print_file(data, output)
61 |
--------------------------------------------------------------------------------
/tests/visual/file_json.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import codecs
3 | import os
4 | import time
5 |
6 | from cwr.parser.decoder.file import default_file_decoder
7 | from cwr.parser.encoder.cwrjson import JSONEncoder
8 |
9 | """
10 | Visual test for transforming file into a JSON.
11 |
12 | This is used to generate a JSON for other tests.
13 |
14 | The full JSON will be stored into a file.
15 | """
16 |
17 | __author__ = 'Bernardo Martínez Garrido'
18 | __license__ = 'MIT'
19 | __status__ = 'Development'
20 |
21 | if __name__ == '__main__':
22 | print('File to JSON test')
23 | path = input(
24 | 'Please enter the full path to a CWR file (e.g. c:/documents/file.cwr): ')
25 | output = input(
26 | 'Please enter the full path to the file where the results will be stored: ')
27 | print('\n')
28 | print('Reading file %s' % path)
29 | print('Storing output on %s' % output)
30 | print('\n')
31 |
32 | decoder = default_file_decoder()
33 |
34 | data = {}
35 | data['filename'] = os.path.basename(path)
36 | data['contents'] = codecs.open(path, 'r', 'latin-1').read()
37 |
38 | print('Begins parsing CWR at %s' % time.ctime())
39 | start = time.clock()
40 | data = decoder.decode(data)
41 | end = time.clock()
42 | time_parse = (end - start)
43 |
44 | print('Parsed the file in %s seconds' % time_parse)
45 | print('\n')
46 |
47 | encoder = JSONEncoder()
48 |
49 | print('Begins creating JSON at %s' % time.ctime())
50 | start = time.clock()
51 | result = encoder.encode(data)
52 | end = time.clock()
53 | time_parse = (end - start)
54 |
55 | print('Created the JSON in %s seconds' % time_parse)
56 | print('\n')
57 |
58 | start = time.clock()
59 | output = codecs.open(output, 'w', 'latin-1')
60 | end = time.clock()
61 | time_parse = (end - start)
62 |
63 | print('Saved the JSON in %s seconds' % time_parse)
64 |
65 | output.write(result)
66 |
--------------------------------------------------------------------------------
/tox.ini:
--------------------------------------------------------------------------------
1 | [tox]
2 | envlist =
3 | py{34,35,36},
4 | pypy{,3},
5 | check,
6 | docs,
7 | coverage
8 | skip_missing_interpreters =
9 | true
10 |
11 | [testenv]
12 | # Default environment
13 | deps =
14 | -r{toxinidir}/requirements.txt
15 | nose
16 | commands =
17 | nosetests
18 |
19 | [testenv:coverage]
20 | # Generates coverage report
21 | passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
22 | deps =
23 | -r{toxinidir}/requirements.txt
24 | nose
25 | coverage
26 | coveralls
27 | commands =
28 | nosetests --with-coverage --cover-package=cwr
29 | coveralls
30 |
31 | [testenv:check]
32 | # Checks code rules
33 | deps =
34 | -r{toxinidir}/requirements.txt
35 | docutils
36 | check-manifest
37 | flake8
38 | readme
39 | commands =
40 | python setup.py check --strict --metadata --restructuredtext
41 | check-manifest {toxinidir}
42 | #flake8 cwr
43 | #flake8 data_cwr
44 | #flake8 config_cwr
45 |
46 | [testenv:docs]
47 | # Validates the project docs
48 | changedir =
49 | docs/source
50 | deps =
51 | -r{toxinidir}/requirements.txt
52 | sphinx
53 | commands =
54 | sphinx-build -b linkcheck ./ {envtmpdir}/html
55 | sphinx-build -nW -b html -d {envtmpdir}/doctrees ./ {envtmpdir}/html
--------------------------------------------------------------------------------