Пример #1
0
    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')
Пример #2
0
    def test_09_(self):

        CommonFunc().select_course()

        CommonFunc().select_lesson()

        CommonFunc().resources_testing()
Пример #3
0
    def chk_kinds(self, num):
        print("1. 자동    2. 수동   3. 뒤로가기")
        choice = input(INPUT_TEXT)
        c2 = CommonFunc.values_chk(choice)
        if 0 < c2 < 4:
            if c2 == 1:
                for i in range(num):
                    self.buy_auto()
                    print("{}번째 {}".format(i + 1,
                                           self.user_lottos[self.l_index - 1]))
                self.money = CommonFunc.left_money(self.money, num * ONE_PRICE,
                                                   False)
                print("남은 돈: {}".format(self.money))

                self.again()
            elif c2 == 2:
                for i in range(num):
                    self.buy_manual()
                    print("{}번째 {}".format(i + 1,
                                           self.user_lottos[self.l_index - 1]))
                self.money = CommonFunc.left_money(self.money, num * ONE_PRICE,
                                                   False)
                print("남은 돈: {}".format(self.money))

                self.again()
            if c2 == 3:
                self.sub_menu()
        else:
            print("1~3 사이의 번호를 입력하세요.")
            self.chk_kinds(num)
Пример #4
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())
Пример #5
0
class Person:
    def __init__(self, money):
        self.common = CommonFunc()
        self.money = self.common.values_chk(money)
        self.place = None

    def sub_menu(self):
        print("무엇을 할까~~")
        for i in MainMenu:
            print("{}. {}".format(i.value, i.name), end='\t')
        print("")

        choice = input("입력: ")
        c2 = self.common.values_chk(choice)
        if c2 == MainMenu.HOME.value:
            self.go_home()
        elif c2 == MainMenu.LOTTO.value:
            if self.min_money(LOTTO_MIN):
                input("돈 없어. 집에 가자 enter ->")
                self.go_home()
            else:
                self.go_lotto()
        elif c2 == MainMenu.BOWLING.value:
            if self.min_money(BOWLING_MIN):
                input("돈 없어. 집에 가자 enter ->")
                self.go_home()
            else:
                self.go_bowling()
        else:
            input("1~3 중 선택하세요 enter ->")
            return self.sub_menu()

        self.go()

    def min_money(self, min_money):
        return self.money < min_money

    def go(self):
        if self.place:
            self.place.sub_menu()
        else:
            print("Error!")

    def go_home(self):
        self.place = Home(self)

    def go_lotto(self):
        self.place = Lotto(self)

    def go_bowling(self):
        self.place = Bowling(self)
Пример #6
0
    def buy_lotto(self):
        if len(self.user_lottos) >= MAX_BUY:
            input("최대 30만원까지 구매 가능합니다 enter ->")
            self.sub_menu()
        elif self.min_money():
            print("남은 돈: {}".format(self.money))
            input("돈이 부족합니다. enter ->")
            self.sub_menu()
        else:
            print("몇 장 구매하시겠습니까? (최대 20장 가능)")
            count = input("개수: ")
            c2 = CommonFunc.values_chk(count)
            if len(self.user_lottos) + c2 > MAX_BUY:
                print("최대 30만원까지 구매 가능합니다.")
                print("현재 구매 가능한 개수는 {}입니다.".format(MAX_BUY -
                                                    len(self.user_lottos)))
                self.buy_lotto()
            elif c2 * ONE_PRICE > self.money:
                print("돈이 부족합니다.")
                print("남은 돈: {}".format(self.money))
                input()
                self.sub_menu()

            if 0 < c2 < 21:
                self.chk_kinds(c2)
            else:
                print("최소 1장, 최대 20장이어야 합니다.")
                self.buy_lotto()
Пример #7
0
 def sub_menu(self):
     print("로또사러 왔다.")
     for i in LottoMenu:
         print("{}. {}".format(i.value, i.name), end="\t")
     print("")
     choice = input(INPUT_TEXT)
     c2 = CommonFunc.values_chk(choice)
     if c2 == LottoMenu.Buy_Lotto.value:
         print("로또구매")
         self.buy_lotto()
     elif c2 == LottoMenu.Check_Win.value:
         print("=" * 25)
         print("당첨확인")
         print("=" * 25)
         if not self.user_lottos:
             input("구매한 로또가 없습니다.\n사러가기 enter ->")
             self.buy_lotto()
         else:
             print("현재 {}장 있습니다.".format(len(self.user_lottos)))
             self.chk_win()
     elif c2 == LottoMenu.Next_Lotto.value:
         print("회차넘김")
         self.next_lotto()
     elif c2 == LottoMenu.H**o.value:
         self.person.go_home()
         self.person.go()
     else:
         input("1~4 중 선택하세요 enter ->")
         self.sub_menu()
Пример #8
0
    def chk_rank(self, l_index, lst, is_b):
        ranks = [1658710563, 62592852, 1475065, 50000, 5000, 0]
        i = 0

        if len(lst) == 6:
            print("축하합니다. 1등 당첨!!")
            print("당첨금: {}".format(ranks[i]))
        elif len(lst) == 5:
            if is_b:
                i += 1
                print("축하합니다. 2등 당첨!!")
                print("당첨금: {}".format(ranks[i]))
            else:
                i += 2
                print("축하합니다. 3등 당첨!!")
                print("당첨금: {}".format(ranks[i]))
        elif len(lst) == 4:
            i += 3
            print("축하합니다. 4등 당첨!!")
            print("당첨금: {}".format(ranks[i]))
        elif len(lst) == 3:
            i += 4
            print("축하합니다. 5등 당첨!!")
            print("당첨금: {}".format(ranks[i]))
        else:
            i += 5

        if l_index in self.receipt_m:
            print("이미 수령한 로또입니다.")
            print("남은 돈: {}".format(self.money))
        else:
            self.money = CommonFunc.left_money(self.money, ranks[i], True)
            print("남은 돈: {}".format(self.money))
