This repository has been archived by the owner on Jan 29, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#280] Parse registration_date from ICTRP (#51)
- Loading branch information
1 parent
6b15ccf
commit 868ccbc
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
|
||
import copy | ||
import datetime | ||
import pytest | ||
import processors.ictrp.extractors as extractors | ||
|
||
|
||
class TestICTRPExtractors(object): | ||
STUB_RECORD = { | ||
'register': 'ClinicalTrials.gov', | ||
'main_id': 'NCT0000000', | ||
'public_title': 'Public title', | ||
'scientific_title': 'Scientific title', | ||
'target_sample_size': 100, | ||
'study_type': 'study_type', | ||
'study_design': 'study design', | ||
'study_phase': 'study phase', | ||
'primary_outcomes': 'primary outcomes', | ||
'secondary_outcomes': 'secondary outcomes', | ||
'key_inclusion_exclusion_criteria': 'key inclusion exclusion criteria', | ||
} | ||
|
||
@pytest.mark.parametrize('date_str,expected_date', [ | ||
('2012-12-31', datetime.date(2012, 12, 31)), | ||
('31/12/2012', datetime.date(2012, 12, 31)), | ||
('2012-05-01', datetime.date(2012, 5, 1)), | ||
('01/05/2012', datetime.date(2012, 5, 1)), | ||
('invalid', None), | ||
('', None), | ||
]) | ||
def test_extract_trial_handles_dates(self, date_str, expected_date): | ||
record = copy.deepcopy(self.STUB_RECORD) | ||
record['date_of_registration'] = date_str | ||
|
||
trial = extractors.extract_trial(record) | ||
|
||
assert trial.get('registration_date') == expected_date |