class SecondsFieldTest(TestCase):

    def setUp(self):
        self.f = SecondsField()

    def test_to_python_int(self):
        self.assertEqual(Seconds(400), self.f.to_python(400))

    def test_to_python_Seconds(self):
        self.assertEqual(Seconds(500), self.f.to_python(Seconds(500)))

    def test_to_python_seconds_string(self):
        self.assertEqual(Seconds(500), self.f.to_python('500'))

    def test_to_python_hm_string(self):
        self.assertEqual(Seconds(3660), self.f.to_python('01:01'))

    def test_to_python_hms_string(self):
        self.assertEqual(Seconds(3661), self.f.to_python('01:01:01'))

    def test_to_python_too_many_colons(self):
        self.assertRaises(ValueError, self.f.to_python, '01:01:01:01')

    def test_prep_db_value_Seconds(self):
        self.assertEqual(500, self.f.get_prep_value(Seconds(500)))

    def test_prep_db_value_None(self):
        self.assertIsNone(self.f.get_prep_value(None))
class SecondsFieldTest(TestCase):
    def setUp(self):
        self.f = SecondsField()

    def test_to_python_int(self):
        self.assertEqual(Seconds(400), self.f.to_python(400))

    def test_to_python_Seconds(self):
        self.assertEqual(Seconds(500), self.f.to_python(Seconds(500)))

    def test_to_python_seconds_string(self):
        self.assertEqual(Seconds(500), self.f.to_python('500'))

    def test_to_python_hm_string(self):
        self.assertEqual(Seconds(3660), self.f.to_python('01:01'))

    def test_to_python_hms_string(self):
        self.assertEqual(Seconds(3661), self.f.to_python('01:01:01'))

    def test_to_python_too_many_colons(self):
        self.assertRaises(ValueError, self.f.to_python, '01:01:01:01')

    def test_to_python_none(self):
        self.assertIsNone(self.f.to_python(None))

    def test_to_python_empty_string(self):
        self.assertIsNone(self.f.to_python(''))

    def test_prep_db_value_Seconds(self):
        self.assertEqual(500, self.f.get_prep_value(Seconds(500)))

    def test_prep_db_value_None(self):
        self.assertIsNone(self.f.get_prep_value(None))