Example #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_get_quota_balances(
    mock_first_come_first_serve,
    mock_licensed,
    has_quotas,
    called_add_first_come_first_serve,
    called_add_licensed,
):
    mock_first_come_first_serve.return_value = None
    mock_licensed.return_value = None
    application = mock.MagicMock(country_name='spain')
    document = Document(application)
    document.has_quotas = has_quotas
    document.get_quota_balances()
    assert mock_licensed.called is called_add_licensed
    assert mock_first_come_first_serve.called is called_add_first_come_first_serve