Skip to content

Commit

Permalink
Add tag to more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredb96 committed Jun 26, 2024
1 parent 2f918d5 commit b29fc83
Show file tree
Hide file tree
Showing 5 changed files with 294 additions and 287 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
//package hmda.analytics.query
//
//import java.time.{ LocalDateTime, ZoneOffset }
//
//import hmda.model.filing.submission.SubmissionId
//import hmda.utils.EmbeddedPostgres
//import hmda.utils.YearUtils.Period
//import org.scalatest.{ AsyncWordSpec, MustMatchers }
//
//class SubmissionHistoryComponentSpec extends AsyncWordSpec with SubmissionHistoryComponent with EmbeddedPostgres with MustMatchers {
// "SubmissionHistoryRepository" must {
// "be able to persist data" in {
// val repo = new SubmissionHistoryRepository(dbConfig, "submission_history") // as per hmda.sql
// val lei = "EXAMPLE-LEI"
// val timeNow = LocalDateTime.now()
//
// repo
// .insert(lei, SubmissionId(lei, Period(2018, None), 1), Some(timeNow.toEpochSecond(ZoneOffset.UTC)))
// .map(res => res mustBe 1)
// }
// }
//
// override def bootstrapSqlFile: String = "hmda.sql"
//}
package hmda.analytics.query

import java.time.{LocalDateTime, ZoneOffset}
import hmda.model.filing.submission.SubmissionId
import hmda.utils.EmbeddedPostgres
import hmda.utils.YearUtils.Period
import org.scalatest.{AsyncWordSpec, MustMatchers, Tag}

object CustomTag extends Tag("actions-ignore")

