Skip to content

Commit b0821f0

Browse files
committed
Add repository test.
1 parent cbaacfa commit b0821f0

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from pathlib import Path
2+
3+
from aws_doc_sdk_examples_tools.fs import RecordFs
4+
from aws_doc_sdk_examples_tools.lliam.adapters.repository import PromptRepository
5+
from aws_doc_sdk_examples_tools.lliam.domain.model import Prompt
6+
7+
8+
def test_batch_naming_occurs_properly():
9+
"""Test that batch naming occurs properly when batching prompts."""
10+
fs = RecordFs({})
11+
repo = PromptRepository(fs=fs)
12+
13+
prompts = []
14+
for i in range(300):
15+
prompts.append(Prompt(f"prompt_{i}.md", f"Content for prompt {i}"))
16+
17+
repo.batch(prompts)
18+
19+
expected_batch_1_prompts = 150
20+
expected_batch_2_prompts = 150
21+
22+
batch_1_count = 0
23+
batch_2_count = 0
24+
for prompt_id in repo.to_write:
25+
if prompt_id.startswith("batch_1/"):
26+
batch_1_count += 1
27+
elif prompt_id.startswith("batch_2/"):
28+
batch_2_count += 1
29+
30+
assert batch_1_count == expected_batch_1_prompts
31+
assert batch_2_count == expected_batch_2_prompts

0 commit comments

Comments
 (0)