Ejemplo n.º 1
0
 def test_resource_slug(self):
     tool = ToolFactory(unit="qwerty",
                        version="2.7",
                        jurisdiction_code="zys")
     self.assertEqual("qwerty_27_zys", tool.resource_slug)
     tool = ToolFactory(unit="qwerty", version="2.7", jurisdiction_code="")
     self.assertEqual("qwerty_27", tool.resource_slug)
Ejemplo n.º 2
0
 def test_resource_name(self):
     tool = ToolFactory(unit="qwerty",
                        version="2.7",
                        jurisdiction_code="zys")
     self.assertEqual("QWERTY 2.7 ZYS", tool.resource_name)
     tool = ToolFactory(unit="qwerty", version="2.7", jurisdiction_code="")
     self.assertEqual("QWERTY 2.7", tool.resource_name)
Ejemplo n.º 3
0
    def test_translated(self):
        bylicense30ported = ToolFactory(unit="by-nc",
                                        version="3.0",
                                        jurisdiction_code="ar")
        bylicense30unported = ToolFactory(unit="by-nc",
                                          version="3.0",
                                          jurisdiction_code="")

        bylicense40 = ToolFactory(unit="by-nc",
                                  version="4.0",
                                  jurisdiction_code="")

        zerov1declaration = ToolFactory(unit="zero",
                                        version="1.0",
                                        jurisdiction_code="")

        should_be_translated = [
            LegalCodeFactory(tool=bylicense40),
            LegalCodeFactory(tool=zerov1declaration),
        ]
        should_not_be_translated = [
            LegalCodeFactory(tool=bylicense30ported),
            LegalCodeFactory(tool=bylicense30unported),
        ]
        self.assertCountEqual(should_be_translated,
                              list(LegalCode.objects.translated()))
        self.assertCountEqual(
            should_not_be_translated,
            set(LegalCode.objects.all()) - set(LegalCode.objects.translated()),
        )
Ejemplo n.º 4
0
 def test_view_metadata(self):
     ToolFactory(category="licenses", unit="by", version="1.1")
     ToolFactory(category="publicdomain", unit="zero", version="1.1")
     with mock.patch.object(Tool, "get_metadata") as mock_get_metadata:
         mock_get_metadata.return_value = {"foo": "bar"}
         rsp = self.client.get(reverse("metadata"))
     self.assertEqual(200, rsp.status_code)
     mock_get_metadata.assert_called_with()
     self.assertEqual(
         b"licenses:\n- by_11: &id001\n    foo: bar\n"
         b"publicdomain:\n- zero_11: *id001\n",
         rsp.content,
     )
Ejemplo n.º 5
0
    def test_valid(self):
        bylicense30ported = ToolFactory(unit="by-nc",
                                        version="3.0",
                                        jurisdiction_code="ar")
        bylicense30unported = ToolFactory(unit="by-nc",
                                          version="3.0",
                                          jurisdiction_code="")
        nonbylicense30ported = ToolFactory(unit="xyz",
                                           version="3.0",
                                           jurisdiction_code="ar")
        nonbylicense30unported = ToolFactory(unit="xyz",
                                             version="3.0",
                                             jurisdiction_code="")

        bylicense40 = ToolFactory(unit="by-nc",
                                  version="4.0",
                                  jurisdiction_code="")
        nonbylicense40 = ToolFactory(unit="xyz",
                                     version="4.0",
                                     jurisdiction_code="")

        zerov1declaration = ToolFactory(unit="zero",
                                        version="1.0",
                                        jurisdiction_code="")
        nonzerov1declaration = ToolFactory(unit="xyz",
                                           version="1.0",
                                           jurisdiction_code="")

        # Test valid()
        should_be_valid = [
            LegalCodeFactory(tool=bylicense30ported),
            LegalCodeFactory(tool=bylicense30unported),
            LegalCodeFactory(tool=bylicense40),
            LegalCodeFactory(tool=zerov1declaration),
        ]
        should_not_be_valid = [
            LegalCodeFactory(tool=nonbylicense30ported),
            LegalCodeFactory(tool=nonbylicense30unported),
            LegalCodeFactory(tool=nonbylicense40),
            LegalCodeFactory(tool=nonzerov1declaration),
        ]
        self.assertCountEqual(should_be_valid, list(LegalCode.objects.valid()))
        self.assertCountEqual(
            should_not_be_valid,
            set(LegalCode.objects.all()) - set(LegalCode.objects.valid()),
        )
        # Test validgroups()
        self.assertCountEqual(
            should_be_valid,
            list(LegalCode.objects.validgroups()["Licenses 4.0"]) +
            list(LegalCode.objects.validgroups()["Licenses 3.0"]) +
            list(LegalCode.objects.validgroups()["Public Domain all"]),
        )
        self.assertCountEqual(
            should_not_be_valid,
            set(LegalCode.objects.all()) - set(
                list(LegalCode.objects.validgroups()["Licenses 4.0"]) +
                list(LegalCode.objects.validgroups()["Licenses 3.0"]) +
                list(LegalCode.objects.validgroups()["Public Domain all"])),
        )