class SubmissionHistoryComponentSpec extends AsyncWordSpec with SubmissionHistoryComponent with EmbeddedPostgres with MustMatchers {
"SubmissionHistoryRepository" must {
"be able to persist data" taggedAs CustomTag in {
val repo = new SubmissionHistoryRepository(dbConfig, "submission_history") // as per hmda.sql
val lei = "EXAMPLE-LEI"
val timeNow = LocalDateTime.now()

repo
.insert(lei, SubmissionId(lei, Period(2018, None), 1), Some(timeNow.toEpochSecond(ZoneOffset.UTC)))
.map(res => res mustBe 1)
}
}

override def bootstrapSqlFile: String = "hmda.sql"
}
Original file line number Diff line number Diff line change
@@ -1,138 +1,140 @@
//package hmda.publisher.validation
//
//import akka.actor.ActorSystem
//import akka.testkit.TestKit
//import hmda.publisher.query.component.{ PublisherComponent2018, TransmittalSheetTable, TsRepository }
//import hmda.publisher.query.lar.{ LarEntityImpl2018, LarPartFive2018, LarPartFour2018, LarPartOne2018, LarPartSix2018, LarPartThree2018, LarPartTwo2018 }
//import hmda.query.ts.TransmittalSheetEntity
//import hmda.utils.EmbeddedPostgres
//import org.scalatest.concurrent.{ PatienceConfiguration, ScalaFutures }
//import org.scalatest.time.{ Millis, Minutes, Span }
//import org.scalatest.{ BeforeAndAfterAll, BeforeAndAfterEach, FreeSpecLike, Matchers }
//
//import scala.concurrent.duration.DurationInt
//import scala.concurrent.{ Await, Future }
//
//class TSLinesCheckTest
// extends TestKit(ActorSystem("PublisherComponent2018Spec"))
// with FreeSpecLike
// with Matchers
// with ScalaFutures
// with EmbeddedPostgres
// with BeforeAndAfterAll
// with BeforeAndAfterEach
// with PublisherComponent2018
// with PatienceConfiguration {
//
// import scala.concurrent.ExecutionContext.Implicits.global
//
// override implicit def patienceConfig: PatienceConfig = PatienceConfig(timeout = Span(2, Minutes), interval = Span(100, Millis))
//
// val tsRepo2018 = new TsRepository[TransmittalSheetTable](dbConfig, transmittalSheetTable2018)
// val larRepo2018 = new LarRepository2018(dbConfig)
//
// override def beforeAll(): Unit = {
// super.beforeAll()
// Await.ready(
// Future.sequence(
// List(
// tsRepo2018.createSchema(),
// larRepo2018.createSchema()
// )
// ),
// 30.seconds
// )
// }
//
// "no data in lar" in {
//
// val lei1 = "EXAMPLE-LEI"
// val ts1 = TransmittalSheetEntity(lei = lei1, totalLines = 10, submissionId = Some("sub1"))
//
// val check = new TSLinesCheck(dbConfig, validationTSData2018, validationLarData2018)
//
// val test = for {
// _ <- tsRepo2018.insert(ts1)
// result <- check.check()
// _ = assert(
// result == Left(
// """Some of the LEIs has different counts of records in Transmittal Sheet table and in LAR table.
// |LEI: EXAMPLE-LEI, submissionId: sub1, countFromTs: 10, countFromLar: null""".stripMargin
// )
// )
// } yield ()
//
// test.futureValue
//
// }
//
// "different data in lar" in {
//
// val lei1 = "EXAMPLE-LEI"
// val ts1 = TransmittalSheetEntity(lei = lei1, totalLines = 10, submissionId = Some("sub1"))
// val check = new TSLinesCheck(dbConfig, validationTSData2018, validationLarData2018)
// val test = for {
// _ <- tsRepo2018.insert(ts1)
// _ <- larRepo2018.insert(dummyLar2018)
// _ <- larRepo2018.insert(dummyLar2018)
// result <- check.check()
// _ = assert(
// result == Left(
// """Some of the LEIs has different counts of records in Transmittal Sheet table and in LAR table.
// |LEI: EXAMPLE-LEI, submissionId: sub1, countFromTs: 10, countFromLar: 2""".stripMargin
// )
// )
// } yield ()
//
// test.futureValue
//
// }
//
// "matching data in lar - 0" in {
//
// val lei1 = "EXAMPLE-LEI"
// val ts1 = TransmittalSheetEntity(lei = lei1, totalLines = 0, submissionId = Some("sub1"))
//
// val check = new TSLinesCheck(dbConfig, validationTSData2018, validationLarData2018)
//
// val test = for {
// _ <- tsRepo2018.insert(ts1)
// result <- check.check()
// _ = assert(
// result == Right(())
// )
// } yield ()
//
// test.futureValue
//
// }
//
// "matching data in lar - non 0" in {
//
// val lei1 = "EXAMPLE-LEI"
// val ts1 = TransmittalSheetEntity(lei = lei1, totalLines = 1, submissionId = Some("sub1"))
// val check = new TSLinesCheck(dbConfig, validationTSData2018, validationLarData2018)
// val test = for {
// _ <- tsRepo2018.insert(ts1)
// _ <- larRepo2018.insert(dummyLar2018)
// result <- check.check()
// _ = assert(
// result == Right(())
// )
// } yield ()
//
// test.futureValue
//
// }
//
// def dummyLar2018 = LarEntityImpl2018(
// LarPartOne2018(lei = "EXAMPLE-LEI"),
// LarPartTwo2018(),
// LarPartThree2018(),
// LarPartFour2018(),
// LarPartFive2018(),
// LarPartSix2018()
// )
//
// override def bootstrapSqlFile: String = ""
//}
package hmda.publisher.validation

import akka.actor.ActorSystem
import akka.testkit.TestKit
import hmda.publisher.query.component.{PublisherComponent2018, TransmittalSheetTable, TsRepository}
import hmda.publisher.query.lar.{LarEntityImpl2018, LarPartFive2018, LarPartFour2018, LarPartOne2018, LarPartSix2018, LarPartThree2018, LarPartTwo2018}
import hmda.query.ts.TransmittalSheetEntity
import hmda.utils.EmbeddedPostgres
import org.scalatest.concurrent.{PatienceConfiguration, ScalaFutures}
import org.scalatest.time.{Millis, Minutes, Span}
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, FreeSpecLike, Matchers, Tag}

