Example #1
0
 def test_add(self, mock_method):
     # prepare mock
     mock_method.return_value = Note(5.0, "Kasia")
     # testing
     test_object = NotesService()
     result = test_object.add(Note(5.0, "Kasia"))
     self.assertEqual(Note(5.0, "Kasia").name, result.getName())
Example #2
0
    def test_add_note(self):
        objectStorage = NotesStorage()
        objectStorage.add = MagicMock()
        objectStorage.add.return_value = Note("Maciej", 4.5).note

        test_object = NotesService()
        test_object.notesStorage = objectStorage

        result = test_object.add(Note("Maciej", 4.5))
        self.assertEqual(result, Note("Maciej", 4.5).note)
Example #3
0
 def test_get_all_notes_off(self, mock_method):
     # prepare mock
     mock_method.return_value = [
         Note(5.0, "Marlena"),
         Note(3.5, "Marlena"),
         Note(2.0, "Marlena"),
         Note(4.5, "Marlena")
     ]
     # testing
     test_object = NotesService()
     result = test_object.averageOf("Marlena")
     self.assertEqual(3.75, result)
Example #4
0
    def test_average(self):
        objectStorage = NotesStorage()
        objectStorage.getAllNotesOf = MagicMock()
        objectStorage.getAllNotesOf.return_value = [
            Note("Maciej", 4.0),
            Note("Maciej", 5.0),
            Note("Maciej", 3.0)
        ]

        test_object = NotesService()
        test_object.notesStorage = objectStorage

        result = test_object.averageOf("Maciej")
        self.assertEqual(result, 4)
Example #5
0
 def test_clear(self):
     self.temp.add(Note("filip", 4.5))
     self.temp.add(Note("filip", 3.5))
     self.temp.clear()
     self.temp.notes_storage.notes = []
     self.assertEqual(self.temp.notes_storage.notes, [])
Example #6
0
 def test_add_average_missing_student_exception(self, mock_method):
     mock_method.return_value = []
     self.temp.add(Note("filip", 4.0))
     self.assertRaises(Exception, self.temp.averageOf, "marcin")
Example #7
0
 def test_average(self, mock_method):
     mock_method.return_value = [Note("filip", 4.5), Note("filip", 3.5)]
     self.temp.add(Note("filip", 4.5))
     self.temp.add(Note("filip", 3.5))
     self.temp.add(Note("dio", 3.5))
     self.assertEqual(self.temp.averageOf("filip"), 4.0)
 def test_note(self):
     note = Note(3.5, 'testTwo')
     self.assertEqual(note.getNote(), 3.5)
 def test_name(self):
     note = Note(3.5, 'testOne')
     self.assertEqual(note.getName(), 'testOne')
 def test_note_greater_than_6(self):
     with self.assertRaises(ValueError):
         Note(6.1, 'test')
 def test_note_smaller_than_2(self):
     with self.assertRaises(ValueError):
         Note(1.3, 'test')
 def test_name_empty(self):
     with self.assertRaises(ValueError):
         Note(3.5, '')
 def test_name_None(self):
     with self.assertRaises(TypeError):
         Note(3.5, None)
 def test_name_null(self):
     with self.assertRaises(TypeError):
         Note(3.5)
 def test_note_equal_6(self):
     note = Note(6.0, 'testTwo')
     self.assertEqual(note.getNote(), 6)
 def test_note_equal_2(self):
     note = Note(2.0, 'testTwo')
     self.assertEqual(note.getNote(), 2)