예제 #1
0
    def create_document(self):
        # Create the document
        my_document = Document(self)

        my_document.check_for_quotas()

        # Create the measures table
        my_document.get_duties("preferences")
        tariff_data = my_document.print_tariffs()

        # Create the quotas table
        my_document.get_duties("quotas")
        my_document.get_quota_order_numbers()
        my_document.get_quota_balances()
        my_document.get_quota_measures()
        my_document.get_quota_definitions()
        quota_data = my_document.print_quotas()

        context_data = {
            'AGREEMENT_NAME': self.agreement.agreement_name,
            'VERSION': self.agreement.version,
            'AGREEMENT_DATE': self.agreement.agreement_date_long,
            'AGREEMENT_DATE_SHORT': self.agreement.agreement_date_short,
            'COUNTRY_NAME': self.agreement.country_name,
            **tariff_data,
            **quota_data,
        }

        # Personalise and write the document
        my_document.create_document(context_data)
        update_document_status(self.agreement, DocumentStatus.AVAILABLE)
def test_print_tariffs(suppress, expected_result):
    application = mock.MagicMock(country_name='spain')
    document = Document(application)
    if suppress is None:
        document.commodity_list = []
    else:
        commodity = QuotaCommodity('124567890', None)
        commodity.suppress = suppress
        commodity.duty_string = 'Test duty string<w:r><w:br/></w:r>'
        document.commodity_list = [commodity]
    actual_result = document.print_tariffs()
    assert actual_result == expected_result