Ejemplo n.º 6
0
    def test_translation_filename(self):
        data = [
            # (expected, unit, version, jurisdiction, language)
            (
                "/foo/legalcode/de/LC_MESSAGES/by-sa_03.po",
                "by-sa",
                "0.3",
                "",
                "de",
            ),
            (
                "/foo/legalcode/de/LC_MESSAGES/by-sa_03_xx.po",
                "by-sa",
                "0.3",
                "xx",
                "de",
            ),
        ]

        for expected, unit, version, jurisdiction, language in data:
            with self.subTest(expected):
                tool = ToolFactory(
                    unit=unit,
                    version=version,
                    jurisdiction_code=jurisdiction,
                )
                self.assertEqual(
                    expected,
                    LegalCodeFactory(
                        tool=tool,
                        language_code=language).translation_filename(),
                )
Ejemplo n.º 7
0
 def test_legal_code_translation_by_40_es(self):
     tool = ToolFactory(
         category="licenses",
         canonical_url="https://creativecommons.org/licenses/by/4.0/",
         version="4.0",
     )
     legal_code = LegalCodeFactory(
         tool=tool,
         language_code="es",
     )
     url = legal_code.legal_code_url
     rsp = self.client.get(url)
     text = rsp.content.decode("utf-8")
     self.assertEqual(f"{rsp.status_code} {url}", f"200 {url}")
     self.assertEqual("es", rsp.context["legal_code"].language_code)
     if ("INVALID_VARIABLE"
             in text):  # Some unresolved variable in the template
         msgs = ["INVALID_VARIABLE in output"]
         for line in text.splitlines():
             if "INVALID_VARIABLE" in line:
                 msgs.append(line)
         self.fail("\n".join(msgs))
     self.assertContains(rsp, "Sección 1 – Definiciones")
     self.assertContains(
         rsp, 'Sección 4 – Derechos "Sui Generis" sobre Bases de Datos.')
     self.assertContains(rsp, "Sección 8 – Interpretación")
Ejemplo n.º 8
0
 def test_has_english(self):
     tool = ToolFactory()
     lc_fr = LegalCodeFactory(tool=tool, language_code="fr")
     self.assertFalse(lc_fr.has_english())
     lc_en = LegalCodeFactory(tool=tool, language_code="en")
     self.assertTrue(lc_fr.has_english())
     self.assertTrue(lc_en.has_english())
Ejemplo n.º 9
0
 def test_get_redirect_pairs_4(self):
     tool = ToolFactory(category="license", unit="by", version="4.0")
     legal_code = LegalCodeFactory(tool=tool, language_code="nl")
     redirect_pairs = legal_code.get_redirect_pairs("deed")
     self.assertEqual(
         [["license/by/4.0/deed.NL", "license/by/4.0/deed.nl"]],
         redirect_pairs,
     )
