mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
* fix issue where ix-f import would raise suggestions ipaddresses not that ixlan (#764) * IX-F Suggestions: Leaving the editor and returning to it via back button issues (#765) * IX-F importer: Clicking "Preview" (IXP Update Tools) on /net/ page resulted in 170 ticket resolutions (#769) More robust testing * black formatting (was lost after pyupgrade) * Add regex searching to deskpro ticket subjects * Change operational error * IX-F suggestions: consolidate delete+add (#770) * Add reset functions to commandline tool * Fix commandline tool bugs * Fix reset commandline tool bugs * add commandline tool * Ixlan needs to be set for import commandline tool * Add email model * Add admin view to emails * Allow network and ix to be null * save emails as part of ixf import * Add email model * Add email delete * add iregex search and better comments * fix ixlan selection for import * redefine migration dependencies for this branch * only enable search w start and end char * Add caption to regex search * Remove delete all ixfmemberdata option * [beta] IX-F importer: don't bother about missing IPv{4,6} address when network is not doing IPv{4,6} (#771) * Add cmdline tests * Resolve email conflicts * Add cmd tool reset tests * add autocomplete to commandline tool * Fix email bugs * Fix email migrations * Fix typos * [beta] IX-F importer: prevent Admin Committee overload by initially limiting importer to IXes enabled by AC (#772) * Finalize regex search for emails and deskprotickets * Fix keyword bug * fix typo * protocol-conflict will now be handled in the notification consolidation 771 changes where if the network indicates neither ipv4 nor ipv6 support, it is handled as supporting both (eg the network didnt configure these at all) realised that the importer command re instantiates the `Importer` class for each ixlan it processes, so moved the sending of consolidated notifications (#772) out of the `update` function and into the command itself after its done processing all the ixlans. This means for tests you will need to call `importer.notify_proposals` after `importer.update` to test the consolidated notifications. fixed several MultipleObjectsReturned errors when network switch protocol support in between imports * should be checking for "ix" in the form data (#773) * Fix cmd ixf tests * fix issue in log_peer * Add commit check for reset tool * fix importer bugs * remove dupe IXFImportEmail definition * ixfimportemail support ix__name and net__name searching * ticket resolution responses * Add commit to command ixf import changes * fix modify entry header * remove whitespace in notification about remote data changes * Begin updating tests * ixf-import command line tool to queue * refactor conflict inserts * Update import protocol tests, including tests for 770 * More test edits * Change cmd tests * better ixfmemberdata error handling and fix some test data * dont reset the same ixfmemberdata requirement * fix many bugs add many tests * remove debug message * fix bug during import when consolidating delete+add * fix perfomance issue in IXFMemberData listing * dont show reset flags on prod env * Add regex search tests * Add 772 tests * remove debug output * fix `test_resolve_deskpro_ticket` test * black formatting * remove dupe import * fix issue with unique constraint error handling * add test for ixp / network ip protocol notification * add missing test data Co-authored-by: Stefan Pratter <stefan@20c.com> Co-authored-by: Elliot Frank <elliot@20c.com>
144 lines
4.5 KiB
Python
144 lines
4.5 KiB
Python
import pytest
|
|
import json
|
|
import uuid
|
|
import re
|
|
|
|
from django.test import Client, TestCase, RequestFactory
|
|
from django.contrib.auth.models import Group, AnonymousUser
|
|
from django.contrib.auth import get_user
|
|
import django_namespace_perms as nsp
|
|
|
|
import peeringdb_server.views as views
|
|
import peeringdb_server.models as models
|
|
|
|
|
|
class ViewTestCase(TestCase):
|
|
|
|
entities = ["ix", "net", "fac"]
|
|
|
|
@classmethod
|
|
def setUpTestData(cls):
|
|
# create user and guest group
|
|
|
|
guest_group = Group.objects.create(name="guest")
|
|
user_group = Group.objects.create(name="user")
|
|
|
|
cls.guest_user = models.User.objects.create_user(
|
|
"guest", "guest@localhost", "guest"
|
|
)
|
|
cls.guest_user.set_password("guest")
|
|
guest_group.user_set.add(cls.guest_user)
|
|
|
|
# create organizations
|
|
|
|
cls.organizations = {
|
|
f"{k}": models.Organization.objects.create(
|
|
name="Sponsor Org %s" % k, status="ok"
|
|
)
|
|
for k in range(1, 7)
|
|
}
|
|
|
|
# create sponsorships
|
|
|
|
cls.sponsorships = {
|
|
"1": models.Sponsorship.objects.create(level=1),
|
|
"2": models.Sponsorship.objects.create(level=1),
|
|
"3": models.Sponsorship.objects.create(level=2),
|
|
"4": models.Sponsorship.objects.create(level=1),
|
|
"5_and_6": models.Sponsorship.objects.create(level=3),
|
|
}
|
|
|
|
# org sponsorship with logo and url set lvl1
|
|
|
|
models.SponsorshipOrganization.objects.create(
|
|
sponsorship=cls.sponsorships["1"],
|
|
org=cls.organizations["1"],
|
|
logo="fake.png",
|
|
url="org-1.com",
|
|
)
|
|
|
|
# org sponsorship with logo set lvl1
|
|
|
|
models.SponsorshipOrganization.objects.create(
|
|
sponsorship=cls.sponsorships["2"],
|
|
org=cls.organizations["2"],
|
|
logo="fake.png",
|
|
)
|
|
|
|
# org sponsorship with logo set lvl2
|
|
|
|
models.SponsorshipOrganization.objects.create(
|
|
sponsorship=cls.sponsorships["3"],
|
|
org=cls.organizations["3"],
|
|
logo="fake.png",
|
|
)
|
|
|
|
# org sponsorship without logo or url set lvl1
|
|
|
|
models.SponsorshipOrganization.objects.create(
|
|
sponsorship=cls.sponsorships["4"], org=cls.organizations["4"],
|
|
)
|
|
|
|
# two orgs in one sponsorship
|
|
|
|
models.SponsorshipOrganization.objects.create(
|
|
sponsorship=cls.sponsorships["5_and_6"],
|
|
org=cls.organizations["5"],
|
|
logo="fake.png",
|
|
url="org-5.com",
|
|
)
|
|
|
|
models.SponsorshipOrganization.objects.create(
|
|
sponsorship=cls.sponsorships["5_and_6"],
|
|
org=cls.organizations["6"],
|
|
logo="fake.png",
|
|
url="org-6.com",
|
|
)
|
|
|
|
def setUp(self):
|
|
self.factory = RequestFactory()
|
|
|
|
def test_data_view(self):
|
|
c = Client()
|
|
resp = c.get("/data/sponsors", follow=True)
|
|
self.assertEqual(resp.status_code, 200)
|
|
expected = {
|
|
"sponsors": {
|
|
"1": {"id": 1, "name": "silver"},
|
|
"3": {"id": 3, "name": "gold"},
|
|
"2": {"id": 2, "name": "silver"},
|
|
"5": {"id": 5, "name": "platinum"},
|
|
"4": {"id": 4, "name": "silver"},
|
|
"6": {"id": 6, "name": "platinum"},
|
|
}
|
|
}
|
|
self.assertEqual(resp.json(), expected)
|
|
|
|
def test_view(self):
|
|
c = Client()
|
|
resp = c.get("/sponsors", follow=True)
|
|
self.assertEqual(resp.status_code, 200)
|
|
|
|
# make sure orgs 1,2,3,5 and 6 exists in the sponsor page
|
|
assert self.organizations["1"].name in resp.content.decode()
|
|
assert self.organizations["2"].name in resp.content.decode()
|
|
assert self.organizations["3"].name in resp.content.decode()
|
|
assert self.organizations["5"].name in resp.content.decode()
|
|
assert self.organizations["6"].name in resp.content.decode()
|
|
|
|
# make sure org 4 does not exist in the sponsors page
|
|
assert self.organizations["4"].name not in resp.content.decode()
|
|
|
|
# makre sure order is randomized with each view
|
|
i = 0
|
|
rgx = re.compile(r'fake.png" alt="([^"]+)"')
|
|
a = re.findall(rgx, resp.content.decode())
|
|
while i < 100:
|
|
resp = c.get("/sponsors", follow=True)
|
|
b = re.findall(rgx, resp.content.decode())
|
|
self.assertEqual(len(a), len(b))
|
|
if b != a:
|
|
break
|
|
i += 1
|
|
self.assertLess(i, 99)
|