mirror of
https://github.com/dyrkin/luxmed-bot.git
synced 2025-12-21 13:23:05 +01:00
Fixed dataservice mock behaviour
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.parallel=true
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
|
||||
|
||||
org.gradle.jvmargs=-Dfile.encoding=UTF-8
|
||||
@@ -211,6 +211,7 @@ class Book(val userId: UserId, bot: Bot, apiService: ApiService, dataService: Da
|
||||
bot.sendMessage(userId.source, lang.appointmentIsConfirmed)
|
||||
stay()
|
||||
}
|
||||
case _ => sys.error(s"Can not prepare reservation request using booking data $bookingData")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,11 +75,13 @@ class ApiService extends SessionSupport {
|
||||
def getAvailableTerms(userId: Long, cityId: Long, clinicId: Option[Long], serviceId: Long, doctorId: Option[Long],
|
||||
fromDate: ZonedDateTime = ZonedDateTime.now(), toDate: Option[ZonedDateTime] = None, timeOfDay: Int = 0,
|
||||
languageId: Long = 10, findFirstFreeTerm: Boolean = false): Either[Throwable, List[AvailableVisitsTermPresentation]] =
|
||||
getDefaultPayer(userId, cityId, clinicId, serviceId).flatMap { case Some(payerId) =>
|
||||
getDefaultPayer(userId, cityId, clinicId, serviceId).flatMap {
|
||||
case Some(payerId) =>
|
||||
withSession(userId) { session =>
|
||||
LuxmedApi.availableTerms(session.accessToken, session.tokenType, payerId.id, cityId, clinicId, serviceId, doctorId,
|
||||
fromDate, toDate, timeOfDay, languageId, findFirstFreeTerm).map(_.availableVisitsTermPresentation)
|
||||
}
|
||||
case None => sys.error(s"Can't determine payer id by user: $userId, city: $cityId, clinic: $clinicId, service: $serviceId")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,13 +19,13 @@ class AuthSpec extends AkkaTestKit {
|
||||
val unauthorizedHelpActor = TestProbe()
|
||||
val loginActor = TestProbe()
|
||||
val chatActor = TestProbe()
|
||||
val unauthorizedHelpFactory: MessageSource => ActorRef = _ => unauthorizedHelpActor.ref
|
||||
val loginActorFactory: (MessageSource, ActorRef) => ActorRef = (_, _) => loginActor.ref
|
||||
val unauthorizedHelpFactory: ByMessageSourceActorFactory = _ => unauthorizedHelpActor.ref
|
||||
val loginActorFactory: ByMessageSourceWithOriginatorActorFactory = (_, _) => loginActor.ref
|
||||
val chatActorFactory: UserId => ActorRef = _ => chatActor.ref
|
||||
val dataService = mock(classOf[DataService])
|
||||
when(dataService.findUserIdBySource(source)).thenReturn(None)
|
||||
val auth = system.actorOf(Auth.props(source, dataService, unauthorizedHelpFactory, loginActorFactory, chatActorFactory))
|
||||
|
||||
when(dataService.findUserIdBySource(source)).thenReturn(None)
|
||||
|
||||
"send english help on /start command" in {
|
||||
val cmd = Command(source, Message("1", Some("/start")))
|
||||
@@ -75,13 +75,14 @@ class AuthSpec extends AkkaTestKit {
|
||||
val unauthorizedHelpActor = TestProbe()
|
||||
val loginActor = TestProbe()
|
||||
val chatActor = TestProbe()
|
||||
val unauthorizedHelpFactory: MessageSource => ActorRef = _ => unauthorizedHelpActor.ref
|
||||
val loginActorFactory: (MessageSource, ActorRef) => ActorRef = (_, _) => loginActor.ref
|
||||
val unauthorizedHelpFactory: ByMessageSourceActorFactory = _ => unauthorizedHelpActor.ref
|
||||
val loginActorFactory: ByMessageSourceWithOriginatorActorFactory = (_, _) => loginActor.ref
|
||||
val chatActorFactory: UserId => ActorRef = _ => chatActor.ref
|
||||
val dataService = mock(classOf[DataService])
|
||||
when(dataService.findUserIdBySource(source)).thenReturn(Some(userId.userId))
|
||||
|
||||
val auth = system.actorOf(Auth.props(source, dataService, unauthorizedHelpFactory, loginActorFactory, chatActorFactory))
|
||||
|
||||
when(dataService.findUserIdBySource(source)).thenReturn(Some(userId.userId))
|
||||
|
||||
"forward all commands to chat actor" in {
|
||||
val cmd = Command(source, Message("1", Some("any")))
|
||||
|
||||
Reference in New Issue
Block a user