Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deedy5 committed Nov 14, 2024
1 parent 2a48835 commit 729430c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@pytest.fixture(autouse=True)
def pause_between_tests():
time.sleep(0.5)
time.sleep(1)


def test_version_command():
Expand Down Expand Up @@ -70,7 +70,7 @@ def test_save_csv(tmp_path):
keywords = "butterfly"
with DDGS() as ddgs:
results = ddgs.text(keywords, max_results=30)
assert 27 <= len(results) <= 30
assert 25 <= len(results) <= 30

temp_file = tmp_path / f"{keywords}.csv"
_save_csv(temp_file, results)
Expand All @@ -81,7 +81,7 @@ def test_save_json(tmp_path):
keywords = "chicago"
with DDGS() as ddgs:
results = ddgs.text(keywords, max_results=30)
assert 27 <= len(results) <= 30
assert 25 <= len(results) <= 30

temp_file = tmp_path / f"{keywords}.json"
_save_json(temp_file, results)
Expand All @@ -94,7 +94,7 @@ def test_text_download():
results = ddgs.text(keywords, max_results=8)
assert 7 <= len(results) <= 8

_download_results(keywords, results)
_download_results(keywords, results, function_name="text")

# delete files contains keyword in name
files = False
Expand All @@ -121,7 +121,7 @@ def test_images_download():
results = ddgs.images(keywords, max_results=8)
assert len(results) >= 8

_download_results(keywords, results, images=True)
_download_results(keywords, results, function_name="images")

# delete files contains keyword in name
files = False
Expand Down
8 changes: 4 additions & 4 deletions tests/test_duckduckgo_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@pytest.fixture(autouse=True)
def pause_between_tests():
time.sleep(0.5)
time.sleep(1)


def test_context_manager():
Expand All @@ -23,17 +23,17 @@ def test_chat(model):

def test_text():
results = DDGS().text("cat", safesearch="off", timelimit="m", max_results=30)
assert 27 <= len(results) <= 30
assert 25 <= len(results) <= 30


def test_text_html():
results = DDGS().text("eagle", backend="html", max_results=30)
assert 27 <= len(results) <= 30
assert 25 <= len(results) <= 30


def test_text_lite():
results = DDGS().text("dog", backend="lite", max_results=30)
assert 27 <= len(results) <= 30
assert 25 <= len(results) <= 30


def test_images():
Expand Down
8 changes: 4 additions & 4 deletions tests/test_duckduckgo_search_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@pytest.fixture(autouse=True)
def pause_between_tests():
time.sleep(0.5)
time.sleep(1)

@pytest.mark.asyncio
async def test_context_manager():
Expand All @@ -25,19 +25,19 @@ async def test_chat(model):
@pytest.mark.asyncio
async def test_text():
results = await AsyncDDGS().atext("sky", safesearch="off", timelimit="m", max_results=30)
assert 27 <= len(results) <= 30
assert 25 <= len(results) <= 30


@pytest.mark.asyncio
async def test_text_html():
results = await AsyncDDGS().atext("eagle", backend="html", max_results=30)
assert 27 <= len(results) <= 30
assert 25 <= len(results) <= 30


@pytest.mark.asyncio
async def test_text_lite():
results = await AsyncDDGS().atext("dog", backend="lite", max_results=30)
assert 27 <= len(results) <= 30
assert 25 <= len(results) <= 30


@pytest.mark.asyncio
Expand Down

0 comments on commit 729430c

Please sign in to comment.