Skip to content

Commit

Permalink
Rename DatasetTestSuite
Browse files Browse the repository at this point in the history
  • Loading branch information
dlindhol committed Jun 29, 2021
1 parent 2545a39 commit b003101
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import latis.dataset.Dataset
import latis.model.DataType
import latis.ops._

abstract class DatasetTestUtils extends AnyFunSuite {
abstract class DatasetTestSuite extends AnyFunSuite {

val catalog: Catalog

Expand Down
24 changes: 12 additions & 12 deletions test-utils/src/test/scala/latis/util/DatasetTestUtilsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import latis.model._
import latis.ops._
import latis.util.Identifier.IdentifierStringContext

class TestUtilsSuite extends AnyFunSuite {
class DatasetTestUtilsSuite extends AnyFunSuite {

val testUtils = new DatasetTestUtils {
val testSuite = new DatasetTestSuite {
val catalog: Catalog = new Catalog {
def datasets: Stream[IO, Dataset] = Stream.emits{
List(
Expand All @@ -27,28 +27,28 @@ class TestUtilsSuite extends AnyFunSuite {
}

test("dataset") {
testUtils.withDataset(id"foo") { ds =>
testSuite.withDataset(id"foo") { ds =>
assert(ds.id.get.asString == "foo")
}
}

test("dataset not found") {
val x = intercept[TestFailedException]{
testUtils.withDataset(id"bar")(_ => ???)
testSuite.withDataset(id"bar")(_ => ???)
}
assert(x.getMessage == "Dataset not found: bar")
}

test("dataset with operation") {
val ops = List(Take(2))
testUtils.withDataset(id"foo", ops) { ds =>
testSuite.withDataset(id"foo", ops) { ds =>
val h = ds.metadata.getProperty("history").getOrElse(fail("No history found"))
assert(h.contains("Take"))
}
}

test("match model") {
testUtils.matchModel(id"foo") {
testSuite.matchModel(id"foo") {
case Function(x: Scalar, a: Scalar) =>
assert(x.id.get.asString == "x")
assert(a.id.get.asString == "a")
Expand All @@ -57,15 +57,15 @@ class TestUtilsSuite extends AnyFunSuite {

test("match model with operation") {
val ops = List(Rename(id"a", id"b"))
testUtils.matchModel(id"foo", ops) {
testSuite.matchModel(id"foo", ops) {
case Function(x: Scalar, a: Scalar) =>
assert(x.id.get.asString == "x")
assert(a.id.get.asString == "b")
}
}

test("match first sample") {
testUtils.matchFirstSample(id"foo") {
testSuite.matchFirstSample(id"foo") {
case Sample(DomainData(Integer(x)), RangeData(Integer(a))) =>
assert(x == 0)
assert(a == 0)
Expand All @@ -74,7 +74,7 @@ class TestUtilsSuite extends AnyFunSuite {

test("match first sample with operation") {
val ops = List(Drop(1))
testUtils.matchFirstSample(id"foo", ops) {
testSuite.matchFirstSample(id"foo", ops) {
case Sample(DomainData(Integer(x)), RangeData(Integer(a))) =>
assert(x == 1)
assert(a == 1)
Expand All @@ -84,21 +84,21 @@ class TestUtilsSuite extends AnyFunSuite {
test("empty dataset") {
val ops = List(Drop(10))
val x = intercept[TestFailedException] {
testUtils.matchFirstSample(id"foo", ops)(_ => ???)
testSuite.matchFirstSample(id"foo", ops)(_ => ???)
}
assert(x.getMessage == "Empty dataset")
}

test("equals first sample") {
val ops = List(Drop(1))
val values = List(1, 1)
testUtils.equalsFirstSample(id"foo", ops)(values)
testSuite.equalsFirstSample(id"foo", ops)(values)
}

test("equals fails for nested function") {
val values = List(0, 0, 0)
val x = intercept[TestFailedException] {
testUtils.equalsFirstSample(id"bar2D")(values)
testSuite.equalsFirstSample(id"bar2D")(values)
}
assert(x.getMessage() == "Equality test on Function not supported")
}
Expand Down

0 comments on commit b003101

Please sign in to comment.