Ejemplo n.º 10
0
 def test_str(self):
     tool = ToolFactory(unit="bx-oh",
                        version="1.3",
                        jurisdiction_code="any")
     self.assertEqual(
         str(tool),
         f"Tool<{tool.unit},{tool.version},"
         f"{tool.jurisdiction_code}>",
     )
Ejemplo n.º 11
0
 def test_level_of_freedom(self):
     data = [
         ("by", FREEDOM_LEVEL_MAX),
         ("devnations", FREEDOM_LEVEL_MIN),
         ("sampling", FREEDOM_LEVEL_MIN),
         ("sampling+", FREEDOM_LEVEL_MID),
         ("by-nc", FREEDOM_LEVEL_MID),
         ("by-nd", FREEDOM_LEVEL_MID),
         ("by-sa", FREEDOM_LEVEL_MAX),
     ]
     for unit, expected_freedom in data:
         with self.subTest(unit):
             tool = ToolFactory(unit=unit)
             self.assertEqual(expected_freedom, tool.level_of_freedom)
Ejemplo n.º 12
0
 def test_text_in_deeds(self):
     ToolFactory()
     for tool in Tool.objects.filter(version="4.0"):
         with self.subTest(tool.identifier):
             # Test in English and for 4.0 since that's how we've set up the
             # strings to test for
             url = build_path(
                 canonical_url=tool.canonical_url,
                 document="deed",
                 language_code="en",
             )
             rsp = self.client.get(url)
             self.assertEqual(f"{rsp.status_code} {url}", f"200 {url}")
             self.validate_deed_text(rsp, tool)
Ejemplo n.º 13
0
    def test_get_legal_code_for_language_code(self):
        tool = ToolFactory()

        lc_pt = LegalCodeFactory(tool=tool, language_code="pt")
        lc_en = LegalCodeFactory(tool=tool, language_code="en")

        with override(language="pt"):
            result = tool.get_legal_code_for_language_code(None)
            self.assertEqual(lc_pt.id, result.id)
        result = tool.get_legal_code_for_language_code("pt")
        self.assertEqual(lc_pt.id, result.id)
        result = tool.get_legal_code_for_language_code("en")
        self.assertEqual(lc_en.id, result.id)
        with self.assertRaises(LegalCode.DoesNotExist):
            tool.get_legal_code_for_language_code("en_us")
Ejemplo n.º 14
0
    def test_get_category_and_category_title_category_tool(self):
        category, category_title = get_category_and_category_title(
            category=None,
            tool=None,
        )
        self.assertEqual(category, "licenses")
        self.assertEqual(category_title, "Licenses")

        tool = ToolFactory(
            category="licenses",
            canonical_url="https://creativecommons.org/licenses/by/4.0/",
            version="4.0",
        )
        category, category_title = get_category_and_category_title(
            category=None,
            tool=tool,
        )
        self.assertEqual(category, "licenses")
        self.assertEqual(category_title, "Licenses")
Ejemplo n.º 15
0
 def test_view_legal_code(self):
     tool = ToolFactory(
         category="licenses",
         canonical_url="https://creativecommons.org/licenses/by/4.0/",
         version="4.0",
     )
     for language_code in ["es", "ar", settings.LANGUAGE_CODE]:
         lc = LegalCodeFactory(
             tool=tool,
             language_code=language_code,
         )
         url = lc.legal_code_url
         rsp = self.client.get(url)
         self.assertEqual(200, rsp.status_code)
         self.assertTemplateUsed(rsp, "legalcode.html")
         self.assertTemplateUsed(rsp,
                                 "includes/legalcode_licenses_4.0.html")
         context = rsp.context
         self.assertEqual(lc, context["legal_code"])
         self.assertContains(rsp, f'lang="{language_code}"')
         if language_code == "es":
             self.assertContains(rsp, 'dir="ltr"')
         elif language_code == "ar":
             self.assertContains(rsp, 'dir="rtl"')
