Skip to content

Commit

Permalink
Added a couple more simple tests for the cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
janton01 committed Dec 17, 2016
1 parent 38378dc commit d15a17c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, gameTraffic, location, timeout, num_players):
self.timeMS = 0
self.timeout = timeout

def updateTime(self, time): # is this how it works?
def updateTime(self, time):
self.timeMS = time
return self.processResponse(time)

Expand All @@ -47,6 +47,6 @@ def processResponse(self, time):
else:
return None

def receiveRequest(self, packet): # can this access
def receiveRequest(self, packet):
self.requestList.put(packet)

38 changes: 29 additions & 9 deletions testCloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,40 @@

if __name__ == "__main__":

packet1 = packet.Packet(0, 100, 0, 0, 1)
packet2 = packet.Packet(0, 0, 0, 0, 2)
packet1 = packet.Packet(100, 0, 0, 1)
packet2 = packet.Packet( 0, 0, 0, 2)
packet3 = packet.Packet(100, 0, 0, 1)
packet4 = packet.Packet( 100, 0, 0, 2)

cloud = cloud.Cloud(0, 0, 10, 10)
cloud.receiveRequest(packet1)

cloud.receiveRequest(packet1)
cloud.receiveRequest(packet4)
cloud.receiveRequest(packet3)
cloud.receiveRequest(packet2)

time = 90

for i in range(0,10):
time = time + 1
packetList = cloud.updateTime(time)
if packetList != None:
time = 100
print "\ntest 1: should return 3 packets"
for i in range(0,20):
#print time
packetList = cloud.updateTime(time)
if packetList != None:
print packetList[0].packet_id
time = time + 1

cloud.receiveRequest(packet1)
cloud.receiveRequest(packet2)
cloud.receiveRequest(packet3)
cloud.receiveRequest(packet4)

time = 100
print "\ntest 2: should return 2 packets"

for i in range(0,20):
#print time
packetList = cloud.updateTime(time)
if packetList != None:
print packetList[0].packet_id
time = time + 1
print "\n"

0 comments on commit d15a17c

Please sign in to comment.