Exemplo n.º 1
0
 def test_create_event(self, event):
     event_controller = EventController()
     
     # Mocking upload inside EventController
     event_controller.upload_service = Mock()
     
     result = event_controller.create(event)
     assert result is True
Exemplo n.º 2
0
    def test_create_event_with_none(self):
        event_controller = EventController()

        # Mocking db inside EventController
        event_controller.db = Mock()
        event_controller.upload_service = Mock()

        result = event_controller.create(None)
        assert result is False
Exemplo n.º 3
0
    def test_create_event_with_upload_service_error(self, event):
        event_controller = EventController()

        event_controller.db = Mock()

        event_controller.upload_service = Mock()
        event_controller.upload_service.upload_from_url.side_effect = Exception

        result = event_controller.create(event.__dict__)
        assert result == (False, ConnectionRefusedError)
Exemplo n.º 4
0
    def test_create_event_with_db_connection_error(self, event):
        event_controller = EventController()
        event_controller.db = Mock()
        event_controller.db.insert.side_effect = Exception

        event_controller.upload_service = Mock()

        result, excp = event_controller.create(event.__dict__)
        assert result == False
        assert excp == ConnectionError