import scala.concurrent.duration.DurationInt
import scala.concurrent.{Await, Future}

object CustomTag extends Tag("actions-ignore")

class TSLinesCheckTest
extends TestKit(ActorSystem("PublisherComponent2018Spec"))
with FreeSpecLike
with Matchers
with ScalaFutures
with EmbeddedPostgres
with BeforeAndAfterAll
with BeforeAndAfterEach
with PublisherComponent2018
with PatienceConfiguration {

import scala.concurrent.ExecutionContext.Implicits.global

override implicit def patienceConfig: PatienceConfig = PatienceConfig(timeout = Span(2, Minutes), interval = Span(100, Millis))

val tsRepo2018 = new TsRepository[TransmittalSheetTable](dbConfig, transmittalSheetTable2018)
val larRepo2018 = new LarRepository2018(dbConfig)

override def beforeAll(): Unit = {
super.beforeAll()
Await.ready(
Future.sequence(
List(
tsRepo2018.createSchema(),
larRepo2018.createSchema()
)
),
30.seconds
)
}

"no data in lar" taggedAs CustomTag in {

val lei1 = "EXAMPLE-LEI"
val ts1 = TransmittalSheetEntity(lei = lei1, totalLines = 10, submissionId = Some("sub1"))

val check = new TSLinesCheck(dbConfig, validationTSData2018, validationLarData2018)

val test = for {
_ <- tsRepo2018.insert(ts1)
result <- check.check()
_ = assert(
result == Left(
"""Some of the LEIs has different counts of records in Transmittal Sheet table and in LAR table.
|LEI: EXAMPLE-LEI, submissionId: sub1, countFromTs: 10, countFromLar: null""".stripMargin
)
)
} yield ()

test.futureValue

}

"different data in lar" taggedAs CustomTag in {

val lei1 = "EXAMPLE-LEI"
val ts1 = TransmittalSheetEntity(lei = lei1, totalLines = 10, submissionId = Some("sub1"))
val check = new TSLinesCheck(dbConfig, validationTSData2018, validationLarData2018)
val test = for {
_ <- tsRepo2018.insert(ts1)
_ <- larRepo2018.insert(dummyLar2018)
_ <- larRepo2018.insert(dummyLar2018)
result <- check.check()
_ = assert(
result == Left(
"""Some of the LEIs has different counts of records in Transmittal Sheet table and in LAR table.
|LEI: EXAMPLE-LEI, submissionId: sub1, countFromTs: 10, countFromLar: 2""".stripMargin
)
)
} yield ()

test.futureValue

}

"matching data in lar - 0" taggedAs CustomTag in {

val lei1 = "EXAMPLE-LEI"
val ts1 = TransmittalSheetEntity(lei = lei1, totalLines = 0, submissionId = Some("sub1"))

val check = new TSLinesCheck(dbConfig, validationTSData2018, validationLarData2018)

val test = for {
_ <- tsRepo2018.insert(ts1)
result <- check.check()
_ = assert(
result == Right(())
)
} yield ()

test.futureValue

}

"matching data in lar - non 0" taggedAs CustomTag in {

val lei1 = "EXAMPLE-LEI"
val ts1 = TransmittalSheetEntity(lei = lei1, totalLines = 1, submissionId = Some("sub1"))
val check = new TSLinesCheck(dbConfig, validationTSData2018, validationLarData2018)
val test = for {
_ <- tsRepo2018.insert(ts1)
_ <- larRepo2018.insert(dummyLar2018)
result <- check.check()
_ = assert(
result == Right(())
)
} yield ()

test.futureValue

}

def dummyLar2018 = LarEntityImpl2018(
LarPartOne2018(lei = "EXAMPLE-LEI"),
LarPartTwo2018(),
LarPartThree2018(),
LarPartFour2018(),
LarPartFive2018(),
LarPartSix2018()
)

override def bootstrapSqlFile: String = ""
}
Loading

0 comments on commit b29fc83

Please sign in to comment.