Beispiel #1
0
def test_duck_compare(all_drivers):
    """
    Сценарий проверяет, что при клике на товар открывается правильная страница товара в учебном приложении litecart.
    """
    test_page = LiteCart(all_drivers)
    test_page.go_to_site()
    campaigns_block = test_page.find_element((By.ID, "box-campaigns"))
    first_duck = campaigns_block.find_elements_by_class_name('link')[0]
    first_duck_title = first_duck.get_attribute('title')
    first_duck_link = first_duck.get_attribute('href')
    duck_data_main_page = (test_page.get_duck_data())
    test_page.go_to_site(first_duck_link)
    duck_block = test_page.find_element((By.ID, "box-product"))
    duck_block_title = duck_block.find_element_by_class_name('title').text
    duck_data_page = (test_page.get_duck_data())
    # Сравнение заголовков
    check.equal(first_duck_title, duck_block_title, "Title is not equal!")
    for key in duck_data_main_page.keys():
        if key not in [
                "font_size_reg_price", "font_size_camp_price",
                "regular_price_main_page_color",
                "campaigns_price_main_page_color"
        ]:
            check.equal(duck_data_main_page[key], duck_data_page[key],
                        f"{key} param in not equal")

    test_pages = [duck_data_main_page, duck_data_page]
    for page in test_pages:
        # Проверка серого цвета обычной цены(r = g = b)
        check.equal(len(set(page["regular_price_main_page_color"])), 1)
        # Проверка красного цвета акционной цены (g и b = 0)
        check.equal(int(page["campaigns_price_main_page_color"][1]), 0)
        check.equal(int(page["campaigns_price_main_page_color"][2]), 0)
        # проверка, что акционная цена крупнее, чем обычная
        check.less(page["font_size_reg_price"], page["font_size_camp_price"])
Beispiel #2
0
def test_tencent_ml_train():
    t0 = time.time()
    ds = datasets.tencent_ml.TencentML7M('train', use_subset=True)
    check.less((time.time() - t0), (60.0 * 5))
    check.equal(len(ds), 916214 + 6607309)

    idx = 0
    image, labels = ds[idx]
    check.equal(image.size, (215, 258))
    check.equal(labels, [ds.subsets[idx] for idx in [2198, 2193, 2188, 2163, 1831, 1054, 1041, 865, 2]])

    idx = 458105
    image, labels = ds[idx]
    check.equal(image.size, (500, 375))
    check.equal(labels, [ds.subsets[idx] for idx in [7507, 7460, 7445, 7419, 6526, 6519, 6468, 5174, 5170, 1042, 865, 2]])

    idx = 916214 - 1
    image, labels = ds[idx]
    check.equal(image.size, (528, 600))
    check.equal(labels, [ds.subsets[idx] for idx in [7424, 7420, 7418, 6526, 6519, 6468, 5174, 5170, 1042, 865, 2]])

    idx = 916214
    image, labels = ds[idx]
    check.equal(image.size, (1024, 768))
    check.equal(labels, [ds.subsets[idx] for idx in [4097, 4089, 4063, 1837, 1054, 1041, 865, 2, 4129, 4132]])

    idx = 916214 + 3303654
    image, labels = ds[idx]
    check.equal(image.size, (1024, 681))
    check.equal(labels, [ds.subsets[idx] for idx in [5177, 5170]])

    idx = 916214 + 6607309 - 1
    image, labels = ds[idx]
    check.equal(image.size, (1024, 768))
    check.equal(labels, [ds.subsets[idx] for idx in [1193, 1053, 1379]])
Beispiel #3
0
def test_classify_frames():
    frame_list1 = example_job2.classify_frames()
    frame_list = example_job1.classify_frames()
    check.equal(frame_list1[0][0], 0)
    check.less(frame_list1[0][1], 0.7)
    check.not_equal(frame_list1[1][0], 5)
    check.greater(frame_list1[1][1], 0.7)

    check.equal(frame_list[0][0], 0)
    check.less(frame_list[0][1], 0.7)
    check.not_equal(frame_list[1][0], 4)
    check.greater(frame_list[1][1], 0.7)
