test_project# project_json# Source code in tests/unit/apps/core/models/test_project.py 7 8 9 10 11 12 13 14 15 16 17@pytest.fixture def project_json(): return { "participating_organizations": [{"pref_label": {"fi": "testi"}}], "funding": [ { "funding_identifier": "rahoitustunniste", "funder": {"organization": {"pref_label": {"fi": "rahoittajataho"}}}, } ], } test_serialize_project# Source code in tests/unit/apps/core/models/test_project.py 20 21 22 23 24 25 26 27 28 29def test_serialize_project(project_json): serializer = ProjectModelSerializer( data=project_json, context={"dataset": None}, ) serializer.is_valid(raise_exception=True) project = serializer.save() assert project.participating_organizations.first().pref_label["fi"] == "testi" assert project.funding.first().funding_identifier == "rahoitustunniste" assert project.funding.first().funder.organization.pref_label["fi"] == "rahoittajataho" test_serialize_project_no_org# Source code in tests/unit/apps/core/models/test_project.py 32 33 34 35 36 37 38 39def test_serialize_project_no_org(project_json): project_json["participating_organizations"] = [] serializer = ProjectModelSerializer( data=project_json, context={"dataset": None}, ) with pytest.raises(serializers.ValidationError): serializer.is_valid(raise_exception=True) test_serialize_project_no_org_migrating# Source code in tests/unit/apps/core/models/test_project.py 42 43 44 45 46 47 48 49 50def test_serialize_project_no_org_migrating(project_json): project_json["participating_organizations"] = [] serializer = ProjectModelSerializer( data=project_json, context={"dataset": None, "migrating": True}, ) serializer.is_valid(raise_exception=True) project = serializer.save() assert project.participating_organizations.count() == 0