def setUp(self):
     self.db_context = TestDBContext.db_context
     self.access_note = NotesAccessor(self.db_context)
class NotesAccessorTest(unittest.TestCase):
    def setUp(self):
        self.db_context = TestDBContext.db_context
        self.access_note = NotesAccessor(self.db_context)

    def testConstructor(self):
        assert self.access_note is not None

    def testNoteList(self):
        assert self.access_note.get_note_list().count > 50

    def testGetNote(self):
        first = self.access_note.get_note_list()[0]
        assert self.access_note.get_note(first.id).id == first.id

    def testUpdateNote(self):
        note = self.access_note.get_note_list()[0]
        assert note.notes != "TEST"
        note.notes = "TEST"
        assert self.access_note.update_note(note)
        assert self.access_note.get_note(note.id).notes == "TEST"

    def testInsertNote(self):
        count1 = len(self.access_note.get_note_list())
        assert self.access_note.insert_note(Note(date(2011, 01, 01), date(2011, 01, 03), "testfile", 1, 1)) > 0
        count2 = len(self.access_note.get_note_list())
        assert count2 > count1


    def testDeleteNote(self):
        assert self.access_note.get_note(1) is not None
        assert self.access_note.delete_note(1)
        assert self.access_note.get_note(1) is None


    def testGetCourseNotes(self):
        course_notes = self.access_note.get_course_notes(self.access_note.get_note_list()[0].course_id)
        all_notes = self.access_note.get_note_list()
        assert len(course_notes) > 0
        assert len(course_notes) < len(all_notes)