def test_09_(self):

        CommonFunc().select_course()

        CommonFunc().select_lesson()

        CommonFunc().resources_testing()
    def test_04_confirmation_popup_in_Learn(self):

        confirmation_modal = CommonFunc().wait_visibility(
            5, By.CSS_SELECTOR, Locator.confirmation_modal)
        confirmation_modal_title = driver.find_element_by_css_selector(
            Locator.confirmation_modal_title)

        if (confirmation_modal.is_displayed()):

            try:

                self.assertIn(confirmation_modal_title.text.upper(),
                              TestData.student_username.upper())
                yes = driver.find_element_by_css_selector(Locator.yes_button)
                sleep(1)
                yes.click()

            except:

                no = driver.find_element_by_css_selector(Locator.no_button)
                no.click()
                sleep(1)
                self.assertEqual(TestData.expected_url, driver.current_url)
                print('Login not confirmed')

        else:
            print('No confirmation modal')
示例#3
0
    def get_widget(self):
        '''

            获取指定用户具有的组件

            returns:User
        '''
        try:
            from ..widget.widget_fuction import widget_get
            from ..widget.widget_fuction import user_widget_get
            from ..common_func import CommonFunc
        except:
            import sys
            sys.path.append('../')
            sys.path.append('../../')
            from widget.widget_fuction import widget_get
            from widget.widget_fuction import user_widget_get
            from common_func import CommonFunc
        cf = CommonFunc()

        user_widget_list = user_widget_get(self.user_id)
        widget_list = widget_get()
        result = [{
            'id': single_user_widget['widget_id'],
            'order': single_user_widget['order'],
            'name': cf.dict_list_get_single_element(widget_list, 'id', single_user_widget['widget_id'], 'name', single_user_widget['widget_id'] - 1),
            'is_login_needed': cf.dict_list_get_single_element(widget_list, 'id', single_user_widget['widget_id'], 'is_login_needed', single_user_widget['widget_id'] - 1),
            'span': cf.dict_list_get_single_element(widget_list, 'id', single_user_widget['widget_id'], 'span', single_user_widget['widget_id'] - 1),
            'buttons': BUTTONS[cf.dict_list_get_single_element(widget_list, 'id', single_user_widget['widget_id'], 'name', single_user_widget['widget_id'] - 1)]
        } for single_user_widget in user_widget_list]
        self.widget = result
        return self
示例#4
0
def get_info(start_num, end_num):
    global list_items
    for num in range(start_num, end_num + 1):
        url = str(num) + '/'
        detail_info = {"id": num}

        list_items, detail_info = CommonFunc().get_pro_info(
            url, list_items, detail_info)
示例#5
0
def get_info():
    global list_items

    list_items, detail_info = CommonFunc().get_student_guide('', list_items)
    num = 0
    for item in copy.deepcopy(list_items).keys():
        list_items[item] = CommonFunc().get_news_detail(
            list_items[item]['url'], list_items[item])
        if 'content' not in list_items[item]:
            list_items[item]['content'] = []
        if 'title' not in list_items[item]:
            list_items[item]['tile'] = ''
            list_items[item]['desc'] = ''
        num += 1

    print json.dumps(list_items, encoding='UTF-8',
                     ensure_ascii=False), len(list_items.keys())
    def test_06_check_initial_score_home_page(self):

        right_header_score = CommonFunc().wait_visibility(
            5, By.XPATH, Locator.right_header_score)

        if right_header_score.text >= '100':
            initial_score = right_header_score.text

        else:
            print('initial score is wrong')
示例#7
0
def get_info():
    global list_items

    list_items, detail_info = CommonFunc().get_college_info('', list_items)
    now_date = datetime.datetime.strptime(str(datetime.date.today()),
                                          '%Y-%m-%d')
    num = 0
    for item in copy.deepcopy(list_items):
        news_date = datetime.datetime.strptime(item['date'],
                                               '%Y-%m-%d %H:%M:%S')
        if news_date.__lt__(now_date):
            print item['date']
            list_items = list_items[0:num]
            break
        list_items[num] = CommonFunc().get_news_detail(item['url'], item)
        num += 1

    print json.dumps(list_items, encoding='UTF-8',
                     ensure_ascii=False), len(list_items)
    def test_08_check_badge_sidebar_navigation(self):
        sleep(2)

        badge = CommonFunc().wait_presence(10, By.ID, Locator.badge)
        badge.click()

        try:
            badge_sidebar = driver.find_element_by_css_selector(
                Locator.badge_sidebar)
            badge_sidebar.is_displayed()

        except :
            print('badge sidebar is not active')
        badge.click()

        sleep(2)

        profile_page_back = CommonFunc().wait_visibility(10, By.ID, Locator.profile_page_back)     
        
        profile_page_back.click()
