File size: 998 Bytes
6020ae0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from main import ProcessCollection, RunChain, RunGraph
from dotenv import load_dotenv

# Setup environment variables
load_dotenv(dotenv_path=".env", override=True)

# Define email and database directories
email_dir = "test_emails/R-help/"
db_dir = "test_db"


def test_main():

    # Create the test database
    ProcessCollection(email_dir, db_dir)

    # Define the collection (last part of the email directory path)
    collection = "R-help"

    # Run a query with the chain workflow
    result = RunChain("What R functions are discussed?", db_dir, collection)
    # We should get at least one of these
    assert (
        "aggregate" in result
        or "t.test" in result
        or "lme" in result
        or "ifelse" in result
        or "xyplot" in result
    )

    # Run a query with the graph workflow
    result = RunGraph(
        "What dataset was used in a question about plotting with nlme?",
        db_dir,
        collection,
    )
    assert "BodyWeight" in result["answer"]