Exemple #1
0
 def test_ValueError_raised_after_clear_check_with_not_deposited(self):
     """ test if the ValueError raised after clear_check with the check 
     which not in the pending check. """
     bank_account = set_up()
     ck1 = Check(7890)
     fake_check = Check(1234)
     bank_account.deposit(ck1)
     with self.assertRaises(ValueError):
         bank_account.clear_check(fake_check)
def test_check():
    check = Check()
    check.letter_guessed = "a"
    word = "frog"
    spaces = ["_", "_", "_", "_"]
    check.check(word, spaces)
    assert check.incorrect_guesses == 1
Exemple #3
0
 def add_note(self):
     note_name = Check(
         input(
             'Введите через пробел имя, фамилию, номер телефона(без плюса), город и e-mail:'
         ))
     if note_name.note_is_right():
         handbook = open(self.name + '.txt', 'r')
         notes = handbook.read()
         handbook.close()
         if note_name.check_to_str() in notes:
             print('Такая запись уже существует.', end='\n')
             return
         if note_name.phone_number in notes:
             print('Запись с таким номером уже существует.', end='\n')
             return
         if note_name.name and note_name.last_name in notes:
             print('Запись c такими именем и фамилией уже существует.',
                   end='\n')
             return
         if note_name.email in notes:
             print('Запись с таким e-mail уже существует.', end='\n')
             return
         handbook = open(self.name + '.txt', 'a')
         handbook.write(note_name.check_to_str() + '\n')
         handbook.close()
         print('Запись добавлена.', end='\n')
     else:
         print('Неверный ввод. Повторите попытку.', end='\n')
Exemple #4
0
 def test_check_in_peding_check(self):
     """ test if the ValueError raised after deposit a deposited check. """
     bank_account = set_up()
     ck = Check(1000)
     with self.assertRaises(ValueError):
         bank_account.deposit(ck)
         bank_account.deposit(ck)
Exemple #5
0
 def test_negative_deposit(self):
     """ test if the min_balance is correct. """
     bank_account = set_up()
     with self.assertRaises(ValueError):
         bank_account.deposit(Money(-1000))
     with self.assertRaises(ValueError):
         bank_account.deposit(Check(-1000))
Exemple #6
0
    def run_background(self):
        """
        We trigger the health checks periodically in a background process
        """
        while True:

            config_path = os.getenv('HK_CONFIG_PATH', "resources/config.yaml")
            cfg = Config(path=config_path)

            if not cfg.data:
                print("ERROR: No health-checks valid config found. Please check syntax.")
            else:
                try:
                    print(time.strftime("%c")+" Checking endpoints")
                    chk = Check(cfg.data)
                    chk.check_endpoints()
                    chk.send_notifications()
                    print(time.strftime("%c") + " Endpoints checked")
                except Exception as e:
                    print("ERROR: Killing application. Reason:\n"+str(e))
                    #os.kill(os.getpid(), signal.SIGTERM)
                    #sys.exit()
                    self.server.stop()

            time.sleep(self.interval)
Exemple #7
0
 def test_too_much_withdraw(self):
     """ test that raise the ValueError after withdraw higher than available. """
     bank_account = set_up()
     bank_account.deposit(Money(9000))
     ck = Check(10000)
     bank_account.deposit(ck)
     with self.assertRaises(ValueError):
         bank_account.withdraw(10000)
Exemple #8
0
    def test_check_endpoints_timeout(self):

        endpoint = {'notificationEndpoint': {'url': ''}, 'checks': [{'request': {'endpoint': 'http://127.0.0.1:1',  'method': 'GET', 'connectTimeout': 0.001}, 'response': {'codes': [200]}, 'service': 'Gitlab'}]}

        my_check = Check(endpoint)
        my_check.check_endpoints()

        result = len(my_check.errors_list)
        self.assertEqual(result, 1)
Exemple #9
0
 def test_balance_changed_after_check_added(self):
     """ test if the balance and available is changed after deposit and clear check. """
     bank_account = set_up()
     ck = Check(5000)
     self.assertEqual(ck.check_number, Check._next_check_number - 1)
     bank_account.deposit(ck)
     self.assertEqual(bank_account.available, 0)
     bank_account.clear_check(ck)
     self.assertEqual(bank_account.available, 4000)
