Skip to content

Commit

Permalink
Updated realtime schedules to use prediction repo
Browse files Browse the repository at this point in the history
  • Loading branch information
kotva006 committed May 8, 2024
1 parent 4a64af7 commit 480a754
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/dotcom/realtime_schedule.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
]
Expand Down
8 changes: 6 additions & 2 deletions test/dotcom/realtime_schedule_test.exs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
]
Expand Down Expand Up @@ -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
]
Expand Down

0 comments on commit 480a754

Please sign in to comment.