<s> from unittest import TestCase <EOL> from unittest . mock import MagicMock , patch <EOL> from openslides . users . serializers import UserFullSerializer <EOL> from openslides . utils . rest_api import ValidationError <EOL> class UserCreateUpdateSerializerTest ( TestCase ) : <EOL> def test_validate_no_data ( self ) : <EOL> """<STR_LIT>""" <EOL> serializer = UserFullSerializer ( ) <EOL> data = { } <EOL> with self . assertRaises ( ValidationError ) : <EOL> serializer . validate ( data ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_validate_no_username ( self , generate_username ) : <EOL> """<STR_LIT>""" <EOL> generate_username . return_value = '<STR_LIT>' <EOL> serializer = UserFullSerializer ( ) <EOL> data = { '<STR_LIT>' : '<STR_LIT>' } <EOL> new_data = serializer . validate ( data ) <EOL> self . assertEqual ( new_data [ '<STR_LIT:username>' ] , '<STR_LIT>' ) <EOL> def test_validate_no_username_in_patch_request ( self ) : <EOL> """<STR_LIT>""" <EOL> view = MagicMock ( action = '<STR_LIT>' ) <EOL> serializer = UserFullSerializer ( context = { '<STR_LIT>' : view } ) <EOL> data = { '<STR_LIT>' : '<STR_LIT>' } <EOL> new_data = serializer . validate ( data ) <EOL> self . assertIsNone ( new_data . get ( '<STR_LIT:username>' ) ) </s>
