Example #1
0
    def test_get_callback(self):
        data.clear()
        data.add_callback("googleKeyboard", "keyboard", "A_DOWN",
                ["touch", "DOWN_AND_UP", "200", "400"])
        self.assertEqual(
                data.get_callback("googleKeyboard", "keyboard", "A_DOWN"),
                ["touch", "DOWN_AND_UP", "200", "400"])

        self.assertEqual(
                data.get_callback("googleKeyboard", "keyboard", "no_key"),
                data.NO_CALLBACK)
        self.assertEqual(
                data.get_callback("googleKeyboard", "no_type", "A_DOWN"),
                data.NO_CALLBACK)
        self.assertEqual(
                data.get_callback("no_mode", "keyboard", "A_DOWN"),
                data.NO_CALLBACK)

        data.add_callback(data.DEFAULT_EVENT_MODE, "keyboard",
                          "B_DOWN", ["a", ["c", "d"]])
        self.assertEqual(
                data.get_callback("", "keyboard", "B_DOWN"),
                ["a", ["c", "d"]])
        self.assertEqual(
                data.get_callback("default", "keyboard", "B_DOWN"),
                ["a", ["c", "d"]])
Example #2
0
    def test_set_mode(self):
        data.clear()
        data.set_mode("abcd")
        self.assertEqual(data._current_event_mode, "abcd")

        data.set_mode(None)
        self.assertEqual(data.get_mode(), "abcd")
Example #3
0
    def test_add_callback(self):
        data.clear()
        data.add_callback("abc", "def", "VALUE",
                ["weird", "list", "grrr"])
        self.assertEqual(data.get_callback("abc", "def", "VALUE"),
                ["weird", "list", "grrr"])
        data.add_callback("abc", "def", "VALUE",
                ["normal", "new list", "varrr"])
        self.assertEqual(data.get_callback("abc", "def", "VALUE"),
                ["normal", "new list", "varrr"])

        # Add None is equal to remove.
        data.add_callback("abc", "def", "VALUE", None)
        self.assertEqual(data.get_callback("abc", "def", "VALUE"),
                data.NO_CALLBACK)

        data.add_callback("", "abc", "def", [["code1", "arg1"],["code2"]])
        self.assertEqual(data.get_callback(
                data.DEFAULT_EVENT_MODE, "abc", "def"),
                [["code1", "arg1"], ["code2"]])
        data.add_callback("default", "abc", "def",
                [["code1", "arg1"],["code2"]])
        self.assertEqual(data.get_callback(
                data.DEFAULT_EVENT_MODE, "abc", "def"),
                [["code1", "arg1"], ["code2"]])
Example #4
0
 def test_clear(self):
     data.clear()
     data.add_callback("foo", "bar", "bzrrr", ["a", "b", "c"])
     self.assertEqual(data.get_callback("foo", "bar", "bzrrr"),
             ["a", "b", "c"])
     data.clear()
     self.assertEqual(data.get_callback("foo", "bar", "bzrrr"),
             data.NO_CALLBACK)
Example #5
0
 def test_event(self):
     data.clear()
     data.add_callback("", "typeB", "valueC",
             [
                 ["_mock_function",
                     ["arg", "1"], ["arg", "2"], ["arg", "3"]]
             ])
     self.assertEqual(ashval.ashval("event default typeB valueC 10 20 33"),
             "_mock_function : 10, 20, 33")
Example #6
0
def go1():#输入文法及待测表达式
    text2.delete(1.0,END)
    text3.delete(1.0,END)
    data.clear()
    text1.update()
    a = text1.get('1.0',END)
    data.array = a.strip().split('\n')
    data.stringJudge = data.array[-1]
    data.array.pop()
    print(data.array)
    algorithm.work()
Example #7
0
 def test_show(self):
     data.clear()
     data.add_callback("a", "b", "c", ["d", "e", "f", "g"])
     data.add_callback("a", "c", "d", ["d", "e", "f", "g"])
     data.add_callback("b", "c", "d", ["g", "h"])
     data.add_callback("c", "d", "e", ["aaa", "bbb"])
     data.add_callback("ab", "cd", "ef", ["foo"])
     self.assertEqual(data.show(0), [["a", "ab", "b", "c"]])
     self.assertEqual(data.show(1),
             [["a",
                 ["b", "c"],
              "ab",
                 ["cd"],
              "b",
                 ["c"],
              "c",
                 ["d"]
                 ]])
     self.assertEqual(data.show(2),
             [["a",
                 ["b", ["c"],
                  "c", ["d"]],
              "ab",
                 ["cd", ["ef"]],
              "b",
                 ["c", ["d"]],
              "c",
                 ["d", ["e"]]
                 ]])
     self.assertEqual(data.show(3),
             [["a",
                 ["b",
                     ["c",
                         ["d", "e", "f", "g"]],
                  "c",
                     ["d",
                         ["d", "e", "f", "g"]]],
              "ab",
                 ["cd",
                     ["ef",
                         ["foo"]]],
              "b",
                 ["c",
                     ["d",
                         ["g", "h"]]],
              "c",
                 ["d",
                     ["e",
                         ["aaa", "bbb"]]]
                 ]])
