from app.adapters.store_api_adapter import StoreApiAdapter
from app.entities.agent_data import AccelerometerData, AgentData, GpsData
from app.entities.processed_agent_data import ProcessedAgentData

def _test_processed_agent_data_batch_to_payload():
    processed_data_batch = [
            ProcessedAgentData(road_state = "normal",
                               agent_data = AgentData(user_id = 1,
                                                      accelerometer = AccelerometerData(x = 0.1, y = 0.2, z = 0.3),
                                                      gps = GpsData(latitude = 10.123, longitude = 20.456),
                                                      timestamp = "2023-07-21T12:34:56Z")
            ),
            ProcessedAgentData(road_state = "normal",
                               agent_data = AgentData(user_id = 2,
                                                      accelerometer = AccelerometerData(x = 0.1, y = 0.2, z = 0.3),
                                                      gps = GpsData(latitude = 10.123, longitude = 20.456),
                                                      timestamp = "2023-07-21T12:34:56Z")
            ),
            ProcessedAgentData(road_state = "normal",
                               agent_data = AgentData(user_id = 3,
                                                      accelerometer = AccelerometerData(x = 0.1, y = 0.2, z = 0.3),
                                                      gps = GpsData(latitude = 10.123, longitude = 20.456),
                                                      timestamp = "2023-07-21T12:34:56Z")
            ),
    ]

    res = StoreApiAdapter(None).processed_agent_data_batch_to_payload(processed_data_batch)

    assert res["data"][0]["agent_data"]["user_id"] == 1
    assert res["data"][1]["agent_data"]["user_id"] == 2
    assert res["data"][2]["agent_data"]["user_id"] == 3

    assert StoreApiAdapter(None).processed_agent_data_batch_to_payload([]) == False


if __name__ == "__main__":
    test_functions = [i for i in dir() if i.startswith('_test_')]

    for i in test_functions:
        print(i)
        eval(i)()
