def test_valid(self):
    bylicense30ported = LicenseFactory(license_code='by-nc', version='3.0', jurisdiction_code='ar')
    bylicense30unported = LicenseFactory(license_code='by-nc', version='3.0', jurisdiction_code='')
    nonbylicense30ported = LicenseFactory(license_code='xyz', version='3.0', jurisdiction_code='ar')
    nonbylicense30unported = LicenseFactory(license_code='xyz', version='3.0', jurisdiction_code='')
    bylicense40 = LicenseFactory(license_code='by-nc', version='4.0', jurisdiction_code='')
    nonbylicense40 = LicenseFactory(license_code='xyz', version='4.0', jurisdiction_code='')
    cc0v1license = LicenseFactory(license_code='CC0', version='1.0', jurisdiction_code='')
    noncc0v1license = LicenseFactory(license_code='xyz', version='1.0', jurisdiction_code='')
    should_be_valid = [LegalCodeFactory(license=bylicense30ported), LegalCodeFactory(license=bylicense30unported), LegalCodeFactory(license=bylicense40), LegalCodeFactory(license=cc0v1license)]
    should_not_be_valid = [LegalCodeFactory(license=nonbylicense30ported), LegalCodeFactory(license=nonbylicense30unported), LegalCodeFactory(license=nonbylicense40), LegalCodeFactory(license=noncc0v1license)]
    self.assertCountEqual(should_be_valid, list(LegalCode.objects.valid()))
    self.assertCountEqual(should_not_be_valid, (set(LegalCode.objects.all()) - set(LegalCode.objects.valid())))
    self.assertCountEqual(should_be_valid, ((list(LegalCode.objects.validgroups()['by4.0']) + list(LegalCode.objects.validgroups()['by3.0'])) + list(LegalCode.objects.validgroups()['zero1.0'])))
    self.assertCountEqual(should_not_be_valid, (set(LegalCode.objects.all()) - set(((list(LegalCode.objects.validgroups()['by4.0']) + list(LegalCode.objects.validgroups()['by3.0'])) + list(LegalCode.objects.validgroups()['zero1.0'])))))
def test_valid(self):
    bylicense30ported = LicenseFactory(license_code='by-nc', version='3.0', jurisdiction_code='ar')
    bylicense30unported = LicenseFactory(license_code='by-nc', version='3.0', jurisdiction_code=)
    nonbylicense30ported = LicenseFactory(license_code='xyz', version='3.0', jurisdiction_code='ar')
    nonbylicense30unported = LicenseFactory(license_code='xyz', version='3.0', jurisdiction_code=)
    bylicense40 = LicenseFactory(license_code='by-nc', version='4.0', jurisdiction_code=)
    nonbylicense40 = LicenseFactory(license_code='xyz', version='4.0', jurisdiction_code=)
    cc0v1license = LicenseFactory(license_code='CC0', version='1.0', jurisdiction_code=)
    noncc0v1license = LicenseFactory(license_code='xyz', version='1.0', jurisdiction_code=)
    should_be_valid = [LegalCodeFactory(license=bylicense30ported), LegalCodeFactory(license=bylicense30unported), LegalCodeFactory(license=bylicense40), LegalCodeFactory(license=cc0v1license)]
    should_not_be_valid = [LegalCodeFactory(license=nonbylicense30ported), LegalCodeFactory(license=nonbylicense30unported), LegalCodeFactory(license=nonbylicense40), LegalCodeFactory(license=noncc0v1license)]
    self.assertCountEqual(should_be_valid, list(LegalCode.objects.valid()))
    self.assertCountEqual(should_not_be_valid, (set(LegalCode.objects.all()) - set(LegalCode.objects.valid())))
    self.assertCountEqual(should_be_valid, ((list(LegalCode.objects.validgroups()['by4.0']) + list(LegalCode.objects.validgroups()['by3.0'])) + list(LegalCode.objects.validgroups()['zero1.0'])))
    self.assertCountEqual(should_not_be_valid, (set(LegalCode.objects.all()) - set(((list(LegalCode.objects.validgroups()['by4.0']) + list(LegalCode.objects.validgroups()['by3.0'])) + list(LegalCode.objects.validgroups()['zero1.0'])))))