Beispiel #1
0
    def test_default_codelists_type(self, codelist_lengths_by_version):
        """Check that the default Codelists are of the correct type.

        Todo:
            Switch from type-checking to behavior-checking, which is more Pythonic.
        """
        codelists = iati.default.codelists(codelist_lengths_by_version.version)

        assert isinstance(codelists, dict)
        assert len(
            codelists.values()) == codelist_lengths_by_version.expected_length
        for codelist in codelists.values():
            assert isinstance(codelist, iati.Codelist)
            for code in codelist.codes:
                assert isinstance(code, iati.Code)
Beispiel #2
0
    def test_default_codelists_no_name_codes_have_no_name(
            self, standard_version_optional, codelists_with_no_name_codes):
        """Check that Codelists with Codes that are known to have no name have no name.

        Ideally all Codes would have a name. There are a couple of Codelists where Codes do not. This test is intended to identify the point in time that names are added.

        """
        codelists = iati.default.codelists(*standard_version_optional)
        relevant_codelists = [
            codelist for codelist in codelists.values()
            if codelist.name in codelists_with_no_name_codes
        ]

        for codelist in relevant_codelists:
            for code in codelist.codes:
                assert code.name == ''
Beispiel #3
0
    def test_default_codelists_codes_have_name(self, standard_version_optional,
                                               codelists_with_no_name_codes):
        """Check that Codelists with Codes that should have names do have names.

        Codes in a Codelist should have a name. This checks that default Codelists have names. A small number of Codelists are excluded because they are known not to have names.

        """
        codelists = iati.default.codelists(*standard_version_optional)
        relevant_codelists = [
            codelist for codelist in codelists.values()
            if codelist.name not in codelists_with_no_name_codes
        ]

        for codelist in relevant_codelists:
            for code in codelist.codes:
                assert code.name != ''