Esempio n. 1
0
    def test_edit_board_with_invalid_authorization(self):
        # Initializing BoardService and editing board
        board_service = BoardService("test")
        headers = {}
        headers['Authorization'] = "somerandomstringhere"
        response = board_service.edit_board(self.board, headers)

        # Validating the response
        assert isinstance(response, str)
        self.assertEqual(response, "Invalid Authorization")
Esempio n. 2
0
def editBoard():
    try:
        # Fetching data from post body
        data = request.json
        headers = request.headers

        # Invoking edit_board method present in services
        board_service = BoardService()
        response = board_service.edit_board(data, headers)

        # Returning appropriate message
        if isinstance(response, Board):
            return jsonpickle.encode(response, unpicklable=False), 200
        else:
            return jsonify({'errorMessage': response}), 500
    except Exception as e:
        return jsonify({'errorMessage': e}), 500
Esempio n. 3
0
    def test_edit_board(self):
        # Initializing BoardService and editing board
        board_service = BoardService("test")
        response = board_service.create_board(self.board, self.headers)
        # Building the board object
        self.board['board_id'] = response.board_id
        self.board['name'] = "new name"
        self.board['description'] = "some description"
        self.board['color'] = "#cccccc"
        self.board['image'] = None

        # Editing the board
        response = board_service.edit_board(self.board, self.headers)

        # Validating the response
        assert isinstance(response, Board)
        assert response.user_id is not None
        self.assertEqual(response.name, "new name")
        self.assertEqual(response.description, "some description")
        self.assertEqual(response.color, "#cccccc")
        self.assertEqual(response.board_id, response.board_id)
        assert response.image is None