|
| 1 | +from vectorcode.chunking import Chunk |
| 2 | +from vectorcode.database.types import QueryResult, VectoriseStats |
| 3 | + |
| 4 | +""" |
| 5 | +For boilerplate code that wasn't covered in other tests. |
| 6 | +""" |
| 7 | + |
| 8 | + |
| 9 | +def test_vectorstats_add(): |
| 10 | + assert VectoriseStats( |
| 11 | + add=1, update=2, removed=3, skipped=4, failed=5 |
| 12 | + ) + VectoriseStats( |
| 13 | + add=5, update=4, removed=3, skipped=2, failed=1 |
| 14 | + ) == VectoriseStats(add=6, update=6, removed=6, skipped=6, failed=6) |
| 15 | + |
| 16 | + assert VectoriseStats( |
| 17 | + add=1, update=2, removed=3, skipped=4, failed=5 |
| 18 | + ) + VectoriseStats( |
| 19 | + add=5, update=4, removed=3, skipped=2, failed=1 |
| 20 | + ) != VectoriseStats(add=6, update=6, removed=6, skipped=6, failed=5) |
| 21 | + |
| 22 | + |
| 23 | +def test_query_result_equal(): |
| 24 | + assert QueryResult( |
| 25 | + path="some_path", |
| 26 | + chunk=Chunk(text="some_text"), |
| 27 | + query=("some_query",), |
| 28 | + scores=(1,), |
| 29 | + ) == QueryResult( |
| 30 | + path="other_path", |
| 31 | + chunk=Chunk(text="other_text"), |
| 32 | + query=("some_query",), |
| 33 | + scores=(1.0,), |
| 34 | + ) |
| 35 | + |
| 36 | + assert QueryResult( |
| 37 | + path="some_path", |
| 38 | + chunk=Chunk(text="some_text"), |
| 39 | + query=("some_query",), |
| 40 | + scores=(1,), |
| 41 | + ) != QueryResult( |
| 42 | + path="other_path", |
| 43 | + chunk=Chunk(text="other_text"), |
| 44 | + query=("some_query",), |
| 45 | + scores=(2.0,), |
| 46 | + ) |
0 commit comments