@@ -793,17 +793,19 @@ def _get_field_pattern(
793793 # Without any environment variables set. dandischema is unvendorized.
794794 (
795795 {},
796- "DANDI-ADHOC " ,
797- None ,
796+ r"[A-Z][-A-Z]* " ,
797+ r"10\.\d{4,}" ,
798798 {
799799 "dandiset_id" : "DANDI-ADHOC:001350/draft" ,
800800 "dandiset_identifier" : "DANDI-ADHOC:001350" ,
801801 "published_dandiset_id" : "DANDI-ADHOC:001350/0.250511.1527" ,
802+ "published_dandiset_doi" : "" ,
802803 },
803804 {
804805 "dandiset_id" : "45:001350/draft" , # Invalid id prefix
805806 "dandiset_identifier" : "DANDI-ADHOC:001350" ,
806807 "published_dandiset_id" : "DANDI-ADHOC:001350/0.250511.1527" ,
808+ "published_dandiset_doi" : "" ,
807809 },
808810 ),
809811 (
@@ -832,34 +834,39 @@ def _get_field_pattern(
832834 "instance_name" : "DANDI" ,
833835 },
834836 "DANDI" ,
835- None ,
837+ r"10\.\d{4,}" ,
836838 {
837839 "dandiset_id" : "DANDI:001425/draft" ,
838840 "dandiset_identifier" : "DANDI:001425" ,
839841 "published_dandiset_id" : "DANDI:001425/0.250514.0602" ,
842+ "published_dandiset_doi" : "10.48324/dandi.001425/0.250514.0602" ,
840843 },
841844 {
842845 "dandiset_id" : "DANDI:001425/draft" ,
843846 "dandiset_identifier" : "DANDI:001425" ,
844847 # Not matching the `ID_PATTERN` regex
845848 "published_dandiset_id" : "DANDI3:001425/0.250514.0602" ,
849+ "published_dandiset_doi" : "10.48324/dandi.001425/0.250514.0602" ,
846850 },
847851 ),
848852 # === EMBER DANDI instance test cases ===
849853 # Without any environment variables set. dandischema is unvendorized.
850854 (
851855 {},
852- "DANDI-ADHOC " ,
853- None ,
856+ r"[A-Z][-A-Z]* " ,
857+ r"10\.\d{4,}" ,
854858 {
855859 "dandiset_id" : "DANDI-ADHOC:000005/draft" ,
856- "dandiset_identifier" : "DANDI-ADHOC :000005" ,
860+ "dandiset_identifier" : "ABC :000005" ,
857861 "published_dandiset_id" : "DANDI-ADHOC:000005/0.250404.1839" ,
862+ "published_dandiset_doi" : "10.60533/ember-dandi.000005/0.250404.1839" ,
858863 },
859864 {
860865 "dandiset_id" : "DANDI-ADHOC:000005/draft" ,
861- "dandiset_identifier" : "-DANDI-ADHOC :000005" , # Invalid id prefix
866+ "dandiset_identifier" : "ABC :000005" ,
862867 "published_dandiset_id" : "DANDI-ADHOC:000005/0.250404.1839" ,
868+ # Invalid registrant code in the DOI prefix
869+ "published_dandiset_doi" : "10.605/ember-dandi.000005/0.250404.1839" ,
863870 },
864871 ),
865872 (
@@ -889,7 +896,7 @@ def _get_field_pattern(
889896def test_vendorization (
890897 clear_dandischema_modules_and_set_env_vars : None ,
891898 exp_id_pattern : str ,
892- exp_doi_prefix_pattern : Optional [ str ] ,
899+ exp_doi_prefix_pattern : str ,
893900 # Fields that are valid for the vendorization
894901 valid_vendored_fields : dict [str , str ],
895902 # Fields that are invalid for the vendorization
@@ -915,12 +922,11 @@ class VendoredFieldModel(BaseModel):
915922 published_dandiset_id : str = Field (
916923 pattern = _get_field_pattern ("id" , models_ .PublishedDandiset )
917924 )
918- if exp_doi_prefix_pattern is not None :
919- published_dandiset_doi : str = Field (
920- pattern = _get_field_pattern ("doi" , models_ .PublishedDandiset )
921- )
925+ published_dandiset_doi : str = Field (
926+ pattern = _get_field_pattern ("doi" , models_ .PublishedDandiset )
927+ )
922928
923- model_config = ConfigDict (strict = True , extra = "forbid" )
929+ model_config = ConfigDict (strict = True )
924930
925931 # Validate the valid vendored fields against the vendored patterns
926932 VendoredFieldModel .model_validate (valid_vendored_fields )
0 commit comments