Ejemplo n.º 1
0
 def test_delete_note(self):
     test_path = '/questions.note'
     assert _get_note(notes_directory=CONFIG['notes_directory'],
                      path=test_path)
     _delete_note(notes_directory=CONFIG['notes_directory'],
                  note_path=test_path)
     with pytest.raises(ValueError) as e:
         _get_note(notes_directory=CONFIG['notes_directory'],
                   path=test_path)
     assert 'does not exist' in str(e.value)
Ejemplo n.º 2
0
 def test_append_to_note(self):
     test_path = '/todos.note'
     test_content = '## A new section\nwith some more content'
     original_content = _get_note(notes_directory=CONFIG['notes_directory'],
                                  path=test_path)
     _append_to_note(notes_directory=CONFIG['notes_directory'],
                     note_path=test_path,
                     content=test_content,
                     blank_lines=1)
     updated_note = _get_note(notes_directory=CONFIG['notes_directory'],
                              path=test_path)
     assert original_content in updated_note
     assert test_content in updated_note
     assert updated_note == original_content + '\n\n' + test_content
Ejemplo n.º 3
0
    def test_get_note(self):
        test_path = '/section/mixed.note'
        note_content = _get_note(notes_directory=CONFIG['notes_directory'],
                                 path=test_path)

        with open(CONFIG['notes_directory'] + test_path, 'r') as f:
            read_content = f.read()

        assert note_content == read_content

        # Test error handling for invalid notes paths
        with pytest.raises(ValueError) as e:
            _get_note(notes_directory=CONFIG['notes_directory'],
                      path='/doesnt-exist.note')
        assert 'does not exist' in str(e.value)
Ejemplo n.º 4
0
 def test_update_note(self):
     test_path = '/section/mixed.note'
     test_content = 'This note has been replaced!'
     _update_note(notes_directory=CONFIG['notes_directory'],
                  file_path=test_path,
                  content=test_content)
     note_content = _get_note(notes_directory=CONFIG['notes_directory'],
                              path=test_path)
     assert note_content == test_content
Ejemplo n.º 5
0
    def test_create_note(self):
        new_note_path = '/new.note'
        new_note_content = 'This is a new note added via the API'
        _create_note(notes_directory=CONFIG['notes_directory'],
                     note_path=new_note_path,
                     content=new_note_content)
        note_content = _get_note(notes_directory=CONFIG['notes_directory'],
                                 path=new_note_path)
        assert note_content == new_note_content

        # Test handling for specifying a path to an existing note
        with pytest.raises(ValueError) as e:
            _create_note(notes_directory=CONFIG['notes_directory'],
                         note_path='/todos.note',
                         content='test')
        assert 'already exists' in str(e.value)
Ejemplo n.º 6
0
 def test_today_replaced(self):
     sample_note_path = CONFIG['notes_directory'] + '/todos.note'
     content = _get_note(CONFIG['notes_directory'], sample_note_path)
     assert '\\today' not in content
Ejemplo n.º 7
0
 def get_note(self, note_path):
     return _get_note(notes_directory=self.config['notes_directory'],
                      path=note_path)