コード例 #1
0
    def test_get_with_valid_index(self):
        """test normal get behaviour
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertEqual(note_app.get(0), "Note 0", msg="Incorrect get method")
コード例 #2
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_search_finds_matches(self):
     test = NotesApplication("test")
     test.create("emeka is a boy")
     appOutput = ("showing results for emeka"
                  "Note ID: 0\nemeka is a boy\nBy Author test\n")
     with capture(test.search, "emeka") as output:
         self.assertEqual(appOutput, output, msg="search() method does not find matches")
コード例 #3
0
    def test_create_with_list(self):
        """test if a list can be used to create a note
        """
        note_app = NotesApplication("Ben")
        note_app.create([1, 2])

        self.assertListEqual(note_app.notes, [[1, 2]],
                             msg="incorrect notes attribute after create")
コード例 #4
0
    def test_create_with_int(self):
        """test if an int can be added as a note
        """
        note_app = NotesApplication("Ben")
        note_app.create(1)

        self.assertListEqual(note_app.notes, [1],
                             msg="incorrect notes attribute after create")
コード例 #5
0
    def test_get_with_invalid_index(self):
        """test get with bad parameters
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertEqual(note_app.get(10), None,
                         msg="Invalid index should return None")
コード例 #6
0
    def test_create_with_string2(self):
        """test if the notes list has the correct value
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertListEqual(note_app.notes, ["Note 0"],
                             msg="incorrect notes attribute after create")
コード例 #7
0
    def test_edit_with_valid_parameters(self):
        """test for normal edit behaviour
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertTrue(note_app.edit(0, "New Note 0"),
                        msg="edit was unsuccessful")
コード例 #8
0
    def test_create_with_string(self):
        """test whether adding a note works
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertEqual(len(note_app.notes), 1,
                         msg="notes not added correctly")
コード例 #9
0
    def test_create_with_string2(self):
        """test if the notes list has the correct value
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertListEqual(note_app.notes, ["Note 0"],
                             msg="incorrect notes attribute after create")
コード例 #10
0
    def test_edit_with_bad_index(self):
        """test if edit recongnizes bad indexes
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertFalse(note_app.edit(10, "New Note 0"),
                         msg="edit was unsuccessful")
コード例 #11
0
    def test_edit_with_bad_index(self):
        """test if edit recongnizes bad indexes
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertFalse(note_app.edit(10, "New Note 0"),
                         msg="edit was unsuccessful")
コード例 #12
0
    def test_edit_with_valid_parameters(self):
        """test for normal edit behaviour
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertTrue(note_app.edit(0, "New Note 0"),
                        msg="edit was unsuccessful")
コード例 #13
0
    def test_get_with_non_int_index(self):
        """test get with bad parameters
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertEqual(note_app.get(""), None,
                         msg="string index should return None")
コード例 #14
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_get_with_nonexistent_index(self):
     test = NotesApplication("test")
     test.create("emeka is a boy")
     test.create(1)
     test.create(4)
     appOutput = "The index you entered does not exist\n"
     with capture(test.get, 8) as output:
         self.assertEqual(appOutput, output, msg="get() method does not handle entry of invalid indices appropriately")
コード例 #15
0
    def test_create_with_int(self):
        """test if an int can be added as a note
        """
        note_app = NotesApplication("Ben")
        note_app.create(1)

        self.assertListEqual(note_app.notes, [1],
                             msg="incorrect notes attribute after create")
コード例 #16
0
    def test_get_with_valid_index(self):
        """test normal get behaviour
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertEqual(note_app.get(0), "Note 0",
                         msg="Incorrect get method")
コード例 #17
0
    def test_create_with_list(self):
        """test if a list can be used to create a note
        """
        note_app = NotesApplication("Ben")
        note_app.create([1, 2])

        self.assertListEqual(note_app.notes, [[1, 2]],
                             msg="incorrect notes attribute after create")
コード例 #18
0
    def test_create_with_string(self):
        """test whether adding a note works
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertEqual(len(note_app.notes),
                         1,
                         msg="notes not added correctly")
コード例 #19
0
    def test_get_with_invalid_index(self):
        """test get with bad parameters
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertEqual(note_app.get(10),
                         None,
                         msg="Invalid index should return None")
コード例 #20
0
    def test_get_with_non_int_index(self):
        """test get with bad parameters
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")

        self.assertEqual(note_app.get(""),
                         None,
                         msg="string index should return None")
コード例 #21
0
    def test_edit_changes_with_tuple(self):
        """test if edit changes the right variable to the right
        value
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")
        note_app.edit(0, (1, 2))

        self.assertEqual(note_app.notes[0], (1, 2),
                         msg="edit value incorrect")
コード例 #22
0
    def test_search(self):
        """Test if search returns the right output"""
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")
        out = "Showing results for search '{0}'\n\n".format("Note")
        args = (0, note_app.notes[0], note_app.author)
        out += "Note ID: {0}\n{1}\n\nBy Author {2}\n\n".format(*args)

        self.assertEqual(note_app.search("Note"), out,
                         msg="searching for a note returns incorrect value")
コード例 #23
0
    def test_list(self):
        """Test the listing of notes
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")
        args = (0, note_app.notes[0], note_app.author)
        expected_out = "Note ID: {0}\n{1}\n\nBy Author {2}\n\n".format(*args)

        self.assertEqual(note_app.list(), expected_out,
                         msg="Listing of notes incorrect")
コード例 #24
0
    def test_search(self):
        """Test if search returns the right output"""
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")
        out = "Showing results for search '{0}'\n\n".format("Note")
        args = (0, note_app.notes[0], note_app.author)
        out += "Note ID: {0}\n{1}\n\nBy Author {2}\n\n".format(*args)

        self.assertEqual(note_app.search("Note"),
                         out,
                         msg="searching for a note returns incorrect value")
