def test_setup_mysql(): #check internet connection up.connected() #run vpn up.openvpn_running() #create connection object cursor_obj, connection = up.setup_mysql() #test object connection is open assert connection.open
def main(): turn_down_wireless_card() try_with_restart(switch_monitor_mode, 3) turn_on_wireless_card() # connect wifi try_with_restart(connect_wifi, 5) # get ip try_with_restart(get_ip, 5) # get time try_with_restart(syn_time, 5) while True: if stop(): break # start sniff unused = check_output(['/usr/bin/python', work_dir + 'gather.py']) log_to_file('Gathered mac addresses') # send to server time.sleep(1) if connected(): log_to_file('Network is OK, and is going to upload!') try_with_restart(upload, 3, connect_wifi) else: try_with_restart(get_ip, 5)
def main(): turn_down_wireless_card() try_with_restart(switch_monitor_mode, 3) turn_on_wireless_card() # connect wifi try_with_restart(connect_wifi, 5) # get ip try_with_restart(get_ip, 5) # get time try_with_restart(syn_time, 5) while True: if stop(): break # start sniff unused = check_output(['/usr/bin/python', work_dir+'gather.py']) log_to_file('Gathered mac addresses') # send to server time.sleep(1) if connected(): log_to_file('Network is OK, and is going to upload!') try_with_restart(upload, 3, connect_wifi) else: try_with_restart(get_ip, 5)
def test_create_table(): #check vpn is running up.connected() up.openvpn_running() #create table table_name = 'mmp_test' cursor_obj, connection = up.setup_mysql() up.create_table(cursor_obj, table_name) #check table exists result = up.table_exists(cursor_obj, table_name) #drop the table sql = 'DROP TABLE ' + table_name + ';' cursor_obj.execute(sql) #test result assert result #check if table exists which it shouldn't result = up.table_exists(cursor_obj, table_name) assert not result
def get_ip(): ret = check_output("ifconfig") if c.ip_start in ret: if connected(): return True, '' else: log_to_file("Not connected to server, release IP") not_used = check_output("dhclient wlan0 -r".split()) # not got yet not_used = check_output("dhclient wlan0".split()) log_to_file('Finished dhclient') ret = check_output("ifconfig") if c.ip_start in ret and connected(): return True, '' elif c.ip_start in ret and not connected(): log_to_file('Got IP but cannot connect to server.') return False, 'Got IP but cannot connect to server.' else: log_to_file('Cannot get IP') return False, 'Cannot get IP'
def test_not_connected(): assert not up.connected()
def test_connected(): assert up.connected()