예제 #1
0
 def test_invalid(self):
     prop = bcpd.Date()
     assert not prop.is_valid(1.0+1.0j)
     assert not prop.is_valid(())
     assert not prop.is_valid([])
     assert not prop.is_valid({})
     assert not prop.is_valid(_TestHasProps())
     assert not prop.is_valid(_TestModel())
예제 #2
0
 def test_invalid(self) -> None:
     prop = bcpd.Date()
     assert not prop.is_valid(datetime.datetime(2020, 1, 11))
     assert not prop.is_valid("")
     assert not prop.is_valid(False)
     assert not prop.is_valid(True)
     assert not prop.is_valid(1.0 + 1.0j)
     assert not prop.is_valid(())
     assert not prop.is_valid([])
     assert not prop.is_valid({})
     assert not prop.is_valid(_TestHasProps())
     assert not prop.is_valid(_TestModel())
예제 #3
0
    def test_valid(self):
        prop = bcpd.Date()
        assert prop.is_valid(None)

        assert prop.is_valid(0)
        assert prop.is_valid(1)
        assert prop.is_valid(0.0)
        assert prop.is_valid(1.0)

        # TODO (bev) should check actual convertibility
        assert prop.is_valid("")

        # TODO (bev) should fail
        assert prop.is_valid(False)
        assert prop.is_valid(True)
예제 #4
0
 def test_str(self):
     prop = bcpd.Date()
     assert str(prop) == "Date"
예제 #5
0
 def test_has_ref(self):
     prop = bcpd.Date()
     assert not prop.has_ref
예제 #6
0
 def test_transform_milliseconds(self):
     t = time.time() * 1000
     prop = bcpd.Date()
     assert prop.transform(t) == datetime.date.today()
예제 #7
0
 def test_valid(self) -> None:
     prop = bcpd.Date()
     assert prop.is_valid(datetime.date(2020, 1, 11))
     assert prop.is_valid("2020-01-10")