示例#1
0
    def test_update_resources3(self, mocker, test_notebook, test_note_metadata, test_note):
        """
        Test that resources are removed from the database if a note is deleted
        """
        mocker.patch('app.evernote_utils.get_note', return_value=test_note)

        # insert the requisite notebook
        load_notebook(test_notebook)
        db_notebook = Notebook.query.filter_by(guid=test_notebook.guid).first()

        # load the notes and resources into the database
        load_notes(test_note_metadata, db_notebook)

        assert Note.query.first().resources.count() == 1, "Note with one resource should be present in the database"

        # Simulate that we are removing all notes
        delete_notes([], db_notebook)

        assert Resource.query.count() == 0, "Deleting all notes should also remove all resources."
示例#2
0
    def test_delete_notes(self, mocker, test_notebook, test_note_metadata, test_note):
        """
        Test deleting notes.
        """
        mocker.patch('app.evernote_utils.get_note', return_value=test_note)

        # insert the requisite notebook
        load_notebook(test_notebook)
        db_notebook = Notebook.query.filter_by(guid=test_notebook.guid).first()

        # load the notes into the database
        load_notes(test_note_metadata, db_notebook)

        # test that the notes loaded successfully
        db_notes = db_notebook.notes
        assert len(db_notes) == len(test_note_metadata)

        # simulate deleting all notes from the notebook
        test_note_metadata = []
        delete_notes(test_note_metadata, db_notebook)

        # test that the notes have been removed
        assert len(Note.query.all()) == 0