Exemple #1
0
def test_render_template():
    path = pathlib.Path("./nbs/other/Assessment.ipynb")
    path_id = main.get_id(path)
    nb, _ = main.convert_html(path)
    nb = nb.replace("{{root}}", main.ROOT)
    html = main.render_template("content.html", {
        "nb": nb,
        "root": main.ROOT,
        "id": path_id,
    })

    assert type(html) is str
    assert main.ROOT in html
    assert path_id in html
    assert nb in html
Exemple #2
0
# unloaded = [165454370]
# for i in unloaded:
#     pre_parse("https://www.ozon.ru/context/detail/id/"+str(i)+"/", "v1")

for i in range(1, 21):
    if i == 2:
        i = 3
    driver.get("https://www.ozon.ru/category/televizory-15528/?page=" + str(i))
    driver.implicitly_wait(3)  # seconds
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    time.sleep(3)
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    elements = driver.find_elements_by_css_selector(
        'html body div#__nuxt div.layout-page.desktop div.block-vertical div.container.c0x2 div.c1d div.c0u9 div.ce4.c0v0 div div.widget-search-result-container.ap div.ap0>div')
    for j in range(0, len(elements)):
        element = elements[j]
        url = element.find_element_by_xpath("div/div/div[1]/a").get_attribute("href")
        id = get_id(url)
        if id == "172197496":
            flag = True
        if not flag:
            print(id + " skip")
            continue
        print(url)
        pre_parse(url, "v1")

driver.close()


Exemple #3
0
def test_get_id():
    path = pathlib.Path("./nbs/chapters/00-Introduction-to-the-course.ipynb")
    assert main.get_id(path) == "00"
Exemple #4
0
def test_get_id_with_no_id():
    path = pathlib.Path("./nbs/other/Assessment.ipynb")
    assert main.get_id(path) == "assessment"
 def test_id(self):
     os.environ['ID'] = 'testid'
     self.assertEqual(m.get_id(), 'testid')
 def test_none(self):
     # IDという環境変数があれば削除する
     os.environ.pop('ID', None)
     self.assertEqual(m.get_id(), None)
Exemple #7
0
 def test_get_id(self):
     url = 'https://twitter.com/bak840/status/1362860958092316675?s=20'
     result = get_id(url)
     self.assertEqual(result, '1362860958092316675')