import unittest
import verif.field


class TestField(unittest.TestCase):
    def test_equal(self):
        self.assertEqual(verif.field.Obs(), verif.field.Obs())
        self.assertTrue(verif.field.Obs() == verif.field.Obs())
        self.assertFalse(verif.field.Obs() != verif.field.Obs())

        self.assertEqual(verif.field.Threshold(0), verif.field.Threshold(0))
        self.assertTrue(verif.field.Threshold(0) == verif.field.Threshold(0))
        self.assertFalse(verif.field.Threshold(0) != verif.field.Threshold(0))

    def test_unequal(self):
        self.assertFalse(verif.field.Obs() == verif.field.Fcst())
        self.assertFalse(verif.field.Obs() == verif.field.Threshold(0))
        self.assertTrue(verif.field.Obs() != verif.field.Fcst())
        self.assertTrue(verif.field.Obs() != verif.field.Threshold(0))

        self.assertFalse(verif.field.Threshold(0) == verif.field.Threshold(1))
        self.assertTrue(verif.field.Threshold(0) != verif.field.Threshold(1))

    def test_get(self):
        f = verif.field.get("threshold:0.1")
        self.assertEqual(f, verif.field.Threshold(0.1))

        f = verif.field.get("quantile:0.1")
        self.assertEqual(f, verif.field.Quantile(0.1))

        f = verif.field.get("ensemble:1")
        self.assertEqual(f, verif.field.EnsembleMember(1))


if __name__ == "__main__":
    unittest.main()
