Best Python code snippet using localstack_python
test_node_stepwise.py
Source:test_node_stepwise.py
...61def test_round_step():62 node.advance_round()63 node.compute_leader()64 leader.propose()65 noleader.receive_messages()66 noleader.process_message() # acks are sent here67 assert noleader.phase == Phase.Acknowledge68 node.receive_messages()69 for n in noleader:70 assert len(n._message_queue) == N - 271 assert len(leader._message_queue) == N - 172 node.process_messages() # confirms are sent here73 node.receive_messages()74 node.process_messages()75def test_2rounds_step():76 node.advance_round()77 node.compute_leader()78 leader.propose()79 node.receive_messages()80 node.process_messages() # sends out acks81 node.receive_messages()82 node.process_messages() # sends out confirms83 node.receive_messages()84 node.process_messages()85 # all nodes have beacon and confirmation certificate here86 node.advance_round()87 node.compute_leader()88 assert node.leader.all_equal89 assert node.round == 290 leader.propose()91 node.receive_messages()92 node.process_messages()93def test_run_round():94 threads = [Thread(target=n.run_round) for n in nodes]95 for t in threads:96 t.start()97 for t in threads:98 t.join()99 assert node.beacon.all_equal100 assert node.beacon is not None101 for cc in node.confirmation_certificate:102 assert cc is not None103def test_recover_first_round():104 node.advance_round()105 node.compute_leader()106 leader.compute_beacon(leader.shared_secret)107 node.update_phase()108 noleader.recover()109 noleader.receive_messages()110 noleader.process_messages()...
test_init.py
Source:test_init.py
...13 yield fixtures['not-forwarded']14expect_yes = {'20140303035053.GA18216': ('20140303035053.GA18216', 1393818653.0, 'aoeuaoeu', 'oeu\r\n')}15expect_no = {}16def test_no_target():17 observed = receive_messages('not host', 'not address', 'not password',18 mailbox = forwarded)19 n.assert_equal(observed, expect_yes)20def test_target_dict():21 observed = {}22 receive_messages('not host', 'not address', 'not password',23 target = observed,24 mailbox = forwarded)25 n.assert_equal(observed, expect_yes)26def test_forwarded_set_match():27 observed = receive_messages('not host', 'not address', 'not password',28 forwarding_address = 'forwarding@thomaslevine.com',29 mailbox = forwarded)30 n.assert_equal(observed, expect_yes)31 observed = receive_messages('not host', 'not address', 'not password',32 forwarding_address = 'forwarding@thomaslevine.com',33 mailbox = not_forwarded)34 n.assert_equal(observed, expect_no)35def test_forwarded_set_nomatch():36 observed = receive_messages('not host', 'not address', 'not password',37 forwarding_address = 'blah@thomaslevine.com',38 mailbox = forwarded)39 n.assert_equal(observed, expect_no)40def test_forwarded_notset():41 observed = receive_messages('not host', 'not address', 'not password',42 forwarding_address = None,43 mailbox = forwarded)44 n.assert_equal(observed, expect_yes)45 observed = receive_messages('not host', 'not address', 'not password',46 forwarding_address = None,47 mailbox = not_forwarded)48 n.assert_equal(observed, expect_yes)49def test_sending():50 observed = receive_messages('not host', 'not address', 'not password',51 sending_address = 'sending@thomaslevine.com',52 mailbox = not_forwarded)53 n.assert_equal(observed, expect_yes)54 observed = receive_messages('not host', 'not address', 'not password',55 sending_address = None,56 mailbox = not_forwarded)57 n.assert_equal(observed, expect_yes)58 observed = receive_messages('not host', 'not address', 'not password',59 sending_address = 'incorrect@thomaslevine.com',60 mailbox = forwarded)...
get_messages.py
Source:get_messages.py
1#-*-coding:utf-8-*-2from django.shortcuts import render,redirect,get_object_or_4043from django.http import HttpResponse4from django.contrib.auth import authenticate, login5from django.contrib.auth.decorators import login_required6from ..models import Member_Model,Chat_Model7from django.core.files.storage import default_storage8from django.conf import settings9from django.core.files.base import ContentFile10import os11from django.core import serializers12import json13@login_required(login_url="/mysite/login/")14def get_messages(request,contacter):15 get_email = request.user.username16 print contacter17 receiver = get_object_or_404(Member_Model,email=get_email)18 sender = get_object_or_404(Member_Model,email=contacter)19 receive_messages = Chat_Model.objects.filter(msg_to=receiver,msg_from=sender)20 send_messages = Chat_Model.objects.filter(msg_to=sender, msg_from=receiver)21 for message in receive_messages:22 print message.read_status #change it to true23 receive_messages = serializers.serialize("json", receive_messages)24 send_messages = serializers.serialize("json", send_messages)25 #print receive_messages26 #print send_messages27 return HttpResponse(json.dumps({'receive_messages':receive_messages,...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!