Ejemplo n.º 16
0
 def test_rdf(self):
     tool = ToolFactory(unit="bx-oh",
                        version="1.3",
                        jurisdiction_code="any")
     self.assertEqual("RDF Generation Not Implemented", tool.rdf())
Ejemplo n.º 17
0
 def test_logos(self):
     # Every tool includes "cc-logo"
     self.assertIn("cc-logo", ToolFactory().logos())
     self.assertEqual(["cc-logo", "cc-zero"],
                      ToolFactory(unit="zero").logos())
     self.assertEqual(
         ["cc-logo", "cc-by"],
         ToolFactory(
             unit="by",
             version="4.0",
             prohibits_commercial_use=False,
             requires_share_alike=False,
             permits_derivative_works=True,
         ).logos(),
     )
     self.assertEqual(
         ["cc-logo", "cc-by", "cc-nc"],
         ToolFactory(
             unit="by-nc",
             version="3.0",
             prohibits_commercial_use=True,
             requires_share_alike=False,
             permits_derivative_works=True,
         ).logos(),
     )
     self.assertEqual(
         ["cc-logo", "cc-by", "cc-nd"],
         ToolFactory(
             unit="by-nd",
             version="4.0",
             prohibits_commercial_use=False,
             requires_share_alike=False,
             permits_derivative_works=False,
         ).logos(),
     )
     self.assertEqual(
         ["cc-logo", "cc-by", "cc-sa"],
         ToolFactory(
             unit="by-sa",
             version="4.0",
             prohibits_commercial_use=False,
             requires_share_alike=True,
             permits_derivative_works=True,
         ).logos(),
     )
     self.assertEqual(
         ["cc-logo", "cc-by", "cc-nc", "cc-sa"],
         ToolFactory(
             unit="by-nc-sa",
             version="4.0",
             prohibits_commercial_use=True,
             requires_share_alike=True,
             permits_derivative_works=True,
         ).logos(),
     )
     self.assertEqual(
         ["cc-logo", "cc-by", "cc-nc", "cc-sa"],
         ToolFactory(
             unit="by-nc-sa",
             version="3.0",
             prohibits_commercial_use=True,
             requires_share_alike=True,
             permits_derivative_works=True,
         ).logos(),
     )
Ejemplo n.º 18
0
 def test_superseded(self):
     lic1 = ToolFactory()
     lic2 = ToolFactory(is_replaced_by=lic1)
     self.assertTrue(lic2.superseded)
     self.assertFalse(lic1.superseded)
Ejemplo n.º 19
0
 def test_sa(self):
     self.assertFalse(ToolFactory(unit="xyz").sa)
     self.assertTrue(ToolFactory(unit="xyz-sa").sa)
Ejemplo n.º 20
0
 def test_nc(self):
     self.assertFalse(ToolFactory(unit="xyz").nc)
     self.assertTrue(ToolFactory(unit="by-nc-xyz").nc)
Ejemplo n.º 21
0
 def test_nd(self):
     self.assertFalse(ToolFactory(unit="xyz").nd)
     self.assertTrue(ToolFactory(unit="by-nd-xyz").nd)
Ejemplo n.º 22
0
 def test_sampling_plus(self):
     self.assertTrue(ToolFactory(unit="nc-sampling+").sampling_plus)
     self.assertTrue(ToolFactory(unit="sampling+").sampling_plus)
     self.assertFalse(ToolFactory(unit="sampling").sampling_plus)
     self.assertFalse(ToolFactory(unit="MIT").sampling_plus)
     self.assertFalse(ToolFactory(unit="by-nc-nd-sa").sampling_plus)
Ejemplo n.º 23
0
    def test_get_metadata(self):
        # Ported
        tool = ToolFactory(
            **{
                "canonical_url": (
                    "https://creativecommons.org/licenses/by-nc/3.0/xyz/"),
                "category":
                "licenses",
                "unit":
                "by-nc",
                "version":
                "3.0",
                "jurisdiction_code":
                "xyz",
                "permits_derivative_works":
                False,
                "permits_reproduction":
                False,
                "permits_distribution":
                True,
                "permits_sharing":
                True,
                "requires_share_alike":
                True,
                "requires_notice":
                True,
                "requires_attribution":
                True,
                "requires_source_code":
                True,
                "prohibits_commercial_use":
                True,
                "prohibits_high_income_nation_use":
                False,
            })

        LegalCodeFactory(tool=tool, language_code="pt")
        LegalCodeFactory(tool=tool, language_code="en")

        data = tool.get_metadata()
        expected_data = {
            "jurisdiction_name": "UNDEFINED",
            "unit": "by-nc",
            "permits_derivative_works": False,
            "permits_distribution": True,
            "permits_reproduction": False,
            "permits_sharing": True,
            "prohibits_commercial_use": True,
            "prohibits_high_income_nation_use": False,
            "requires_attribution": True,
            "requires_notice": True,
            "requires_share_alike": True,
            "requires_source_code": True,
            "legal_code_languages": {
                "en": "English",
                "pt": "Portuguese",
            },
            "version": "3.0",
        }

        for key in expected_data.keys():
            self.assertEqual(expected_data[key], data[key])

        # Unported
        tool = ToolFactory(
            **{
                "canonical_url": (
                    "https://creativecommons.org/licenses/by-nc/3.0/"),
                "category":
                "licenses",
                "unit":
                "by-nc",
                "version":
                "3.0",
                "jurisdiction_code":
                "",
                "permits_derivative_works":
                False,
                "permits_reproduction":
                False,
                "permits_distribution":
                True,
                "permits_sharing":
                True,
                "requires_share_alike":
                True,
                "requires_notice":
                True,
                "requires_attribution":
                True,
                "requires_source_code":
                True,
                "prohibits_commercial_use":
                True,
                "prohibits_high_income_nation_use":
                False,
            })

        LegalCodeFactory(tool=tool, language_code="en")

        data = tool.get_metadata()
        expected_data = {
            "unit": "by-nc",
            "version": "3.0",
            "permits_derivative_works": False,
            "permits_distribution": True,
            "permits_reproduction": False,
            "permits_sharing": True,
            "prohibits_commercial_use": True,
            "prohibits_high_income_nation_use": False,
            "requires_attribution": True,
            "requires_notice": True,
            "requires_share_alike": True,
            "requires_source_code": True,
            "legal_code_languages": {
                "en": "English",
            },
        }

        for key in expected_data.keys():
            self.assertEqual(expected_data[key], data[key])

        # Deprecated
        tool = ToolFactory(
            **{
                "canonical_url": (
                    "https://creativecommons.org/licenses/sampling/1.0/"),
                "category":
                "licenses",
                "unit":
                "sampling",
                "version":
                "1.0",
                "jurisdiction_code":
                "",
                "deprecated_on":
                "2007-06-04",
                "permits_derivative_works":
                True,
                "permits_reproduction":
                True,
                "permits_distribution":
                True,
                "permits_sharing":
                True,
                "requires_share_alike":
                False,
                "requires_notice":
                True,
                "requires_attribution":
                True,
                "requires_source_code":
                False,
                "prohibits_commercial_use":
                False,
                "prohibits_high_income_nation_use":
                False,
            })

        LegalCodeFactory(tool=tool, language_code="en")

        data = tool.get_metadata()
        expected_data = {
            "unit": "sampling",
            "version": "1.0",
            "deprecated_on": "2007-06-04",
            "permits_derivative_works": True,
            "permits_distribution": True,
            "permits_reproduction": True,
            "permits_sharing": True,
            "prohibits_commercial_use": False,
            "prohibits_high_income_nation_use": False,
            "requires_attribution": True,
            "requires_notice": True,
            "requires_share_alike": False,
            "requires_source_code": False,
            "legal_code_languages": {
                "en": "English",
            },
        }

        for key in expected_data.keys():
            self.assertEqual(expected_data[key], data[key])

        # Deed-only
        tool = ToolFactory(
            **{
                "canonical_url": (
                    "https://creativecommons.org/publicdomain/mark/1.0/"),
                "category":
                "publicdomain",
                "unit":
                "mark",
                "version":
                "1.0",
                "jurisdiction_code":
                "",
                "deed_only":
                True,
                "deprecated_on":
                "2007-06-04",
                "permits_derivative_works":
                True,
                "permits_reproduction":
                True,
                "permits_distribution":
                True,
                "permits_sharing":
                True,
                "requires_share_alike":
                False,
                "requires_notice":
                False,
                "requires_attribution":
                False,
                "requires_source_code":
                False,
                "prohibits_commercial_use":
                False,
                "prohibits_high_income_nation_use":
                False,
            })

        LegalCodeFactory(tool=tool, language_code="en")

        data = tool.get_metadata()
        expected_data = {
            "unit": "mark",
            "version": "1.0",
            "deprecated_on": "2007-06-04",
            "permits_derivative_works": True,
            "permits_distribution": True,
            "permits_reproduction": True,
            "permits_sharing": True,
            "prohibits_commercial_use": False,
            "prohibits_high_income_nation_use": False,
            "requires_attribution": False,
            "requires_notice": False,
            "requires_share_alike": False,
            "requires_source_code": False,
        }

        for key in expected_data.keys():
            self.assertEqual(expected_data[key], data[key])
