Ejemplo n.º 1
0
 def test_movement_south_east(self):
     for x in range(1, 4):
         for y in reversed(range(1, 3)):
             input = '5 3\n' + str(x) + ' ' + str(y) + ' E\nFRFL'
             assert robot.process_input(input) == [
                 str(x + 1) + ' ' + str(y - 1) + ' E'
             ]
Ejemplo n.º 2
0
 def test_movement_north_west(self):
     for x in reversed(range(1, 4)):
         for y in range(1, 3):
             input = '5 3\n' + str(x) + ' ' + str(y) + ' W\nFRFL'
             assert robot.process_input(input) == [
                 str(x - 1) + ' ' + str(y + 1) + ' W'
             ]
Ejemplo n.º 3
0
 def test_movement_north_east(self):
     for x in range(4):
         for y in range(3):
             input = '5 3\n' + str(x) + ' ' + str(y) + ' E\nFLFR'
             assert robot.process_input(input) == [
                 str(x + 1) + ' ' + str(y + 1) + ' E'
             ]
Ejemplo n.º 4
0
def smooch_events():
    """
    the firehose of events that the webhooks subscribed to,
    this will send all messages from people who visit your website
    to this endmpoint, the robot then parses those messages and
    does a postback of its response.
    """
    # this is actually everything people say to the robot, may be good
    # to send this to a log file or database
    #print json.dumps(request.json)

    # get the singletons
    smooch_api = LocalProxy(get_smooch_api)
    robot = LocalProxy(get_robot)

    for message in request.json['messages']:
        response = robot.process_input(message['text'])
        smooch_api.postback_message(response, message['authorId'])

    data = {'message': 'succeed'}
    resp = Response(json.dumps(data), status=200, mimetype='application/json')
    return resp
Ejemplo n.º 5
0
import robot

# Read input from txt file
file = open('testdata.txt', 'r')
input = file.read()

# process input and print result
for line in robot.process_input(input):
    print line
Ejemplo n.º 6
0
 def test_edge_case_east_north(self):
     input = '5 3\n5 3 N\nF'
     assert robot.process_input(input) == ['5 3 N LOST']
Ejemplo n.º 7
0
 def test_movement_south(self):
     for i in reversed(range(1, 3)):
         input = '5 3\n0 ' + str(i) + ' S\nF'
         assert robot.process_input(input) == ['0 ' + str(i - 1) + ' S']
Ejemplo n.º 8
0
 def test_movement_north(self):
     for i in range(3):
         input = '5 3\n0 ' + str(i) + ' N\nF'
         assert robot.process_input(input) == ['0 ' + str(i + 1) + ' N']
Ejemplo n.º 9
0
 def test_movement_west(self):
     for i in reversed(range(1, 4)):
         input = '5 3\n' + str(i) + ' 0 W\nF'
         assert robot.process_input(input) == [str(i - 1) + ' 0 W']
Ejemplo n.º 10
0
 def test_movement_east(self):
     for i in range(4):
         input = '5 3\n' + str(i) + ' 0 E\nF'
         assert robot.process_input(input) == [str(i + 1) + ' 0 E']
Ejemplo n.º 11
0
 def test_edge_case_east(self):
     input = '5 3\n5 2 E\nF'
     assert robot.process_input(input) == ['5 2 E LOST']
Ejemplo n.º 12
0
 def test_edge_case_south(self):
     input = '5 3\n2 0 S\nF'
     assert robot.process_input(input) == ['2 0 S LOST']
Ejemplo n.º 13
0
 def test_edge_case_west(self):
     input = '5 3\n0 2 W\nF'
     assert robot.process_input(input) == ['0 2 W LOST']