コード例 #1
0
 def test_NotesApplication_list(self):
     """Tests if the lists method \
     returns a value when the list \
     is empty.
     """
     lists = NotesApplication('John')
     self.assertEqual(False, lists.lists(), msg="Sorry list is empty!")
コード例 #2
0
 def test_NotesApplication_delete3(self):
     """Tests if the delete method \
     returns a False \
     when the list is empty.\
     """
     delete3 = NotesApplication('John')
     self.assertEqual(False, delete3.delete(3), msg="Sorry list is empty")
コード例 #3
0
		def test_notes_create_4(self):
			notes = NotesApplication('Author', 'Test Content1')
			notes.create("Test Content2")
			notes.create("Test Content3")
			notes.create("Test Content4")
			length = len(notes.notes)
			self.assertEqual(length, 4, msg='A new note was not created')
コード例 #4
0
		def test_notes_create_5(self):
			notes = NotesApplication('Author', ['Test Content1', 'Test Content2', 'Test Content3'])
			notes.create("Test Content4")
			notes.create("Test Content5")
			notes.create("Test Content6")
			length = len(notes.notes)
			self.assertEqual(length, 6, msg='A new note was not created')
コード例 #5
0
 def test_NotesApplication_edit2(self):
     """Tests if the delete method \
     returns False \
     when the list is empty.\
     """
     edit2 = NotesApplication('John')
     self.assertEqual(False, edit2.edit(3, "Great"),
                      msg="Sorry list is empty")
コード例 #6
0
 def test_NotesApplication_delete2(self):
     """Tests if the delete method \
     returns False \
     when the ID selected is out of range.
     """
     delete2 = NotesApplication('John')
     delete2.create("Nigeria")
     self.assertEqual(False, delete2.delete(7), msg="Index out of range")
コード例 #7
0
 def test_NotesApplication_edit(self):
     """Tests if the edit method \
     returns True \
     when a note is successfully edited.\
     """
     edit = NotesApplication('John')
     edit.create("Nigeria")
     self.assertEqual(
         "Noted edited successfully!", edit.edit(0, "Wonderful!"))
コード例 #8
0
 def test_NotesApplication_list3(self):
     """Tests if the lists method \
     returns the number of elements \
     contained in the list.
     """
     list3 = NotesApplication('John')
     list3.create("Nigeria")
     list3.create("Andela")
     list3.create("Lagos")
     counter = list3.lists()
     self.assertEqual(counter, 3)
コード例 #9
0
 def test_NotesApplication_search(self):
     """Tests if the search method returns a 'Not found' string."""
     search = NotesApplication('John')
     search.create("Nigeria")
     search.create("Andela")
     self.assertEqual(False, search.search("lists"),
                      msg="Wrong entry! Type a word or text!")
コード例 #10
0
 def test_NotesApplication_delete(self):
     """Tests if the delete method \
     returns a True \
     when a note is successfully deleted\
     """
     delete = NotesApplication('John')
     delete.create("Nigeria")
     delete.create("Andela")
     self.assertEqual("Note successfully deleted!", delete.delete(0))
コード例 #11
0
 def test_NotesApplication_get(self):
     """Tests if the get method \
     returns False \
     when the ID selected is out of range.
     """
     get1 = NotesApplication('John')
     get1.create("Nigeria")
     get1.create("Andela")
     self.assertEqual(False, get1.get(7),
                      msg="Wrong entry! Type a word or text!")
コード例 #12
0
 def test_NotesApplication_list2(self):
     """Tests if the lists method \
     returns the number of elements \
     contained in the list.
     """
     list2 = NotesApplication('John')
     list2.create("Nigeria")
     list2.create("Andela")
     counter = list2.lists()
     self.assertEqual(counter, 2, msg="Successful!")
コード例 #13
0
	def test_single_note(self):
		"""Test that a single note is stored properly"""
		test_notesApp = NotesApplication('',[])
		test_notesApp.create('Four')
		self.assertIn('Four',test_notesApp.notes_list)
コード例 #14
0
	def test_list_content_not_empty(self):
		"""This tests if the notes_list is empty or not"""
		test_if_content= NotesApplication('Dummy Content',[])
		test_list_content_if_empty = test_if_content.list_content()
		self.assertEqual(test_list_content_if_empty, None)
コード例 #15
0
	def test_if_note_id_is_an_integer(self):
		"""Testing if the note id is indeed not an integer"""
		test_if_int = NotesApplication('',[])
		concl = test_if_int.get_note_id(1)
		self.assertEqual(type(concl),str)
		"""This is an expected failure because it was type cast to a string"""
コード例 #16
0
 def test_NotesApplication_create2(self):
     """Tests users inputs correct entry or empty string"""
     create2 = NotesApplication('John')
     self.assertEqual(False,
                      create2.create(""),
                      msg="Wrong entry! Type a word or text!")
コード例 #17
0
		def test_create_with_empty_string(self):
			notes = NotesApplication('Author')
			notes.create('')
			length = len(notes.notes)
			self.assertEqual(length, 0, msg='No String was passed in, A note is not to be created')
