def test_get_boards(self): # Initializing BoardService board_service = BoardService("test") # Creating a board board_service.create_board(self.board, self.headers) # Retrieving boards response = board_service.get_boards(self.headers) # Validating the response assert isinstance(response, list) self.assertGreaterEqual(len(response), 1)
def setUp(self): # Initializing Service and invoking register(...) user_service = UserService("test") user = user_service.register({ "email": "*****@*****.**", "name": "John", "password": "******", "confirmPassword": "******", "phone": "+11231231231" }) self.user_id = user.user_id self.headers['Authorization'] = self.__get_jwt_token(user.user_id) self.board = {'name': 'board1', "color": "#fefefe"} # Initializing BoardService and creating board board_service = BoardService("test") response = board_service.create_board(self.board, self.headers) self.board_id = response.board_id # Initializing SwimLaneService and creating a swim lane swim_lane_service = SwimLaneService("test") self.swim_lane = { "title": "todo", "boardId": self.board_id, "position": "0" } response = swim_lane_service.create_swim_lane(self.swim_lane, self.headers)
def test_create_board(self): # Initializing BoardService and creating board board_service = BoardService("test") response = board_service.create_board(self.board, self.headers) # Validating the response assert isinstance(response, Board) assert response.user_id is not None
def test_create_board_with_invalid_authorization(self): # Initializing BoardService and creating board board_service = BoardService("test") headers = {} headers['Authorization'] = "somerandomstringhere" response = board_service.create_board(self.board, headers) # Validating the response assert isinstance(response, str) self.assertEqual(response, "Invalid Authorization")
def createBoard(): try: # Fetching data from post body data = request.json headers = request.headers # Invoking create_board method present in services board_service = BoardService() response = board_service.create_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
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