def test_get_vehicledata_returns_200_if_successful(mock_dynamo_cv_table, mock_dynamodb, setup_siriusxm_service, mock_logger): cv_table = get_main_table(DynamoConfig(table_name=TABLE_NAME)) config = SiriusXmConfig(base_url=URL, api_key=APIKEY, raw_apikey=RAWAPIKEY) uut = SiriusXmService(config=config, table=cv_table) uut.save_vehicledata(generate_valid_cv_data()) response = uut.get_vehicledata(id="TESTREFERENCE", programcode="infiniti") assert type(response) == VehicleData assert response.calldate == response.timestamp.strftime("%Y-%m-%d") assert response.calltime == response.timestamp.strftime("%H:%M") assert response.status == InternalStatusType.SUCCESS assert response.referenceid == "TESTREFERENCE" assert response.programcode == "infiniti"
def test_save_vehicledata_returns_true_if_successful(mock_dynamodb, setup_siriusxm_service, mock_logger): cv_table = get_main_table(DynamoConfig(table_name=TABLE_NAME)) config = SiriusXmConfig(base_url=URL, api_key=APIKEY, raw_apikey=RAWAPIKEY) uut = SiriusXmService(config=config, table=cv_table) cv = generate_valid_cv_data() assert uut.save_vehicledata(cv) conn = boto3.resource("dynamodb", region_name="us-east-1") table = conn.Table(TABLE_NAME) item = table.query( Limit=1, ScanIndexForward=False, KeyConditionExpression=Key("request_key").eq("infiniti-TESTREFERENCE"), ) assert item["Items"][0]["latitude"] == Decimal("42.406") assert item["Items"][0]["vin"] == cv["vin"]