def test_convert(self): for source, expected in TEST_DATA.items(): self.assertEqual( expected, convert_license(source), "License conversion failed for {}".format(source), )
def migrate_licenses(apps, schema_editor): db_alias = schema_editor.connection.alias Component = apps.get_model("trans", "Component") for component in Component.objects.using(db_alias).exclude(license=""): converted = convert_license(component.license) if converted == component.license: continue if converted == "proprietary": print('WARNING: Converted {}/{} license "{}" to "{}"'.format( component.project.slug, component.slug, component.license, converted)) component.license = converted component.save(update_fields=["license"])