Пример #9
0
    def total_score(self):
        """점수 계산"""
        if self.rolls:
            self.rolls = []
            self.scores = []

        self.pin_maker()
        score = 0
        roll_index = 0

        for frame in range(TOTAL_FRAME):
            if self.is_strike(roll_index):
                if frame == LAST_FRAME:
                    score += FULL_SCORE
                else:
                    score += FULL_SCORE + self.rolls[
                        roll_index + 1][0] + self.rolls[roll_index + 1][1]
            elif self.is_spare(roll_index):
                if frame == LAST_FRAME:
                    score += FULL_SCORE
                else:
                    score += FULL_SCORE + self.rolls[roll_index + 1][0]
            else:
                score += self.rolls[roll_index][0] + self.rolls[roll_index][1]
            roll_index += 1
            self.scores.append(score)

            if frame == LAST_FRAME:
                self.show_score(True)

        self.money = CommonFunc.left_money(self.money, MIN_MONEY, False)
        print("남은 돈: {}".format(self.money))
        self.again()
Пример #10
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)
Пример #11
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())
Пример #12
0
    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)
Пример #13
0
    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')
Пример #14
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)
Пример #15
0
    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()
Пример #16
0
 def win_chk_again(self):
     print("다시 확인하시겠습니까? 1. 네    2. 아니오")
     choice = input(INPUT_TEXT)
     c2 = CommonFunc.values_chk(choice)
     if c2 == 1:
         self.chk_win()
     elif c2 == 2:
         self.sub_menu()
     else:
         print("1 또는 2만 입력하세요.")
         self.win_chk_again()
Пример #17
0
    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()
Пример #18
0
 def again(self):
     print("계속 구매하시겠습니까? 1. 네    2. 메인으로")
     choice = input(INPUT_TEXT)
     c2 = CommonFunc.values_chk(choice)
     if 0 < c2 < 3:
         if c2 == 1:
             self.buy_lotto()
         else:
             self.sub_menu()
     else:
         input("1 또는 2만 입력하세요 enter ->")
         self.again()
Пример #19
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
Пример #20
0
 def again(self):
     """다시하기 메뉴"""
     print("1. 메인으로 2. 집으로")
     choice = input("입력: ")
     c2 = CommonFunc.values_chk(choice)
     if c2 == 1:
         self.sub_menu()
     elif c2 == 2:
         self.person.go_home()
         self.person.go()
     else:
         print("1~2 사이 수만 입력하세요.")
         self.again()
Пример #21
0
 def next_lotto(self):
     print("다음 회차로 넘기시겠습니까? 1. 네    2. 아니오")
     choice = input(INPUT_TEXT)
     c2 = CommonFunc.values_chk(choice)
     if c2 == 1:
         self.win_nums = []
         self.user_lottos = {}
         self.sub_menu()
     elif c2 == 2:
         self.sub_menu()
     else:
         print("1 또는 2만 입력하세요.")
         self.next_lotto()
Пример #22
0
 def buy_manual(self):
     nums = []
     for i in range(1, 7):
         while True:
             print("{}번째 수 입력: ".format(i))
             num = input()
             n2 = CommonFunc.values_chk(num)
             if n2 not in range(1, 46):
                 print("1~45 사이의 수만 입력하세요.")
                 continue
             if n2 in nums:
                 x = nums.index(n2) + 1
                 print("{}번째 수와 중복입니다.".format(x))
                 continue
             nums.append(n2)
             nums.sort()
             break
     self.user_lottos[self.l_index] = nums
     self.l_index += 1
Пример #23
0
    def sub_menu(self):
        print("집 도착!")
        for i in HomeMenu:
            print("{}. {}".format(i.value, i.name))
        choice = input("입력: ")
        c2 = CommonFunc.values_chk(choice)

        if c2 == HomeMenu.Lotto.value:
            self.person.go_lotto()
            self.person.go()
        elif c2 == HomeMenu.Bowling.value:
            self.person.go_bowling()
            self.person.go()
        elif c2 == HomeMenu.Go_Outside.value:
            self.person.sub_menu()
        elif c2 == HomeMenu.Exit.value:
            print("빠잉~!")
            pass
        else:
            print("1~4 사이의 수만 입력하세요.")
            self.sub_menu()
Пример #24
0
 def sub_menu(self):
     """Bowling class main_menu"""
     print("볼링치러 왔다.")
     for i in BowlingMenu:
         print("{}. {}".format(i.value, i.name))
     choice = input("입력: ")
     c2 = CommonFunc.values_chk(choice)
     if c2 == BowlingMenu.Bowling.value:
         if self.min_money():
             print("남은 돈: {}".format(self.money))
             input("돈이 부족합니다.")
             self.sub_menu()
         else:
             self.total_score()
     elif c2 == BowlingMenu.Check_Score.value:
         self.show_last_score()
     elif c2 == BowlingMenu.Home.value:
         self.person.go_home()
         self.person.go()
     else:
         print("1~3 사이의 수만 입력하세요.")
         self.sub_menu()
Пример #25
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 = {}
Пример #26
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
Пример #27
0
 def __init__(self, money):
     self.common = CommonFunc()
     self.money = self.common.values_chk(money)
     self.place = None
Пример #28
0
from common_func import CommonFunc
from person import Person

if __name__ == "__main__":
    user_money = input("지금 돈 얼마 있어?\n입력: ")
    user_money = CommonFunc.values_chk(user_money)

    person = Person(user_money)
    person.sub_menu()
Пример #29
0
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]