def entry_id_2_output_path(entry_id: str, base_dir: str) -> str: '''Create local filesystem path for the diary entry output.''' if not isinstance(base_dir, str): raise TypeError( f'Expected a str and got a {type(base_dir)} for base_dir.') if not boe.is_valid_diary_entry_id(entry_id): raise ValueError(f"'{entry_id}' is not a valid entry id.") return os.path.join(base_dir, 'diary_entries', f"boe_diary_entry_raw_{entry_id}.xml")
def test_with_spaces(self): assert boe.is_valid_diary_entry_id(' BOE-A-2020-4859') == False assert boe.is_valid_diary_entry_id('BOE-A-2020-4859 ') == False assert boe.is_valid_diary_entry_id('BOE- -2020-13286') == False
def test_invalid(self): assert boe.is_valid_diary_entry_id('BOCYL-A-2020-4859') == False assert boe.is_valid_diary_entry_id('BOE-B-2020') == False assert boe.is_valid_diary_entry_id('BOE-A-2020123') == False assert boe.is_valid_diary_entry_id('BOE-2-2020-13286') == False
def test_valid(self): assert boe.is_valid_diary_entry_id('BOE-A-2020-4859') == True assert boe.is_valid_diary_entry_id('BOE-B-2020-13286') == True
def test_wrong_type(self): assert boe.is_valid_diary_entry_id(dict()) == False
def test_none(self): assert boe.is_valid_diary_entry_id(None) == False