forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bigint.py
More file actions
44 lines (32 loc) · 1.1 KB
/
test_bigint.py
File metadata and controls
44 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
from unittest import TestCase
from piccolo.table import Table
from piccolo.columns.column_types import BigInt
from ..base import postgres_only
class MyTable(Table):
value = BigInt()
@postgres_only
class TestBigIntPostgres(TestCase):
"""
Make sure a BigInt column in Postgres can store a large number.
"""
def setUp(self):
MyTable.create_table().run_sync()
def tearDown(self):
MyTable.alter().drop_table().run_sync()
def _test_length(self):
# Can store 8 bytes, but split between positive and negative values.
max_value = int(2 ** 64 / 2) - 1
min_value = max_value * -1
print("Testing max value")
row = MyTable(value=max_value)
row.save().run_sync()
print("Testing min value")
row.value = min_value
row.save().run_sync()
if "TRAVIS" not in os.environ:
# This stalls out on Travis - not sure why.
print("Test exceeding max value")
with self.assertRaises(Exception):
row.value = max_value + 100
row.save().run_sync()