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_delete_childless_org.py
Matt Griswold 8ef76dc5ab Support 202110 (#1085)
* Block registering private ASN ranges

* Add a continental region field for facilities #1007

* Incorrect order of search results #232

* Allow users to upload a small logo to their record #346

* Sponsor badge CSS and text translation issues #453

* IXP and Facility summary #18

* Add sales email and phone contact to ix object #949

* Increase timeout timer for IX-F JSON importer to 30s #962

* IX-F manually triggered import bugs #1054

* remove survey notifications

* IX-F importer: manual add followed by IX-F prompted add can result in "The server rejected your data" #807

* performance fix for net view

* api documentation generate broken #956

* fix poc set missing from net view

* Auto focus cursor on search field on main website #695

* PeeringDB website has a poor choice of line-breaks for IPv6 addresses. #748

* Delete childless org objects #838

* linting

* poetry lock

* re-add mistakingly dropped translation to email template

* fix template variables

* regen docs

* regen api docs

* fix merge cruft

* django-peeringdb to 2.11 and poetry relock

* linting

* comment out django-peeringdb volume mount

* add missing declaration

Co-authored-by: Stefan Pratter <stefan@20c.com>
Co-authored-by: David Poarch <dpoarch@20c.com>
2021-11-09 09:47:38 -06:00

50 lines
1.5 KiB
Python

import io
from datetime import timedelta
import pytest
import reversion
from django.conf import settings
from django.core.management import call_command
from django.db.transaction import commit
from django.utils import timezone
from reversion.models import Version
from peeringdb_server.models import Facility, InternetExchange, Network, Organization
from .util import ClientCase, Group
class TestChildlessDeleteOrg(ClientCase):
@classmethod
def setUpTestData(cls):
super().setUpTestData()
with reversion.create_revision():
call_command("pdb_generate_test_data", limit=1, commit=True)
cls.org = Organization.objects.first()
def test_cmd_delete_childless_org(self):
dt = timezone.now() - timedelta(days=settings.ORG_CHILDLESS_DELETE_DURATION + 1)
org = self.org
# Set the date to days before the current date (based on settings.ORG_CHILDLESS_DELETE_DURATION)
org.flagged_date = dt
org.save()
# delete child objects
net = Network.objects.filter(org=org).delete()
ix = InternetExchange.objects.filter(org=org).delete()
fac = Facility.objects.filter(org=org).delete()
# Check if org is childless and can be deleted
assert org.deletable
call_command("pdb_delete_childless_org", commit=True)
org = Organization.objects.filter(id=org.id).first()
# Check if org was flagged and deleted
assert org.flagged
assert org.status == "deleted"