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():
|
for k, v in license_lookup.items():
|
||||||
# Set to min ID
|
# 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
|
# Remove min ID
|
||||||
v[1].remove(v[0])
|
v[1].remove(v[0])
|
||||||
# Delete Redundant License Objects
|
# 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):
|
class Migration(migrations.Migration):
|
||||||
|
|||||||
@ -4,7 +4,14 @@ from django.test import TestCase, tag
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from epdb.logic import UserManager
|
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):
|
class PackageViewTest(TestCase):
|
||||||
@ -32,6 +39,7 @@ class PackageViewTest(TestCase):
|
|||||||
# Create the default license set.
|
# Create the default license set.
|
||||||
cc_strings = ["by", "by-nc", "by-nc-nd", "by-nc-sa", "by-nd", "by-sa"]
|
cc_strings = ["by", "by-nc", "by-nc-nd", "by-nc-sa", "by-nd", "by-sa"]
|
||||||
for cc_string in cc_strings:
|
for cc_string in cc_strings:
|
||||||
|
if not License.objects.filter(cc_string=cc_string).exists():
|
||||||
new_license = License()
|
new_license = License()
|
||||||
new_license.cc_string = cc_string
|
new_license.cc_string = cc_string
|
||||||
new_license.link = f"https://creativecommons.org/licenses/{cc_string}/4.0/"
|
new_license.link = f"https://creativecommons.org/licenses/{cc_string}/4.0/"
|
||||||
@ -203,7 +211,21 @@ class PackageViewTest(TestCase):
|
|||||||
self.client.post(package_url, {"license": cc_string})
|
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
|
# 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)
|
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):
|
def test_delete_package(self):
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
|
|||||||
Reference in New Issue
Block a user