How to use dump_object method in autotest

Best Python code snippet using autotest_python

serializers.py

Source:serializers.py Github

copy

Full Screen

...5from websockets.room_chat_constants import *6from websockets.private_chat_constants import *7from websockets.models import UnreadChatRoomMessages8class LazyStudentProgressEncoder(Serializer):9 def get_dump_object(self, obj):10 dump_object = {}11 dump_object.update({'student_id': int(obj.user.id)})12 dump_object.update({'username': str(obj.user.username)})13 dump_object.update({'full_name': str(obj.user.full_name)})14 if obj.initial_assessment:15 dump_object.update({'has_assessment': str("Yes")})16 else:17 dump_object.update({'has_assessment': str("No")})18 dump_object.update({'starting': str(obj.starting)})19 dump_object.update({'current': str(obj.current)})20 dump_object.update({'last_assessed': str(obj.last_assessed)})21 # print(dump_object)22 return dump_object23class LazyProfileEncoder(Serializer):24 def get_dump_object(self, obj):25 dump_object = {}26 dump_object.update({'member_id': int(obj.user.id)})27 dump_object.update({'username': str(obj.user.username)})28 dump_object.update({'role': str(obj.user.role.name)})29 dump_object.update({'full_name': str(obj.user.full_name)})30 dump_object.update({'email': str(obj.user.email)})31 session_status = obj.user.session_status32 33 if obj.user.role.name == "Staff":34 profile = obj.user.staff_profile35 dump_object.update({'phone': str(profile.contact_number)})36 dump_object.update({'match_needed': str("No")})37 dump_object.update({'scheduled_buddy': str("None")})38 dump_object.update({'gender': str(profile.gender)})39 dump_object.update({'p_lang': str(profile.primary_lang)})40 dump_object.update({'s_lang': str(profile.secondary_lang)})41 dump_object.update({'created': calculate_timestamp(profile.date_created)})42 dump_object.update({'updated': calculate_timestamp(profile.last_updated)})43 elif obj.user.role.name == "Volunteer":44 profile = obj.user.volunteer_profile45 dump_object.update({'phone': str(profile.contact_number)})46 if profile.match_needed:47 match_str = "Yes"48 sch_buddy_str = dump_object.update({'scheduled_buddy': str("None")})49 else:50 match_str = "No"51 sch_buddy_str = dump_object.update({'scheduled_buddy': str(session_status.scheduled_match.student.full_name)})52 dump_object.update({'match_needed': str(match_str)})53 dump_object.update({'gender': str(profile.gender)})54 dump_object.update({'p_lang': str(profile.primary_lang)})55 dump_object.update({'s_lang': str(profile.secondary_lang)})56 dump_object.update({'created': calculate_timestamp(profile.date_created)})57 dump_object.update({'updated': calculate_timestamp(profile.last_updated)})58 if profile.scheduled_day_time_slots.all().count() != 0:59 slots = profile.scheduled_day_time_slots.all()60 s = LazySessionSlotEncoder()61 dump_object.update({'slots': s.serialize(slots)})62 else:63 dump_object.update({'slots': str("No Scheduled Slots")})64 65 elif obj.user.role.name == "Student":66 profile = obj.user.student_profile67 dump_object.update({'phone': str(profile.contact_number)})68 dump_object.update({'person': str(profile.contact_person)})69 if profile.match_needed:70 match_str = "Yes"71 sch_buddy_str = dump_object.update({'scheduled_buddy': str("None")})72 else:73 match_str = "No"74 sch_buddy_str = dump_object.update({'scheduled_buddy': str(session_status.scheduled_match.volunteer.full_name)})75 dump_object.update({'match_needed': str(match_str)})76 dump_object.update({'gender': str(profile.gender)})77 dump_object.update({'p_lang': str(profile.primary_lang)})78 dump_object.update({'s_lang': str(profile.secondary_lang)})79 dump_object.update({'school': str(profile.school)})80 dump_object.update({'grade': str(profile.grade)})81 dump_object.update({'created': calculate_timestamp(profile.date_created)})82 dump_object.update({'updated': calculate_timestamp(profile.last_updated)})83 if profile.scheduled_day_time_slots.all().count() != 0:84 slots = profile.scheduled_day_time_slots.all()85 s = LazySessionSlotEncoder()86 dump_object.update({'slots': s.serialize(slots)})87 else:88 dump_object.update({'slots': str("No Scheduled Slots")})89 90 # print(dump_object)91 return dump_object92class LazySessionSlotEncoder(Serializer):93 def get_dump_object(self, obj):94 dump_object = {}95 dump_object.update({'slot': str(obj.get_name_time())})96 # print(dump_object)97 return dump_object98class LazyMatchStatusEncoder(Serializer):99 def get_dump_object(self, obj):100 dump_object = {}101 dump_object.update({'match_status_id': int(obj.id)})102 dump_object.update({'get_type': str(obj.get_type())})103 dump_object.update({'match_status_active': bool(obj.match_status_active)})104 dump_object.update({'session_id': int(obj.session.id)})105 dump_object.update({'session_slot': str(obj.session.day_time.session_slot)})106 dump_object.update({'student_id': int(obj.get_student().id)})107 dump_object.update({'student_online': bool(obj.get_student().session_status.logged_in)})108 dump_object.update({'display_student_location': bool(obj.display_student_location)})109 dump_object.update({'buddy_id': int(obj.get_buddy().id)})110 dump_object.update({'buddy_online': bool(obj.get_buddy().session_status.logged_in)})111 dump_object.update({'display_buddy_location': bool(obj.display_buddy_location)})112 if obj.get_student().session_status.room:113 dump_object.update({'student_location': str(obj.get_student().session_status.room.id)})114 if obj.get_buddy().session_status.room:115 dump_object.update({'teacher_location': str(obj.get_buddy().session_status.room.id)})116 if(obj.match_type):117 dump_object.update({'match_type': str(obj.match_type.name)})118 else:119 dump_object.update({'match_type': "Broken"})120 dump_object.update({'complete': bool(obj.both_online)})121 dump_object.update({'status': str(obj.status.name)})122 if obj.match_type.name == "Temporary":123 dump_object.update({'student_username': str(obj.temp_match.student_user.username)})124 dump_object.update({'student_full_name': str(obj.temp_match.student_user.full_name)})125 # if obj.temp_match.student_user.session_status.room:126 # dump_object.update({'student_location': str(obj.temp_match.student_user.session_status.room.id)})127 dump_object.update({'teacher_username': str(obj.temp_match.teacher_user.username)})128 dump_object.update({'teacher_full_name': str(obj.temp_match.teacher_user.full_name)})129 # if obj.temp_match.teacher_user.session_status.room:130 # dump_object.update({'teacher_location': str(obj.temp_match.teacher_user.session_status.room.id)})131 # print(dump_object)132 return dump_object133class LazySessionStatusEncoder(Serializer):134 def get_dump_object(self, obj):135 dump_object = {}136 dump_object.update({'member_id': int(obj.user.id)})137 dump_object.update({'username': str(obj.user.username)})138 dump_object.update({'role': str(obj.user.role.name)})139 dump_object.update({'full_name': str(obj.user.full_name)})140 dump_object.update({'needs_match': bool(obj.needs_session_match)})141 # print(dump_object)142 return dump_object143class LazyHelpEncoder(Serializer):144 def get_dump_object(self, obj):145 dump_object = {}146 dump_object.update({'request_id': int(obj.id)})147 dump_object.update({'from_user_id': int(obj.from_user.id)})148 dump_object.update({'username': str(obj.from_user.username)})149 dump_object.update({'full_name': str(obj.from_user.full_name)})150 dump_object.update({'from_room_id': int(obj.from_room.id)})151 dump_object.update({'from_room': str(obj.from_room.name)})152 dump_object.update({'from_room_slug': str(obj.from_room.slug)})153 dump_object.update({'created': calculate_timestamp(obj.created)})154 dump_object.update({'message': str(obj.message)})155 dump_object.update({'user_message': str(obj.user_message)})156 dump_object.update({'room_url': str(obj.room_url)})157 dump_object.update({'done': bool(obj.done)})158 if obj.visited_by:159 dump_object.update({'visited_by_id': int(obj.visited_by.id)})160 dump_object.update({'visited_by_username': str(obj.visited_by.username)})161 dump_object.update({'visited_by_full_name': str(obj.visited_by.full_name)})162 dump_object.update({'visited_time': calculate_timestamp(obj.visited_time)})163 # print(dump_object)164 return dump_object165class LazyRedirectEncoder(Serializer):166 def get_dump_object(self, obj):167 dump_object = {}168 dump_object.update({'redirect_id': int(obj.id)})169 dump_object.update({'user_to_redirect_id': int(obj.user_to_redirect.id)})170 dump_object.update({'user_to_redirect_name': str(obj.user_to_redirect.full_name)})171 dump_object.update({'to_room_id': int(obj.to_room.id)})172 dump_object.update({'to_room_name': str(obj.to_room.name)})173 dump_object.update({'to_room_slug': str(obj.to_room.slug)})174 dump_object.update({'redirect_url': str(obj.redirect_url)})175 return dump_object176class LazyPrivateRoomEncoder(Serializer):177 def get_dump_object(self, obj):178 dump_object = {}179 dump_object.update({'private_room_id': int(obj.id)})180 dump_object.update({'user1_id': int(obj.user1.id)})181 dump_object.update({'user1_name': str(obj.user1.full_name)})182 dump_object.update({'user1_unread': int(obj.unread_count_by_user(obj.user1))})183 dump_object.update({'user2_id': int(obj.user2.id)})184 dump_object.update({'user2_name': str(obj.user2.full_name)})185 dump_object.update({'user2_unread': int(obj.unread_count_by_user(obj.user2))})186 dump_object.update({'total': int(obj.total_message_count())})187 return dump_object188class LazyRoomParticipantsEncoder(Serializer):189 def get_dump_object(self, obj):190 dump_object = {}191 dump_object.update({'room_id': int(obj.id)})192 dump_object.update({'room_name': str(obj.name)})193 dump_object.update({'room_slug': str(obj.slug)})194 dump_object.update({'room_row': "room_" + str(obj.id)})195 dump_object.update({'occupied': bool(obj.occupied)})196 dump_object.update({'count': int(obj.num_participants)})197 participants = obj.participants.all()198 s = LazyMeetingParticipantsEncoder()199 dump_object.update({'participants': s.serialize(participants)})200 return dump_object201class LazyMeetingParticipantsEncoder(Serializer):202 def get_dump_object(self, obj):203 dump_object = {}204 dump_object.update({'member_id': str(obj.id)})205 dump_object.update({'username': str(obj.username)})206 dump_object.update({'role': str(obj.role.name)})207 dump_object.update({'full_name': str(obj.full_name)})208 dump_object.update({'needs_match': bool(obj.session_status.needs_session_match)})209 # print(dump_object)210 return dump_object211class LazyRoomUnreadEncoder(Serializer):212 def get_dump_object(self, obj):213 dump_object = {}214 dump_object.update({'userID': int(obj.id)})215 if obj.unread_user:216 dump_object.update({'unread_count': int(obj.unread_user.unread_count)})217 # print(dump_object)218 return dump_object219 220class LazyJitsiRoomChatMessageEncoder(Serializer):221 def get_dump_object(self, obj):222 dump_object = {}223 dump_object.update({'msg_type': JITSI_MSG_TYPE_MESSAGE})224 dump_object.update({'msg_id': int(obj.id)})225 dump_object.update({'user_id': int(obj.user.id)})226 dump_object.update({'username': str(obj.user.username)})227 dump_object.update({'full_name': str(obj.user.full_name)})228 dump_object.update({'message': str(obj.content)})229 dump_object.update({'meeting_room_id': int(obj.meeting_room.id)})230 dump_object.update({'meeting_room_name': str(obj.meeting_room.name)})231 dump_object.update({'natural_timestamp': calculate_timestamp(obj.timestamp)})232 dump_object.update({'date_time': calculate_date_time(obj.timestamp)})233 dump_object.update({'display': bool(obj.display)})234 return dump_object235class LazyStaffRoomChatMessageEncoder(Serializer):236 def get_dump_object(self, obj):237 dump_object = {}238 dump_object.update({'msg_type': STAFF_MSG_TYPE_MESSAGE})239 dump_object.update({'msg_id': int(obj.id)})240 dump_object.update({'user_id': int(obj.user.id)})241 dump_object.update({'username': str(obj.user.username)})242 dump_object.update({'full_name': str(obj.user.full_name)})243 dump_object.update({'message': str(obj.content)})244 dump_object.update({'meeting_room_id': int(obj.meeting_room.id)})245 dump_object.update({'meeting_room_name': str(obj.meeting_room.name)})246 dump_object.update({'natural_timestamp': calculate_timestamp(obj.timestamp)})247 dump_object.update({'date_time': calculate_date_time(obj.timestamp)})248 return dump_object249class LazyStaffEncoder(Serializer):250 def get_dump_object(self, obj):251 dump_object = {}252 dump_object.update({'userID': int(obj.id)})253 dump_object.update({'staff_unread_count': int(obj.unread_staff.unread_count)})254 # print(dump_object)255 return dump_object256class LazyPrivateRoomChatMessageEncoder(Serializer):257 def get_dump_object(self, obj):258 dump_object = {}259 dump_object.update({'msg_type': PRIVATE_MSG_TYPE_MESSAGE})260 dump_object.update({'msg_id': str(obj.id)})261 dump_object.update({'user_id': str(obj.user.id)})262 dump_object.update({'username': str(obj.user.username)})263 if obj.user.session_status.room:264 dump_object.update({'in_room_id': str(obj.user.session_status.room.id)})265 dump_object.update({'in_room_name': str(obj.user.session_status.room.name)})266 dump_object.update({'in_room_slug': str(obj.user.session_status.room.slug)})267 dump_object.update({'message': str(obj.content)})268 dump_object.update({'natural_timestamp': calculate_timestamp(obj.timestamp)})269 return dump_object270class LazyCustomUserEncoder(Serializer):271 def get_dump_object(self, obj):272 # print(obj.session_status.room)273 dump_object = {}274 dump_object.update({'user_id': str(obj.id)})275 dump_object.update({'username': str(obj.username)})276 dump_object.update({'role': str(obj.role.name)})277 dump_object.update({'full_name': str(obj.full_name)})278 if obj.session_status.room:279 dump_object.update({'location_id': str(obj.session_status.room.id)}) 280 dump_object.update({'location_name': str(obj.session_status.room.name)}) 281 dump_object.update({'location_slug': str(obj.session_status.room.slug)}) 282 # print(dump_object)283 return dump_object284class LazyJitsiMeetingParticipantsEncoder(Serializer):285 def get_dump_object(self, obj):286 dump_object = {}287 dump_object.update({'room_id': int(obj.id)})288 dump_object.update({'room_name': str(obj.name)})289 dump_object.update({'occupied': bool(obj.occupied)})290 dump_object.update({'count': int(obj.num_participants)})291 dump_object.update({'jitsi_count': int(obj.jitsi_num_participants)})292 participants = obj.participants.all()293 s = LazyMeetingParticipantsEncoder()294 dump_object.update({'participants': s.serialize(participants)})295 jitsi_participants = obj.jitsi_participants.all()296 s = LazyMeetingParticipantsEncoder()297 dump_object.update({'jitsi_participants': s.serialize(jitsi_participants)})...

Full Screen

Full Screen

utils.py

Source:utils.py Github

copy

Full Screen

...7 1. FriendRequest8 2. FriendList9 3. UnreadChatRoomMessage10 """11 def get_dump_object(self, obj):12 dump_object = {}13 if obj.get_content_object_type() == "FriendRequest":14 dump_object.update({'notification_type': obj.get_content_object_type()})15 dump_object.update({'notification_id': str(obj.pk)})16 dump_object.update({'verb': obj.verb})17 dump_object.update({'is_active': str(obj.content_object.is_active)})18 dump_object.update({'is_read': str(obj.read)})19 dump_object.update({'natural_timestamp': str(naturaltime(obj.timestamp))})20 dump_object.update({'timestamp': str(obj.timestamp)})21 dump_object.update({22 'actions': {23 'redirect_url': str(obj.redirect_url),24 },25 "from": {...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful