class DbValueTestCase(unittest.TestCase):
    """Tests for converting the Python value to database type."""

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

    def test_none_returns_none(self):
        # psycopg2 will convert None to NULL
        self.assertIsNone(self.f.get_prep_value(None))

    def test_empty_list_returns_empty_list(self):
        # psycopg2 will convert [] to {}
        self.assertEqual(self.f.get_prep_value([]), [])

    def test_list_returns_list(self):
        value = [1, 2, 3, ]
        self.assertEqual(self.f.get_prep_value(value), value)
Exemplo n.º 2
0
class DbValueTestCase(unittest.TestCase):
    """Tests for converting the Python value to database type."""
    def setUp(self):
        self.f = ArrayField()

    def test_none_returns_none(self):
        # psycopg2 will convert None to NULL
        self.assertIsNone(self.f.get_prep_value(None))

    def test_empty_list_returns_empty_list(self):
        # psycopg2 will convert [] to {}
        self.assertEqual(self.f.get_prep_value([]), [])

    def test_list_returns_list(self):
        value = [
            1,
            2,
            3,
        ]
        self.assertEqual(self.f.get_prep_value(value), value)