1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00
Files
peeringdb-peeringdb/tests/test_cmd_pdb_sponsorship_notify.py
Matt Griswold 16285c13f3 Support 202010 (#868)
* Add migrations for 463_745_775

* Black format the migration

* Bump up django_peeringdb version

* api require django-peeringdb 2.3.0.1 and later

* Set timezone to utc throughout sponsorship notifications

* Add government net type to existing migrtion

* Remove ixlan from peers at this exchange point

* Add new migration

* add backward migrtion

* Search on user__username not user object

* Black those changes

* Fix local erro bug

* Add test and fix speed update for deleted netixlan

* Handle attribute error

* Change language in email to reflect we don't email after x days

* Comment out EnvironmentSetting in django admin

* Disable the followup ticket and modify tests to correct deskproticket assertions

* exclude ixf tickets from deskpro publishing

* Add failing mock deskpro api and write a test with it

* Add anchor tags to notify-ixf-add

* a tags for conflict insert

* a tags for consolidated

* a tags modify

* a tags protocol conflict

* a tags remote changes

* a tags for remove

* a tags for resolved

* a tags source error

* Add target blank

* Add comment

* fix unhandled deskpro api errors

* Add mail attachment

* Remove strip_tags

* readd some strip_tags

* add explicit order for fields in admin control panel #861

* revert pretty_speed change

* Coerce is_rs_peer and operational to bool

* black formatted

* pipfile relock

Co-authored-by: Elliot Frank <elliot@20c.com>
Co-authored-by: Stefan Pratter <stefan@20c.com>
2020-11-03 18:26:15 -06:00

41 lines
1.2 KiB
Python

from datetime import datetime, timezone, timedelta
import pytest
import random
import string
from django.conf import settings
from django.core.management import call_command
from django.test import override_settings
from peeringdb_server.models import Sponsorship
from peeringdb_server.models import Organization
FIVE_MONTHS_AGO = datetime.now(tz=timezone.utc) - timedelta(days=150)
TWO_MONTHS_AGO = datetime.now(tz=timezone.utc) - timedelta(days=60)
NOW = datetime.now(tz=timezone.utc)
# max number of seconds we allow between running command and asserting date is
# the same
SECONDS_THRESHOLD = 120
@pytest.mark.django_db
@override_settings(SPONSORSHIPS_EMAIL="localhost")
def test_send_email(outdated_sponsorship):
sponsorship = Sponsorship.objects.all()[0]
call_command("pdb_sponsorship_notify")
sponsorship.refresh_from_db()
assert (sponsorship.notify_date - NOW) < timedelta(seconds=SECONDS_THRESHOLD)
@pytest.fixture
def outdated_sponsorship():
# Has not been notified of expiration
org = Sponsorship.objects.create(
start_date=FIVE_MONTHS_AGO,
end_date=TWO_MONTHS_AGO,
notify_date=None,
level=2,
)
return org