Skip to content

Commit

Permalink
TelemetrySystem/Python: added comments and changed probability of suc…
Browse files Browse the repository at this point in the history
…cessful connection of the client.
  • Loading branch information
Luca Minudel committed Sep 16, 2013
1 parent 981d304 commit 84e8e4c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions TDDMicroExercises/python/TelemetrySystem/telemetry.py
@@ -1,6 +1,10 @@
import random

class TelemetryClient(object):

# The communication with the server is simulated in this implementation.
# Because the focus of the exercise is on the other class.

DIAGNOSTIC_MESSAGE = "AT#UD"

def __init__(self):
Expand All @@ -14,8 +18,8 @@ def connect(self, telemetry_server_connection_string):
if (telemetry_server_connection_string is None or telemetry_server_connection_string == ""):
raise Exception()

# simulate the operation on a real modem
success = random.randint(0, 10) <= 8
# Fake the connection with 20% chances of success
success = random.randint(0, 10) <= 2

self.online_status = success

Expand Down

0 comments on commit 84e8e4c

Please sign in to comment.