コード例 #18
0
		def test_retrieve_notes_valid_index(self):
			notes = NotesApplication('Author')
			notes.create("Test Content")
			note = notes.get(0)
			self.assertEqual(note, "Test Content", msg='Retrieving a note with a valid index should return the correct note')
コード例 #19
0
	def test_result_get_note_using_note_id_is_of_type_string(self):
		obj = NotesApplication('Lolo')
		obj.create('This is Andela')
		note = obj.get_note(0)

		self.assertEqual(True, type(note) is str)
コード例 #20
0
    def test_NotesApplication_create(self):
        """Tests if the create method creates a note."""

        create = NotesApplication('John')
        self.assertEqual(
            "Note created successfully!", create.create(" Nigeria"))
コード例 #21
0
		def test_edit_valid_index(self):
			author_notes = NotesApplication('New Author', ["Test Content1", "Test Content2", "Test Content3"])
			author_notes.edit(1, "Test Content4")
			notes_list = author_notes.list()
			self.assertListEqual(notes_list, ["Test Content1", "Test Content4", "Test Content3"], msg='Edit should alter supplied index in the notes list')
コード例 #22
0
		def test_edit_invalid_index1(self):
			author_notes = NotesApplication('New Author', ["Test Content1", "Test Content2", "Test Content3"])
			author_notes.edit(-3, "Test Content4")
			notes_result = author_notes.list()
			self.assertTrue(notes_result, msg='Delete should return True for a negative Invalid Index')
コード例 #23
0
		def test_list_notes(self):
			author_notes = NotesApplication('New Author', ["Test Content1", "Test Content2", "Test Content3"])
			notes_list = author_notes.list()
			self.assertListEqual(notes_list, ["Test Content1", "Test Content2", "Test Content3"], msg='list() should return all created notes')
コード例 #24
0
		def test_notes_create_3(self):
			notes = NotesApplication('Author')
			notes.create("Test Content")
			length = len(notes.notes)
			self.assertEqual(length, 1, msg='A new note was not created')
コード例 #25
0
		def test_search_notes(self):
			author_notes = NotesApplication('New Author', ["Test Content1", "Test Content2", "Test Content3"])
			notes_list = author_notes.search("Content")
			self.assertListEqual(notes_list, ["Test Content1", "Test Content2", "Test Content3"], msg='search should return all notes with search string')
コード例 #26
0
	def test_author_name_if_string(self):
		"""Testing if name is a string"""
		exampleClass = NotesApplication('Kunene',[])
		self.assertEqual(type(exampleClass.author_name),str)
コード例 #27
0
		def test_delete_valid_index(self):
			author_notes = NotesApplication('New Author', ["Test Content1", "Test Content2", "Test Content3"])
			author_notes.delete(2)
			notes_length = len(author_notes.notes)
			self.assertEqual(notes_length, 2, msg='Delete should reduce the size of the list')
コード例 #28
0
		def test_retrieve_notes_invalid_index(self):
			author_notes = NotesApplication('New Author', "Test Content1")
			author_note = author_notes.get(-10)
			self.assertEqual(author_note, "Invalid Index", msg='Retrieving a note with Invalid Index should fail')
コード例 #29
0
	def test_if_author_name_is_in_existence_when_object_is_instantiated(self):
		"""Testing if name is accessible"""
		exampleClass2 = NotesApplication('Kunene',[])
		self.assertEqual(exampleClass2.author_name,'Kunene')
コード例 #30
0
		def test_list_notes1(self):
			author_notes = NotesApplication('New Author', [])
			notes_list = author_notes.list()
			self.assertListEqual(notes_list, [], msg='list() should return empty list when not instantiated')
コード例 #31
0
	def test_if_author_name_is_not_an_integer_explicitly(self):
		'''Explicit test to conirm that the author name is not an integer Explicitly'''
		exampleClass3 = NotesApplication('Wambugu',[])
		self.assertNotEqual(type(exampleClass3.author_name),int)
コード例 #32
0
		def test_search_notes1(self):
			author_notes = NotesApplication('New Author', ["Test Content1", "Test Content2", "Test Content3"])
			notes_list = author_notes.search("Content4")
			self.assertListEqual(notes_list, [], msg='search should return an empty array when no text is found in any notes')
コード例 #33
0
	def test_note_instance(self):
		exampleClass4 = NotesApplication('WALALO',['This is my fifth note probably'])
		self.assertIsInstance(exampleClass4, NotesApplication, msg='The object should be an instance of the `NotesApplication class')
コード例 #34
0
		def test_delete_invalid_index(self):
			author_notes = NotesApplication('New Author', ["Test Content1", "Test Content2", "Test Content3"])
			delete_result = author_notes.delete(4)
			self.assertTrue(delete_result, msg='Delete should return True for a wrong index')
コード例 #35
0
	def test_object_type(self):
		exampleclass5 = NotesApplication('This is my sixth note',[])
		self.assertTrue((type(exampleclass5) is NotesApplication), msg='The object should be a type of `NotesApplication`')