Example #1
0
    def test_delete_company_export_country_no_signal(self):
        """
        Test that attempting to delete an nonexisting CompanyExportCountry
        record won't send a signal and won't track history
        """
        company = CompanyFactory()
        countries = CountryModel.objects.order_by('name')[:2]
        adviser = AdviserFactory()
        export_country = CompanyExportCountryFactory(
            company=company,
            country=countries[0],
            status=CompanyExportCountry.Status.FUTURE_INTEREST,
        )

        company.delete_export_country(countries[1].id, adviser)
        history = CompanyExportCountryHistory.objects.filter(
            id=export_country.id,
            history_type=CompanyExportCountryHistory.HistoryType.DELETE,
        )
        assert history.count() == 0
Example #2
0
    def test_company_export_country_history_delete(self):
        """
        Test that deleting an existing CompanyExportCountry record
        sets up a corresponding history record.
        """
        company = CompanyFactory()
        country = CountryModel.objects.order_by('name')[0]
        adviser = AdviserFactory()
        export_country = CompanyExportCountryFactory(
            company=company,
            country=country,
            status=CompanyExportCountry.Status.FUTURE_INTEREST,
        )

        company.delete_export_country(country.id, adviser)
        history = CompanyExportCountryHistory.objects.filter(
            id=export_country.id,
            history_type=CompanyExportCountryHistory.HistoryType.DELETE,
        )
        assert history.count() == 1
        assert history[0].id == export_country.id
        assert history[0].status == CompanyExportCountry.Status.FUTURE_INTEREST
        assert history[0].history_type == CompanyExportCountryHistory.HistoryType.DELETE