Ejemplo n.º 24
0
    def setUp(self):
        self.by = ToolFactory(
            canonical_url="https://creativecommons.org/licenses/by/4.0/",
            category="licenses",
            unit="by",
            version="4.0",
            permits_derivative_works=True,
            permits_reproduction=True,
            permits_distribution=True,
            permits_sharing=True,
            requires_share_alike=False,
            requires_notice=True,
            requires_attribution=True,
            requires_source_code=False,
            prohibits_commercial_use=False,
            prohibits_high_income_nation_use=False,
        )
        self.by_nc = ToolFactory(
            canonical_url="https://creativecommons.org/licenses/by-nc/4.0/",
            category="licenses",
            unit="by-nc",
            version="4.0",
            permits_derivative_works=True,
            permits_reproduction=True,
            permits_distribution=True,
            permits_sharing=True,
            requires_share_alike=False,
            requires_notice=True,
            requires_attribution=True,
            requires_source_code=False,
            prohibits_commercial_use=True,
            prohibits_high_income_nation_use=False,
        )
        self.by_nc_nd = ToolFactory(
            canonical_url="https://creativecommons.org/licenses/by-nc-nd/4.0/",
            category="licenses",
            unit="by-nc-nd",
            version="4.0",
            permits_derivative_works=False,
            permits_reproduction=True,
            permits_distribution=True,
            permits_sharing=True,
            requires_share_alike=False,
            requires_notice=True,
            requires_attribution=True,
            requires_source_code=False,
            prohibits_commercial_use=True,
            prohibits_high_income_nation_use=False,
        )
        self.by_nc_sa = ToolFactory(
            canonical_url="https://creativecommons.org/licenses/by-nc-sa/4.0/",
            category="licenses",
            unit="by-nc-sa",
            version="4.0",
            permits_derivative_works=True,
            permits_reproduction=True,
            permits_distribution=True,
            permits_sharing=True,
            requires_share_alike=True,
            requires_notice=True,
            requires_attribution=True,
            requires_source_code=False,
            prohibits_commercial_use=True,
            prohibits_high_income_nation_use=False,
        )
        self.by_nd = ToolFactory(
            canonical_url="https://creativecommons.org/licenses/by-nd/4.0/",
            category="licenses",
            unit="by-nd",
            version="4.0",
            permits_derivative_works=False,
            permits_reproduction=True,
            permits_distribution=True,
            permits_sharing=True,
            requires_share_alike=False,
            requires_notice=True,
            requires_attribution=True,
            requires_source_code=False,
            prohibits_commercial_use=False,
            prohibits_high_income_nation_use=False,
        )
        self.by_sa = ToolFactory(
            canonical_url="https://creativecommons.org/licenses/by-sa/4.0/",
            category="licenses",
            unit="by-sa",
            version="4.0",
            permits_derivative_works=True,
            permits_reproduction=True,
            permits_distribution=True,
            permits_sharing=True,
            requires_share_alike=True,
            requires_notice=True,
            requires_attribution=True,
            requires_source_code=False,
            prohibits_commercial_use=False,
            prohibits_high_income_nation_use=False,
        )
        self.by = ToolFactory(
            canonical_url="https://creativecommons.org/licenses/by/3.0/",
            category="licenses",
            unit="by",
            version="3.0",
            permits_derivative_works=True,
            permits_reproduction=True,
            permits_distribution=True,
            permits_sharing=True,
            requires_share_alike=False,
            requires_notice=True,
            requires_attribution=True,
            requires_source_code=False,
            prohibits_commercial_use=False,
            prohibits_high_income_nation_use=False,
        )
        self.by = ToolFactory(
            canonical_url="https://creativecommons.org/licenses/by/2.0/",
            category="licenses",
            unit="by",
            version="2.0",
            permits_derivative_works=True,
            permits_reproduction=True,
            permits_distribution=True,
            permits_sharing=True,
            requires_share_alike=False,
            requires_notice=True,
            requires_attribution=True,
            requires_source_code=False,
            prohibits_commercial_use=False,
            prohibits_high_income_nation_use=False,
        )
        self.zero = ToolFactory(
            canonical_url="https://creativecommons.org/publicdomain/zero/1.0/",
            category="publicdomain",
            unit="zero",
            version="1.0",
            permits_derivative_works=True,
            permits_reproduction=True,
            permits_distribution=True,
            permits_sharing=True,
            requires_share_alike=False,
            requires_notice=False,
            requires_attribution=False,
            requires_source_code=False,
            prohibits_commercial_use=False,
            prohibits_high_income_nation_use=False,
        )

        for tool in Tool.objects.all():
            LegalCodeFactory(tool=tool, language_code="en")
            LegalCodeFactory(tool=tool, language_code="es")
            LegalCodeFactory(tool=tool, language_code="fr")

        self.by_sa_30_es = ToolFactory(
            canonical_url="https://creativecommons.org/licenses/by-sa/3.0/es/",
            category="licenses",
            unit="by-sa",
            version="3.0",
            jurisdiction_code="es",
            permits_derivative_works=True,
            permits_reproduction=True,
            permits_distribution=True,
            permits_sharing=True,
            requires_share_alike=True,
            requires_notice=True,
            requires_attribution=True,
            requires_source_code=False,
            prohibits_commercial_use=False,
            prohibits_high_income_nation_use=False,
        )
        LegalCodeFactory(tool=self.by_sa_30_es,
                         language_code="es")  # Default lang

        self.by_sa_20_es = ToolFactory(
            canonical_url="https://creativecommons.org/licenses/by-sa/2.0/es/",
            category="licenses",
            unit="by-sa",
            version="2.0",
            jurisdiction_code="es",
            permits_derivative_works=True,
            permits_reproduction=True,
            permits_distribution=True,
            permits_sharing=True,
            requires_share_alike=True,
            requires_notice=True,
            requires_attribution=True,
            requires_source_code=False,
            prohibits_commercial_use=False,
            prohibits_high_income_nation_use=False,
        )
        LegalCodeFactory(tool=self.by_sa_20_es,
                         language_code="es")  # Default lang

        super().setUp()