Exemple #10
0
 def test_can_add_the_check_again_after_clear_check(self):
     """ test if the  """
     bank_account = set_up()
     ck = Check(1000)
     bank_account.deposit(ck)
     bank_account.clear_check(ck)
     self.assertEqual(bank_account.balance, 1000)
     bank_account.deposit(ck)
     bank_account.clear_check(ck)
     self.assertEqual(bank_account.balance, 2000)
Exemple #11
0
 def __init__(self):
     self.Tablero = Tablero()
     self.turnoactual = "W"
     self.Check = Check(self)
     self.Enroque = Enroque(self)
     self.texto = {"W": "Las blancas!", "B": "Las negras!"}
     self.victoria = False
     self.turno = False
     self.enroque = None
     self.oficial = None
Exemple #12
0
 def __init__(self):
     """The class constructor.
     
     Args:
         self (Director): an instance of Director.
     """
     self.puzzle = Puzzle()
     self.jumper = Jumper()
     self.check = Check()
     self.keep_playing = True
Exemple #13
0
 def schedule_check(self, cycle=TESTER_CYCLE):
     '''
     定时测试代理
     :param cycle:
     :return:
     '''
     check = Check()
     while True:
         print('测试器开始运行')
         check.run()
         time.sleep(cycle)
Exemple #14
0
 def __init__(self):
     with open(file='./conf/actorConf.json', mode='r',
               encoding='utf-8') as f:
         content = f.read()
         content_json = json.loads(content)
         self.Head = content_json['Head']
         self.End = content_json['End']
     # 用户检查校验更正文本的输入与输出
     self.myCheck = Check()
     self.parser = TextParser()
     self.classifier = Classifier()
     self.ruleParser = RuleParser()
Exemple #15
0
 def login(self):
     print("*------------------------------------*")
     print("|                                    |")
     print("|           管理员登陆界面           |")
     print("|                                    |")
     print("*------------------------------------*")
     check = Check()
     check.userName(self.admin, self.password)
     print("*-------------登陆成功---------------*")
     print("   正在跳转到系统功能界面,请稍候...  ")
     del check
     time.sleep(3)
     return
Exemple #16
0
def index():
    if request.method == 'POST':
        msg = request.get_json()
        chat_id, txt = prase_message(msg)
        try:
            checking = Check(txt)
            if checking.msg_for_bot():
                bot.send_message(checking.msg_for_bot(), chat_id)
        except Exception as value:
            bot.send_message(str(value), chat_id)
        return Response('OK', status=200)
    else:
        return '<h1>Ngon</h1>'
 def getCheckedOutItems(self):
     self.connect()
     try:
         c = self.connection.cursor()
         c.execute('select * from POSHEA1."CHECK"')
         a = []
         for row in c:
             temp = Check('', '', '')
             temp.adapt(row)
             a.append(temp.dictify())
         self.disconnect()
         return json.dumps(a)
     except:
         self.disconnect()
         return json.dumps([])
Exemple #18
0
    def login(self):
        print("--------------------------------------")
        print("                                      ")
        print("            Admin login.....          ")
        print("                                      ")
        print("--------------------------------------")

        check = Check()
        check.userName(self.admin, self.pwd)

        print("--------------Login success-----------")
        print("          Please wait a moment...     ")
        del check
        time.sleep(1)
        return
Exemple #19
0
    def logout(self):
        print("*------------------------------------*")
        print("|                                    |")
        print("|           管理员注销界面           |")
        print("|                                    |")
        print("*------------------------------------*")
        #确认是否注销
        check = Check()
        if not check.isSure('注销'):
            return False

        check.userName(self.admin, self.password)
        print("*-------------注销成功---------------*")
        print("        正在关闭系统,请稍候...       ")
        del check
        time.sleep(3)

        return True
Exemple #20
0
    def logout(self):
        print("--------------------------------------")
        print("                                      ")
        print("            Admin logout....          ")
        print("                                      ")
        print("--------------------------------------")

        # 确认是否退出
        check = Check()
        if not check.isSure("退出"):
            return False

        check.userName(self.admin, self.pwd)
        print("-------------Logout success-----------")
        print(" It is closing...Please wait a moment ")
        del check
        time.sleep(1)
        return True
