def add_connection_and_go(): connection = request.get_json() logging.info('%s - %s' % (connection['css'], connection['nb'])) site = Site() connection_id = site.add_connection_to_current_page(Action.ActionType.CLICK, connection['css'], connection['nb']) action = site.get_action_from_id(connection_id) action.do() return jsonify(gexf=etree.tostring(site.get_gexf()).decode('utf-8'), current_page=site.current)
def test_get_action(self): from Site.Site import Site from Main.Action import Action site_url = "http://%s.url/for/page" % uuid.uuid4() site = Site(site_url) url = str(uuid.uuid4()) id = site.add_connection_to_current_page(Action.ActionType.CLICK, "[href='%s']" % url, 0) action = site.get_action({'connection': {'data': {'url': url}}, 'id': id}) assert action._type == Action.ActionType.CLICK assert action.connection == id