예제 #1
0
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")
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
 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
예제 #5
0
 def test_wrong_type(self):
     assert boe.is_valid_diary_entry_id(dict()) == False
예제 #6
0
 def test_none(self):
     assert boe.is_valid_diary_entry_id(None) == False