def __init__(self): signal.signal(signal.SIGINT, self.stop) if WIN32_FROZEN: static_path = os.path.join( os.path.dirname(os.path.abspath(sys.executable)), 'static') Win32StopThread(self.stop).start() else: static_path = None #default static path will be used signal.signal(signal.SIGINT, self.stop) self.server = MgmtServer('0.0.0.0', DAEMON_PORT, IdepositboxClient(), static_path)
def init_console(self): self.mocked_id_client = get_test_idepositbox_client() self.mgmt_console = MgmtServer('127.0.0.1', 9999, self.mocked_id_client) self.mgmt_console.start() for i in xrange(20): if self.mgmt_console.is_ready(): break time.sleep(.5) else: raise Exception('Management console does not started!') self.mocked_id_client.simulate_id_client(OK, area={'get_available_media_storages': []})
class IDClientDaemon: def __init__(self): signal.signal(signal.SIGINT, self.stop) if WIN32_FROZEN: static_path = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), 'static') Win32StopThread(self.stop).start() else: static_path = None #default static path will be used signal.signal(signal.SIGINT, self.stop) self.server = MgmtServer('0.0.0.0', DAEMON_PORT, IdepositboxClient(), static_path) def start(self): try: self.server.run() except Exception, err: logger.error('IDClientDaemon error: %s'%err) logger.traceback_info()
def __init__(self): signal.signal(signal.SIGINT, self.stop) if WIN32_FROZEN: static_path = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), 'static') Win32StopThread(self.stop).start() else: static_path = None #default static path will be used signal.signal(signal.SIGINT, self.stop) self.server = MgmtServer('0.0.0.0', DAEMON_PORT, IdepositboxClient(), static_path)
class IDClientDaemon: def __init__(self): signal.signal(signal.SIGINT, self.stop) if WIN32_FROZEN: static_path = os.path.join( os.path.dirname(os.path.abspath(sys.executable)), 'static') Win32StopThread(self.stop).start() else: static_path = None #default static path will be used signal.signal(signal.SIGINT, self.stop) self.server = MgmtServer('0.0.0.0', DAEMON_PORT, IdepositboxClient(), static_path) def start(self): try: self.server.run() except Exception, err: logger.error('IDClientDaemon error: %s' % err) logger.traceback_info()
class MgmtConsoleTest(runtests.SSTTestCase): mocked_id_client = None mgmt_console = None def init_console(self): self.mocked_id_client = get_test_idepositbox_client() self.mgmt_console = MgmtServer('127.0.0.1', 9999, self.mocked_id_client) self.mgmt_console.start() for i in xrange(20): if self.mgmt_console.is_ready(): break time.sleep(.5) else: raise Exception('Management console does not started!') self.mocked_id_client.simulate_id_client(OK, area={'get_available_media_storages': []}) def destroy_console(self): self.mocked_id_client.simulate_fabnet_gw(OK) self.mgmt_console.stop() print 'console is destroyed!' def base_console_test(self): go_to('http://127.0.0.1:9999/') assert_title_contains('iDepositBox') wait_for(assert_element, id='home', css_class='active') assert_text(xpath('//*[@id="wind"]/div[1]/h3'), 'iDepositBox management console') assert_text_contains(xpath('//*[@id="wind"]/div[3]/p'), '2013 iDepositBox software') assert_text(xpath('//*[@id="home"]/a'), 'Home') assert_text(xpath('//*[@id="settings"]/a'), 'Settings') assert_text(xpath('//*[@id="key_mgmt"]/a'), 'Key management') assert_text(xpath('//*[@id="about"]/a'), 'About') def check_help(self): click_element(get_element(css_class="help")) wait_for(assert_element, css_class="popover") click_element('wind') fails(assert_element, css_class="popover") def home_check(self, ks_list, serv_status, sync_status, inpr_files=[]): #ks path if len(ks_list) < 2: wait_for(assert_element, id='ksPathLabel', css_class='label') assert_displayed('ksPathLabel') assert_css_property('ksPath', 'display', 'none') if not ks_list: assert_element(id='ksPathLabel', css_class='label-important') assert_text('ksPathLabel', 'Not found') else: assert_text('ksPathLabel', ks_list[0]) else: raise Exception('not implemented!') #serv status wait_for(assert_element, id='serv_status', css_class='label') wait_for(assert_text, 'serv_status', serv_status) if serv_status == 'Stopped': assert_element(id='serv_status', css_class='label-important') elif serv_status == 'Started': assert_element(id='serv_status', css_class='label-success') #sync_status wait_for(assert_text, 'sync_status', sync_status) if sync_status == 'All files are synchronized': assert_element(id='sync_status', css_class='label-success') else: assert_element(id='sync_status', css_class='label-warning') assert_css_property('inpr_tbl', 'display', 'none') if not inpr_files: assert_css_property('pr_tl', 'display', 'none') else: assert_displayed('pr_tl') click_element('pr_tl') wait_for(assert_displayed, 'inpr_tbl') wait_for(assert_table_has_rows, 'inpr_tbl', len(inpr_files)+1) #assert_css_property('pr_tl', 'width', '100%') is_up_tr = None for i, (f_name, f_size, is_upload) in enumerate(inpr_files): tr = i+2 icon = 'icon-arrow-%s'% ('up' if is_upload else 'down') assert_attribute(xpath('//*[@id="inpr_tbl"]/tbody/tr[%i]/td[1]/span[1]'%tr), 'class', icon) assert_text_contains(xpath('//*[@id="inpr_tbl"]/tbody/tr[%i]/td[1]'%tr), f_name) assert_text(xpath('//*[@id="inpr_tbl"]/tbody/tr[%i]/td[2]'%tr), '%s b'%f_size) if is_upload: assert_text(xpath('//*[@id="inpr_tbl"]/tbody/tr[%i]/td[3]'%tr), '40%') assert_attribute(xpath('//*[@id="inpr_tbl"]/tbody/tr[%i]/td[1]/span[2]'%tr), 'class', 'icon-globe') else: assert_text(xpath('//*[@id="inpr_tbl"]/tbody/tr[%i]/td[3]'%tr), '0%') if is_up_tr is None: is_up_tr = is_upload elif is_up_tr != is_upload: is_up_tr = 'both' if is_up_tr==True: icon = 'icon-arrow-up' perc = '40%' elif is_up_tr==False: icon = 'icon-arrow-down' perc = '0%' else: icon = 'icon-refresh' perc = '16%' assert_text(xpath('//*[@id="d_pr"]/span'), perc) assert_attribute(xpath('//*[@id="sync_status"]/span'), "class", "%s icon-white"%icon) click_element('pr_tl') wait_for(assert_css_property, 'inpr_tbl', 'display', 'none') #btb assert_element(id='startstop', css_class='btn') if serv_status == 'Stopped': assert_element(id='startstop', css_class='btn-success') assert_text('startstop', 'Start service') else: assert_element(id='startstop', css_class='btn-danger') assert_text('startstop', 'Stop service') if not ks_list: assert_attribute('startstop', 'disabled', 'true') assert_css_property('pwdModal', 'display', 'none') assert_css_property('spinModal', 'display', 'none') assert_css_property('events_list_modal', 'display', 'none') def home_click_start(self, pwd): click_element('startstop') wait_for(assert_displayed, 'pwdModal') write_textfield('pwdEdit', pwd, clear=False) click_element(get_element(tag='a', text='Start')) wait_for(assert_css_property, 'pwdModal', 'display', 'none') wait_for(assert_css_property, 'spinModal', 'display', 'none') if pwd != KS_PASSWORD: assert_text_contains('err_msg', 'pin-code is invalid!') else: self.home_check([KEY_NAME], 'Started', 'All files are synchronized') def home_click_stop(self): click_element('startstop') self.home_check([KEY_NAME], 'Stopped', 'Unknown') def send_file(self, file_name, file_len): client = WebDAVClient("127.0.0.1", 9997) response = client.put('/%s'%file_name, RANDOM(file_len), "text/plain") self.assertEqual(response.statusline, 'HTTP/1.1 201 Created') def get_file(self, file_name): client = WebDAVClient("127.0.0.1", 9997) client.timeout = 1 try: response = client.get('/%s'%file_name) except socket.timeout, err: pass except Exception, err: print 'get_file error: %s'%err