Exemple #21
0
 def post(self):
     username_ = self.request.get('username')
     password_ = self.request.get('password')
     verify_ = self.request.get('verify')
     email_ = self.request.get('email')
     if not email_:
         email_=""          
     result = Check(username_, password_, verify_, email_)
     if result[8]:         
         hpassword = hmac.new(key,password_).hexdigest()
         u = User(Name=username_, HashedPassword=hpassword, Email=email_)
         uid = u.put()
         self.response.headers.add_header('Set-Cookie', "user=%s|%s" % (uid.id(),hpassword))
         self.redirect("/welcome")
     else:
         self.render("signup.html", username=result[0], user_error=result[1],
                     password=result[2], pswd_error=result[3],
                     verify=result[4], verify_error=result[5],
                     email=result[6], email_error=result[7],
                     check=result[8])
Exemple #22
0
def main():
    customer1 = Customer("John Wick", "Makedonias 3")
    customer1.place_order(Order("20201215", Payment(100000)))
    customer1.place_order(Order("20201216", Payment(250000)))
    customer2 = Customer("Nemo", "MC Wallaby 42")
    customer2.place_order(
        Order("20201205", Credit(34235, "2349673", "20221010")))
    customer2.place_order(
        Order("20201205", Credit(5436, "2349673", "20221010")))
    customer3 = Customer("John Snow", "The Wall")
    customer3.place_order(Order("20201203", Payment(4234)))
    customer3.place_order(Order("20203905", Credit(5436, "746853",
                                                   "20221111")))
    customer3.place_order(
        Order("20203905", Check(654735, "555555", "20210203")))
    print(customer1)
    print("")
    print(customer2)
    print("")
    print(customer3)
Exemple #23
0
 def change_note(self):
     number = input('Введите номер телефона записи, которую надо изменить')
     handbook = open(self.name + '.txt', 'r')
     notes = handbook.read()
     handbook.seek(0)
     if number in notes:
         print('Введите новое значение:', end='\n')
         new_note_name = Check(input())
         if new_note_name.note_is_right():
             notes = handbook.readlines()
             handbook.close()
             handbook = open(self.name + '.txt', 'w')
             for note in notes:
                 if number in note:
                     handbook.write(new_note_name + '\n')
                 else:
                     handbook.write(note + '\n')
             print('Значение изменено.', end='\n')
         return
     print('Такой записи не существует.', end='\b')
Exemple #24
0
def main():
    proxies_list = []

    ip3366 = Ip3366()
    xici = Xici()
    kuai = Kuai()
    jiang = Jiang()
    qiyun = Qiyun()

    proxies_list.extend(ip3366.get_proxy())
    proxies_list.extend(xici.get_proxy())
    proxies_list.extend(kuai.get_proxy())
    proxies_list.extend(jiang.get_proxy())
    proxies_list.extend(qiyun.get_proxy())

    # 检测代理
    usable = Check(proxies_list)
    usable_proxies = usable.usable_proxies
    print(usable_proxies)

    put = Putproxy(usable_proxies)
    put.run()
Exemple #25
0
    def check_rs_button_click(self):
        """ Кнопка запуска цикла проверки радиостанции
            Запускает отдельный поток для проверки и формирует получение сигналов из этого потока
        """
        self.check_rs_button.setEnabled(False)
        try:
            self.thread = QThread()
            self.k2_functional.model = self.choice_of_the_model.currentText(
            )[3:]
            self.k2_functional.connect_com_port(self.k2_functional.port)

            self.new_check = Check(self.k2_functional, self.rs_functional)
            self.new_check.moveToThread(self.thread)
            self.new_check.next_screen_text.connect(self.screen_text.setText)
            self.new_check.next_message_box.connect(self.message_box)
            self.new_check.check_status.connect(self.get_check_result)

            self.thread.started.connect(self.new_check.run)
            self.thread.start()
        except Exception as exc:
            print(exc)
            self.check_rs_button.setEnabled(True)
