forked from enviPath/enviPy
..:
This commit is contained in:
@ -43,11 +43,11 @@ def set_cc(apps, schema_editor):
|
||||
|
||||
for k, v in license_lookup.items():
|
||||
# Set to min ID
|
||||
print(Packages.objects.filter(pk__in=v[1]).update(license_id=v[0]))
|
||||
Packages.objects.filter(pk__in=v[1]).update(license_id=v[0])
|
||||
# Remove min ID
|
||||
v[1].remove(v[0])
|
||||
# Delete Redundant License Objects
|
||||
print(License.objects.filter(pk__in=v[1]).delete())
|
||||
License.objects.filter(pk__in=v[1]).delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@ -4,7 +4,14 @@ from django.test import TestCase, tag
|
||||
from django.urls import reverse
|
||||
|
||||
from epdb.logic import UserManager
|
||||
from epdb.models import Package, UserPackagePermission, Permission, GroupPackagePermission, Group, License
|
||||
from epdb.models import (
|
||||
Package,
|
||||
UserPackagePermission,
|
||||
Permission,
|
||||
GroupPackagePermission,
|
||||
Group,
|
||||
License,
|
||||
)
|
||||
|
||||
|
||||
class PackageViewTest(TestCase):
|
||||
@ -32,11 +39,12 @@ class PackageViewTest(TestCase):
|
||||
# Create the default license set.
|
||||
cc_strings = ["by", "by-nc", "by-nc-nd", "by-nc-sa", "by-nd", "by-sa"]
|
||||
for cc_string in cc_strings:
|
||||
new_license = License()
|
||||
new_license.cc_string = cc_string
|
||||
new_license.link = f"https://creativecommons.org/licenses/{cc_string}/4.0/"
|
||||
new_license.image_link = f"https://licensebuttons.net/l/{cc_string}/4.0/88x31.png"
|
||||
new_license.save()
|
||||
if not License.objects.filter(cc_string=cc_string).exists():
|
||||
new_license = License()
|
||||
new_license.cc_string = cc_string
|
||||
new_license.link = f"https://creativecommons.org/licenses/{cc_string}/4.0/"
|
||||
new_license.image_link = f"https://licensebuttons.net/l/{cc_string}/4.0/88x31.png"
|
||||
new_license.save()
|
||||
|
||||
def setUp(self):
|
||||
self.client.force_login(self.user1)
|
||||
@ -203,7 +211,21 @@ class PackageViewTest(TestCase):
|
||||
self.client.post(package_url, {"license": cc_string})
|
||||
# Without this, the instance of p doesn't have the license. However, the one retrieved with get does
|
||||
p = Package.objects.get(url=package_url)
|
||||
self.assertEqual(p.license.link, f"https://creativecommons.org/licenses/{cc_string}/4.0/")
|
||||
self.assertEqual(
|
||||
p.license.link, f"https://creativecommons.org/licenses/{cc_string}/4.0/"
|
||||
)
|
||||
|
||||
# Test again to ensure that Licenses are reused
|
||||
cc_strings = ["by", "by-nc", "by-nc-nd", "by-nc-sa", "by-nd", "by-sa"]
|
||||
for cc_string in cc_strings:
|
||||
self.client.post(package_url, {"license": cc_string})
|
||||
# Without this, the instance of p doesn't have the license. However, the one retrieved with get does
|
||||
p = Package.objects.get(url=package_url)
|
||||
self.assertEqual(
|
||||
p.license.link, f"https://creativecommons.org/licenses/{cc_string}/4.0/"
|
||||
)
|
||||
|
||||
self.assertEqual(License.objects.count(), len(cc_strings))
|
||||
|
||||
def test_delete_package(self):
|
||||
response = self.client.post(
|
||||
|
||||
Reference in New Issue
Block a user