From 480a754db60ce0aa0ff47375b40e17f0a43f8da4 Mon Sep 17 00:00:00 2001 From: kotva006 Date: Wed, 8 May 2024 13:49:53 -0500 Subject: [PATCH] Updated realtime schedules to use prediction repo --- lib/dotcom/realtime_schedule.ex | 5 +++-- test/dotcom/realtime_schedule_test.exs | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/dotcom/realtime_schedule.ex b/lib/dotcom/realtime_schedule.ex index fbf6548e39..6d863a4f65 100644 --- a/lib/dotcom/realtime_schedule.ex +++ b/lib/dotcom/realtime_schedule.ex @@ -11,7 +11,6 @@ defmodule Dotcom.RealtimeSchedule do alias Dotcom.JsonHelpers alias Dotcom.TransitNearMe alias Predictions.Prediction - alias Predictions.Repo, as: PredictionsRepo alias RoutePatterns.RoutePattern alias Routes.Repo, as: RoutesRepo alias Routes.Route @@ -25,10 +24,12 @@ defmodule Dotcom.RealtimeSchedule do @predicted_schedules_per_stop 2 + @predictions_repo Application.compile_env!(:dotcom, :repo_modules)[:predictions] + @default_opts [ stops_fn: &StopsRepo.get/1, routes_fn: &RoutesRepo.by_stop_with_route_pattern/1, - predictions_fn: &PredictionsRepo.all_no_cache/1, + predictions_fn: Function.capture(@predictions_repo, :all_no_cache, 1), schedules_fn: &SchedulesRepo.by_route_ids/2, alerts_fn: &Alerts.Repo.by_route_ids/2 ] diff --git a/test/dotcom/realtime_schedule_test.exs b/test/dotcom/realtime_schedule_test.exs index 1673c54e58..f17bd88a94 100644 --- a/test/dotcom/realtime_schedule_test.exs +++ b/test/dotcom/realtime_schedule_test.exs @@ -1,6 +1,8 @@ defmodule Dotcom.RealtimeScheduleTest do use ExUnit.Case + import Mox + alias Alerts.Alert alias Alerts.InformedEntity, as: IE alias Alerts.InformedEntitySet, as: IESet @@ -175,10 +177,11 @@ defmodule Dotcom.RealtimeScheduleTest do end test "stop_data/3 returns stop" do + expect(Predictions.Repo.Mock, :all_no_cache, 3, fn _ -> @predictions end) + opts = [ stops_fn: fn _ -> @stop end, routes_fn: fn _ -> @route_with_patterns end, - predictions_fn: fn _ -> @predictions end, schedules_fn: fn _, _ -> @schedules end, alerts_fn: fn _, _ -> @alerts end ] @@ -301,10 +304,11 @@ defmodule Dotcom.RealtimeScheduleTest do end test "stop_data/3 returns nil" do + expect(Predictions.Repo.Mock, :all_no_cache, fn _ -> [] end) + opts = [ stops_fn: fn _ -> nil end, routes_fn: fn _ -> [] end, - predictions_fn: fn _ -> [] end, schedules_fn: fn _, _ -> [] end, alerts_fn: fn _, _ -> [] end ]