|
13 | 13 | check_institution, |
14 | 14 | check_keywords, |
15 | 15 | check_processing_module_name, |
| 16 | + check_session_id_no_slashes, |
16 | 17 | check_session_start_time_future_date, |
17 | 18 | check_session_start_time_old_date, |
18 | 19 | check_subject_age, |
19 | 20 | check_subject_exists, |
20 | 21 | check_subject_id_exists, |
| 22 | + check_subject_id_no_slashes, |
21 | 23 | check_subject_proper_age_range, |
22 | 24 | check_subject_sex, |
23 | 25 | check_subject_species_exists, |
@@ -565,3 +567,53 @@ def test_check_processing_module_name(): |
565 | 567 | def test_pass_check_processing_module_name(): |
566 | 568 | processing_module = ProcessingModule(name="ecephys", description="desc") |
567 | 569 | assert check_processing_module_name(processing_module) is None |
| 570 | + |
| 571 | + |
| 572 | +def test_pass_check_session_id_no_slashes(): |
| 573 | + nwbfile = NWBFile( |
| 574 | + session_description="", |
| 575 | + identifier=str(uuid4()), |
| 576 | + session_start_time=datetime.now().astimezone(), |
| 577 | + session_id="session001", |
| 578 | + ) |
| 579 | + assert check_session_id_no_slashes(nwbfile) is None |
| 580 | + |
| 581 | + |
| 582 | +def test_check_session_id_with_slashes(): |
| 583 | + nwbfile = NWBFile( |
| 584 | + session_description="", |
| 585 | + identifier=str(uuid4()), |
| 586 | + session_start_time=datetime.now().astimezone(), |
| 587 | + session_id="session/001", |
| 588 | + ) |
| 589 | + assert check_session_id_no_slashes(nwbfile) == InspectorMessage( |
| 590 | + message=( |
| 591 | + "The session_id 'session/001' contains slash character(s) '/', which can cause problems " |
| 592 | + "when constructing paths in DANDI. Please replace slashes with another character (e.g., '-' or '_')." |
| 593 | + ), |
| 594 | + importance=Importance.BEST_PRACTICE_VIOLATION, |
| 595 | + check_function_name="check_session_id_no_slashes", |
| 596 | + object_type="NWBFile", |
| 597 | + object_name="root", |
| 598 | + location="/", |
| 599 | + ) |
| 600 | + |
| 601 | + |
| 602 | +def test_pass_check_subject_id_no_slashes(): |
| 603 | + subject = Subject(subject_id="subject001") |
| 604 | + assert check_subject_id_no_slashes(subject) is None |
| 605 | + |
| 606 | + |
| 607 | +def test_check_subject_id_with_slashes(): |
| 608 | + subject = Subject(subject_id="subject/001") |
| 609 | + assert check_subject_id_no_slashes(subject) == InspectorMessage( |
| 610 | + message=( |
| 611 | + "The subject_id 'subject/001' contains slash character(s) '/', which can cause problems " |
| 612 | + "when constructing paths in DANDI. Please replace slashes with another character (e.g., '-' or '_')." |
| 613 | + ), |
| 614 | + importance=Importance.BEST_PRACTICE_VIOLATION, |
| 615 | + check_function_name="check_subject_id_no_slashes", |
| 616 | + object_type="Subject", |
| 617 | + object_name="subject", |
| 618 | + location="/general/subject", |
| 619 | + ) |
0 commit comments