示例#9
0
def get_info(start_num, end_num):
    global list_items

    for num in range(start_num, end_num + 1):
        url = 'p' + str(num) + '/'
        detail_info = {"p": num}
        list_items, detail_info = CommonFunc().get_college_detail(
            url, list_items)

    print json.dumps(list_items, encoding='UTF-8',
                     ensure_ascii=False), len(list_items.keys())
    def test_02_login(self):
        # select student  and login
        sleep(3)

        student = driver.find_element_by_xpath(Locator.student)
        student.click()

        username = CommonFunc().wait_presence(5, By.XPATH, Locator.username)
        username.send_keys(TestData.student_username)

        password = driver.find_element_by_xpath(Locator.password)
        password.send_keys(TestData.student_password)

        login = driver.find_element_by_id(Locator.login)
        login.click()

        current_url = driver.current_url

        self.assertEqual(TestData.expected_url, current_url)
    def test_03_landing_page(self):

        try:
            learn = CommonFunc().wait_visibility(10, By.XPATH, Locator.learn)

        except NoSuchElementException:
            print('Learn not present')

        try:
            quiz = driver.find_element_by_xpath(Locator.quiz)

        except NoSuchElementException:
            print('quiz not present')

        try:
            logout = driver.find_element_by_xpath(Locator.logout)

        except NoSuchElementException:
            print('logout not present')

        learn.click()
示例#12
0
def get_info():
    global list_items
    global detail_info
    with open(PATH + '/result/failed.json') as fp:
        data = fp.read()
        result = Utils().unicode_convert(json.loads(data))
        failed_item_dict = eval(result)

        for item in failed_item_dict.values():
            itemDict = eval(item)
            try:
                list_items, detail_info = CommonFunc().get_pro_info(
                    itemDict['url'], list_items, itemDict)
            except IOError:
                time.sleep(5)
                pass

    date = time.strftime('%Y%m%d', time.localtime(time.time()))

    JsonFunc().save_json(list_items,
                         PATH + '/profile/profession_failed_' + date)
    list_items = {}
示例#13
0
def get_info(start_num, end_num):
    global list_items
    global detail_info

    for num in range(start_num, end_num + 1):
        url = request.get_url('p' + str(num) + '/', mod='pro_list_url')
        itemLink = ''
        try:
            res = request.set_request(url)
            soup = BeautifulSoup(res.text, "html.parser")

            dom = soup.find('div', {'class': 'scores_List'})
            domList = dom.find_all('dl')

            print 'ok: ', url
            for item in domList:
                # 专业链接
                itemLink = item.find_all('a')[0]['href']
                detail_info = {"p": num}
                for subItem in item.find_all('li'):
                    info = subItem.get_text().strip().split(':')
                    detail_info[info[0]] = info[1]
                try:
                    list_items, detail_info = CommonFunc().get_pro_info(
                        itemLink, list_items, detail_info, mod='pro_list_url')
                except IOError:
                    time.sleep(5)
                    pass
        except IOError:
            print 'failed: ', url
        finally:
            JsonFunc().save_json(list_items,
                                 PATH + '/profile/profession_' + str(num))
            list_items = {}
            time.sleep(30)
            pass
示例#14
0
 def __init__(self, money):
     self.common = CommonFunc()
     self.money = self.common.values_chk(money)
     self.place = None
import requests
import datetime
import threading

import sys
sys.path.append('../')
sys.path.append('../..')

from common_func import CommonFunc

from model.widget_model import widget

from model.stock_model import stock as stock_table
from model.stock_model import stock_price, stock_belong

cf = CommonFunc()

CODE_SH: 1
CODE_SZ: 2
CODE_HK: 3
CODE_US: 4
MARKET_PREFIX = ['sh', 'sz', 'hk', 'gb_']  # 顺序与上方code严格对应
MARKET_TEXT = ['SH', 'SZ', 'HK', 'US']  # 顺序与上方code严格对应
STOCK_BASE_URL = 'http://hq.sinajs.cn/list='

data_source = []


def get_valid_stock_id():
    stock_belong_query = stock_belong.select().where(stock_belong.is_valid == 1).dicts()
    return [{'stock_id': _['stock_id']} for _ in stock_belong_query]