Example #8
0
 def test_save_to_file(self):
     data.clear()
     data.load_from_file("data_2.0.xml")
     data.save_to_file("data_2.0_write_test.xml")
     data.clear()
     data.load_from_file("data_2.0_write_test.xml")
     self.assertEqual(
             data.get_callback("googleKeyboard", "keyboard", "A_DOWN"),
             ["touch", "DOWN_AND_UP", "300", "680"])
     self.assertEqual(
             data.get_callback("default", "alias", "click"),
             [["touch", "DOWN", ["arg", "1"], ["arg", "2"]],
                 ["sleep", "0.1"],
                 ["touch", "UP", ["arg", "1"], ["arg", "2"]]
                 ])
Example #9
0
def logom(username, passwrod):
    clear()
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '7.0'
    desired_caps['deviceName'] = 'KWG5T16C26014368'
    desired_caps['appPackage'] = 'cn.sanfast.zhuoer.student'  # 被测App的包名
    desired_caps[
        'appActivity'] = 'cn.sanfast.zhuoer.student.activity.splash.SplashActivity'  # 启动时的Activity
    desired_caps['unicodeKeyboard'] = True
    desired_caps['resetKeyboard'] = True
    desired_caps['newCommandTimeout'] = 7200
    driver = webdriver.Remote('http://*****:*****@index='0']")
    if a:
        driver.find_element_by_id(
            "cn.sanfast.zhuoer.student:id/dialog_btn_cancel").click()

    b = driver.find_element_by_xpath(
        "//android.widget.FrameLayout[@index='0']")
    if b:
        driver.find_element_by_id("android:id/button1").click()
        driver.find_element_by_id("android:id/button1").click()
        driver.find_element_by_id("android:id/button1").click()

    s = driver.get_window_size()

    driver.swipe(s['width'] * 0.8, s['height'] * 0.6, s['width'] * 0.01,
                 s['height'] * 0.6, 500)
    driver.swipe(s['width'] * 0.8, s['height'] * 0.6, s['width'] * 0.01,
                 s['height'] * 0.6, 500)
    driver.swipe(s['width'] * 0.8, s['height'] * 0.6, s['width'] * 0.01,
                 s['height'] * 0.6, 500)
    driver.tap([(593, 1555)], 500)
    driver.find_element_by_xpath(
        "//android.widget.RadioButton[@text='我的']").click()
    driver.find_element_by_id("cn.sanfast.zhuoer.student:id/et_phone").click()
    driver.find_element_by_id(
        "cn.sanfast.zhuoer.student:id/et_phone").send_keys("13052821327")
    driver.find_element_by_id(
        "cn.sanfast.zhuoer.student:id/et_password").click()
    driver.find_element_by_id(
        "cn.sanfast.zhuoer.student:id/et_password").send_keys("123456")
    driver.find_element_by_id("cn.sanfast.zhuoer.student:id/btn_login").click()
Example #10
0
def initY86(linelist):#初始化Y86中的所有内容
    data.clear()#清空
    Readin.linelist=linelist[:]#复制文件字符串
    Readin.readin()#写入内存
Example #11
0
from logom import id, xpath, window_size, swip_up, tap, yinshi, find_element, tap1
import time
import datetime
from time import sleep
#driver=driver()
from data import clear
clear()
sleep(4)
yinshi(20)


def login_qidongye(username, password):
    s = window_size()

    sleep(5)

    try:

        a = xpath("//android.widget.RelativeLayout[@index='0']")
    except Exception as rst:
        rst = 0
    else:
        rst = 1

        id("cn.sanfast.zhuoer.student:id/dialog_btn_cancel").click()

    try:
        b = xpath("//android.widget.LinearLayout[@index='0']")

    except Exception as ret:
        rst = 0
Example #12
0
def initY86(linelist):
    data.clear()
    Readin.linelist = linelist[:]
    Readin.readin()
async def clear(ctx):
    data.clear(ctx)
    await ctx.send("Cleared your data")
Example #14
0
def initY86(linelist):  #初始化Y86中的所有内容
    data.clear()  #清空
    Readin.linelist = linelist[:]  #复制文件字符串
    Readin.readin()  #写入内存
Example #15
0
 def test_get_mode(self):
     data.clear()
     self.assertEqual(data.get_mode(), data.DEFAULT_EVENT_MODE)
     data._current_event_mode = "grrr"
     self.assertEqual(data.get_mode(), "grrr")
Example #16
0
import pytest
import data
from error import *
from comments import *
from login_system import *

data.clear()


@pytest.fixture
def users():
    return [
        user_register('user1', 'password1'),
        user_register('user2', 'password2'),
        user_register('user3', 'password3'),
        user_register('user4', 'password4')
    ]


'''
Testing for comments_add
'''


def test_comments_add(users):
    assert user_login('user1', 'password1') == True
    assert user_login('user3', 'password3') == True

    # error catching tests
    with pytest.raises(AccessError):
        comments_add(10, 'Margarita', 'good', '19/04/2021, 05:34:57')
Example #17
0
def initY86(linelist):
    data.clear()
    Readin.linelist=linelist[:]
    Readin.readin()
Example #18
0
 def tearDown(self):
     clear()
     self.testbed.deactivate()