Exemple #26
0
def main():
    stations = []
    print("please input stations which you need(split in space):")
    stations.append(input().split())
    station = stations[0]
    print("please input start year:")
    start_year = int(input())
    print("please input end year:")
    end_year = int(input())

    # 获取文件
    get_file = GetFile(start_year, end_year)
    get_file.getFile()
    get_file.getFileInt()

    path_nor = os.getcwd() + '\\station\\'
    fileListNor = os.listdir(path_nor)
    path_int = os.getcwd() + '\\stationInt\\'
    fileListInt = os.listdir(path_int)

    # 检测文件
    test = Check(fileListNor)
    test.countFile()

    # 统计台站观测信息
    print("counting....")
    count_station = CountStation(path_nor, fileListNor, station, start_year, end_year)
    count_station.count()
    # count_station = CountStation(path_int, fileListInt)
    # count_station.countInt()
    print("End")

    # 查寻某个台站的观测信息
    print("Do you need query anyone station Y/N:")
    choice = input()

    if choice == "Y":
        query()
Exemple #27
0
    def run(self):

        while True:
            CheckFunc = Check()
            CheckFunc.run()

            Products = CheckFunc.Products
            self.CpFile(Products)

            ErrorProducts = CheckFunc.ErrorProducts
            if not len(ErrorProducts):
                print("Products Basket OK")
                os.system("echo Products Basket OK|mail -r ProductsBasket [email protected]")
                break

            TargetFunc = Target(ErrorProducts)
            TargetFunc.run()

            NewOpenFunc = NewOpen(ErrorProducts)
            NewOpenFunc.run()

            AdjustFunc = Adjust(ErrorProducts)
            AdjustFunc.run()
Exemple #28
0
    async def run(self, loop):
        # 创建连接池
        pool = await aiomysql.create_pool(
            host=self.host,
            port=self.port,
            user=self.user,
            password=self.password,
            db=self.db,
            loop=loop,
        )

        proxies_get = await self.check_proxy(pool)

        check_proxy = Check(proxies_get)
        # 获得不能使用的proxies
        disable_proxies = check_proxy.disable_proxies

        for each in disable_proxies:
            await self.del_proxy(each, pool)

        # 连接池不用时
        pool.close()
        # 避免池中连接用完,等待连接断开
        await pool.wait_closed()
Exemple #29
0
 def __init__(self):
     self.check = Check()
     self.readCard = ReadCard()
     self.appendCard = AppendCard()
     self.cards = self.readCard.read()
     'building_strips_to_sas_dictionary', 'building_translation_key',
     'checking_invariant_weight', 'choosing_groups', 'collecting_mutex_groups',
     'completing_instantiation', 'computing_fact_groups', 'computing_model',
     'detecting_unreachable_propositions', 'done', 'finding_invariants',
     'generating_datalog_program', 'instantiating', 'instantiating_groups',
     'normalizing_datalog_program', 'normalizing_task', 'parsing',
     'preparing_model', 'processing_axioms', 'simplifying_axioms',
     'translating_task', 'writing_output')
])
SEARCH_ATTRIBUTES = [
    'dead_ends', 'evaluations', 'expansions', 'expansions_until_last_jump',
    'generated', 'reopened'
]
MEMORY_ATTRIBUTES = ['translator_peak_memory', 'memory']
RELATIVE_CHECKS = ([
    Check('initial_h_value', min_rel=1.0),
    Check('cost', max_rel=1.0),
    Check('plan_length', max_rel=1.0)
] + [
    Check('translator_%s' % attr, max_rel=1.0)
    for attr in TRANSLATOR_ATTRIBUTES
] + [
    Check(attr, max_rel=1.05, ignored_abs_diff=1) for attr in TIME_ATTRIBUTES
] + [Check(attr, max_rel=1.05) for attr in SEARCH_ATTRIBUTES] + [
    Check(attr, max_rel=1.05, ignored_abs_diff=1024)
    for attr in MEMORY_ATTRIBUTES
])

# Absolute attributes are reported, but not checked.
ABSOLUTE_ATTRIBUTES = [check.attribute for check in RELATIVE_CHECKS]