Beispiel #4
0
def test_tencent_ml_validation():
    t0 = time.time()
    ds = datasets.tencent_ml.TencentML7M('validation')
    check.less((time.time() - t0), 30.0)
    check.equal(len(ds), 4824 + 38739)

    idx = 0
    image, labels = ds[idx]
    check.equal(image.size, (500, 375))
    check.equal(labels, [3371, 2609, 1833, 1054, 1041, 865, 2])

    idx = 4824 // 2 - 1
    image, labels = ds[idx]
    check.equal(image.size, (375, 500))
    check.equal(labels,
                [2095, 2094, 2092, 2065, 1905, 1829, 1054, 1041, 865, 2])

    idx = 4824 - 1
    image, labels = ds[idx]
    check.equal(image.size, (375, 500))
    check.equal(labels, [4858, 4822, 4781, 4767, 4765, 1067, 1041, 865, 2])

    idx = 4824
    image, labels = ds[idx]
    check.equal(image.size, (1024, 683))
    check.equal(labels, [
        5173, 5170, 1042, 865, 2, 11026, 892, 890, 884, 870, 859, 5851, 5193,
        5181, 9303, 9300, 9289, 1043, 11057, 9305
    ])

    idx = 4824 + 38739 // 2 - 1
    image, labels = ds[idx]
    check.equal(image.size, (1024, 686))
    check.equal(labels, [
        6866, 6854, 6781, 6767, 6522, 6519, 6468, 5174, 5170, 1042, 865, 2,
        6460, 6880, 6878
    ])

    idx = 4824 + 38739 - 1
    image, labels = ds[idx]
    check.equal(image.size, (1024, 601))
    check.equal(labels, [
        5173, 5170, 1042, 865, 2, 5851, 5193, 5181, 1314, 1300, 1192, 1053,
        1041
    ])
def test_get_reproduction_dist():
    environment = model.Environment(h=500, w=500)

    agents = [
        model.Agent(0, 0),
        model.Agent(0, 1),
        model.Agent(0, 2),
        model.Agent(0, 3),
    ]
    environment.agents = agents

    environment.heightmap[0, 0] = 8
    environment.heightmap[0, 1] = 6
    environment.heightmap[0, 2] = 4
    environment.heightmap[0, 3] = 2
    environment.rel_fitness = environment._get_relative_dist()

    environment.k = 1
    totally_equal = environment._get_reproduction_dist()
    environment.k = 0
    most_unequal = environment._get_reproduction_dist()
    environment.k = 0.5
    halfway_equal = environment._get_reproduction_dist()

    for elt in totally_equal:
        check.equal(elt, 0.25)

    check.less(most_unequal[3], most_unequal[2])
    check.less(most_unequal[2], most_unequal[1])
    check.less(most_unequal[1], most_unequal[0])

    for i in range(len(halfway_equal)):
        check.almost_equal(halfway_equal[i], 0.5*totally_equal[i] + 0.5*most_unequal[i])
Beispiel #6
0
def test_less():
    check.less(1, 2)
def test_get_relative_dist():
    environment = model.Environment(h=500, w=500)

    agents = [
        model.Agent(0, 0),
        model.Agent(0, 1),
        model.Agent(0, 2),
        model.Agent(0, 3),
    ]
    environment.agents = agents

    environment.heightmap[0, 0] = 1
    environment.heightmap[0, 1] = 1
    environment.heightmap[0, 2] = 1
    environment.heightmap[0, 3] = 1
    equal_fitness = environment._get_relative_dist()

    environment.heightmap[0, 0] = 0
    environment.heightmap[0, 1] = 0
    environment.heightmap[0, 2] = 0
    environment.heightmap[0, 3] = 10
    all_for_one_fitness = environment._get_relative_dist()

    agents = [
        model.Agent(0, 0),
        model.Agent(0, 1)
    ]
    environment.heightmap[0, 0] = 0.1
    environment.heightmap[0, 1] = 0.3
    quarter_seventyfive_fitness = environment._get_relative_dist()

    for fitness in equal_fitness:
        check.equal(fitness, 0.25)
    
    check.less(all_for_one_fitness[0] - 0, 0.001)
    check.less(all_for_one_fitness[1] - 0, 0.001)
    check.less(all_for_one_fitness[2] - 0, 0.001)
    check.less(all_for_one_fitness[3] - 1, 0.001)

    check.less(quarter_seventyfive_fitness[0] - 0.25, 0.001)
    check.less(quarter_seventyfive_fitness[1] - 0.75, 0.001)
 def check_lesser(self, actual, expected, message=None):
     if message is None:
         message = "Actual and expected results do not match"
     check.less(expected, actual, message)