コード例 #25
0
    def test_list(self):
        """Test the listing of notes
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")
        args = (0, note_app.notes[0], note_app.author)
        expected_out = "Note ID: {0}\n{1}\n\nBy Author {2}\n\n".format(*args)

        self.assertEqual(note_app.list(),
                         expected_out,
                         msg="Listing of notes incorrect")
コード例 #26
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_list_notes_of_digits(self):
     test = NotesApplication("test")
     test.create(1)
     test.create(2)
     test.create(3)
     appOutput = ("Note ID: 0\n1\nBy Author test\n"
                  "Note ID: 1\n2\nBy Author test\n"
                  "Note ID: 2\n3\nBy Author test\n"
                 )
     with capture(test.list) as output:
         self.assertEqual(appOutput, output, msg="List method doesn't handle a note list of only digits well")
コード例 #27
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_list_five_notes_in_notes(self):
     test = NotesApplication("test")
     test.create("emeka is a boy")
     test.create("chidi is fresh")
     test.create("i am fresh too")
     listoutput = ("Note ID: 0\nemeka is a boy\nBy Author test\n"
                  "Note ID: 1\nchidi is fresh\nBy Author test\n"
                  "Note ID: 2\ni am fresh too\nBy Author test\n"
                 )
     with capture(test.list) as output:
         self.assertEqual(listoutput, output, msg="The list method should print according to the specified format")
コード例 #28
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_get_note_from_end(self):
     test = NotesApplication("test")
     test.create("emeka is boy")
     test.create(1)
     test.create(2)
     test.create("chidi is fresh")
     res  = test.get(3)
     self.assertEqual("chidi is fresh",res , msg="get() method does not return the right value at the last index")
コード例 #29
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_edit_note(self):
     test = NotesApplication("test")
     test.create("emeka is a boy")
     test.create("ada is a girl")
     test.create("Real studio")
     appOutput = ("Note ID: 0\nemeka is boy\nBy Author Erika\n"
                  "Note ID: 1\nchidi is fresh\nBy Author Erika\n"
                  "Note ID: 2\nReal studio\nBy Author Erika\n"
                 )
     test.edit(1, "chidi is fresh")
     with capture(test.list) as output:
         self.assertEqual(appOutput, output, msg="edit() method does not edit note specified by index")
コード例 #30
0
 def test_init_author_variable(self):
     """test whether the author instance variable is set properly
     """
     note_app = NotesApplication("Ben")
     self.assertEqual(note_app.author,
                      "Ben",
                      msg="author attribute is incorrect")
コード例 #31
0
 def test_init_with_dict(self):
     """test what happens when an dictionary is passed to the
     constructor instead
     """
     note_app = NotesApplication({})
     self.assertIsNone(note_app.author,
                       msg="init with dict shouldn't set author variable")
コード例 #32
0
 def test_init_with_int(self):
     """test what happpens when an int is passed to constructor
     instead
     """
     note_app = NotesApplication(2)
     self.assertIsNone(note_app.author,
                       msg="init with int shouldn't set author variable")
コード例 #33
0
 def test_init_with_string(self):
     """test whether the right object is created when the
     constructor is called with a string
     """
     note_app = NotesApplication("")
     self.assertIsInstance(note_app,
                           NotesApplication,
                           msg="init not working")
コード例 #34
0
    def test_edit_changes_with_tuple(self):
        """test if edit changes the right variable to the right
        value
        """
        note_app = NotesApplication("Ben")
        note_app.create("Note 0")
        note_app.edit(0, (1, 2))

        self.assertEqual(note_app.notes[0], (1, 2), msg="edit value incorrect")
コード例 #35
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_for_delete_note(self):
     test = NotesApplication('test')
     test.create('emeka is a boy')
     lenght = len(self.note_name)
     res = (test.delete(0))
     self.assertEqual(res,lenght)
コード例 #36
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_create_two_notes(self):
     test = NotesApplication("test")
     test.create("emeka is a boy")
     test.create("chidi is fresh")
     self.assertEqual(["emeka is a boy", "chidi is fresh"], test.note_name, 
                       msg="The create method should add multiple notes to the same 'notes' property")
コード例 #37
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_list_one_note_in_notes(self):
     test = NotesApplication("test")
     test.create("emeka is a boy")
     listoutput = "Note ID: 0\nemeka is a boy\nBy Author test\n"
     with capture(test.list) as output:
         self.assertEqual(listoutput, output, msg="The list method should print according to the specified format")
コード例 #38
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_get_note_from_begining(self):
     test = NotesApplication("test")
     test.create("emeka is a boy")
     res = test.get(0)
     self.assertEqual("emeka is a boy", res, msg="get() method does not return the right value at 0 index")
コード例 #39
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_search_handles_non_matches(self):
     test = NotesApplication("Erika")
     test.create("emeka is a boy")
コード例 #40
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_for_delete_2(self):
     test = NotesApplication('test')
     res = (test.delete(0))
     appOutput = "No note created\n"
     with capture(res, 0) as output:
         self.assertEqual(appOutput, output, msg="delete() method is supposed to warn user that the note list is empty")
コード例 #41
0
 def test_init_notes_variable(self):
     """test if the notes list is created properly
     """
     note_app = NotesApplication("")
     self.assertListEqual(note_app.notes, [],
                          msg="notes attribute is incorrect")
コード例 #42
0
ファイル: note_app_test.py プロジェクト: texyh/bc-python-xv
 def test_create_one_note(self):
     test = NotesApplication("test")
     test.create("emeka is a boy")
     self.assertEqual(["emeka is a boy"], test.note_name, msg="The class should have a create method adds its argument to a property called notes")