How to check the param added

Gahyun Son - Oct 18 - - Dev Community
  1. Create board
  2. Add param
  3. Check the param in the board
def test(self):
        board = create_board(user=self.user, title='Sunday Roast secret')
        com = Command.objects.create(user=self.user, content='So interesting')
        board.commands.add(com)

        params = {'commands': f'{com.id}'}
        res = self.client.get(BOARD_URL, params)

        b1 = BoardSerializer(board)
        self.assertIn(b1.data, res.data)
Enter fullscreen mode Exit fullscreen mode

board

Sunday Roast secret
Enter fullscreen mode Exit fullscreen mode

b1

BoardSerializer(<Board: Sunday Roast secret>): 
id = IntegerField(label='ID', read_only=True) 
title = CharField(max_length=255)
tags = TagSerializer(many=True, required=False):
id = IntegerField(label='ID', read_only=True)
name = CharField(max_length=255)
commands = CommandSerializer(...)
Enter fullscreen mode Exit fullscreen mode

You can user serializer to get the data.

. .
Terabox Video Player