Skip to content

Commit

Permalink
moved working large number tests into correct file
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo committed May 13, 2024
1 parent 94b6c81 commit 8258d54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
20 changes: 0 additions & 20 deletions test_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,3 @@ def test_serialize_time_with_micros(cur):
cur.execute('SELECT a FROM t')
assert cur.fetchone()[0] != datetime.time(15, 19, 10, 12) # This should be equal
assert cur.fetchone() is None

def test_serialize_decimal_large(cur):
cur.execute('DROP TABLE IF EXISTS t')
cur.execute('CREATE TABLE t(i INTEGER NOT NULL, a DECIMAL(1) NOT NULL, PRIMARY KEY(i))')
with pytest.raises(polypheny.Error, match='RuntimeException'):
cur.execute('INSERT INTO t(i, a) VALUES (0, ?)', (2**77,))

return # remove if execute works
cur.execute('SELECT a FROM t')
assert cur.fetchone()[0] == 2**77
assert cur.fetchone() is None

def test_serialize_decimal_large2(cur):
cur.execute('DROP TABLE IF EXISTS t')
cur.execute('CREATE TABLE t(i INTEGER NOT NULL, a DECIMAL NOT NULL, PRIMARY KEY(i))')
cur.execute('INSERT INTO t(i, a) VALUES (0, ?)', (2**77,))
cur.execute('SELECT a FROM t')

assert cur.fetchone()[0] == 151115727451828650000000 # This should be 2**77 or 151115727451828646838272
assert cur.fetchone() is None
19 changes: 19 additions & 0 deletions test_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ def test_serialize_list(cur):
assert cur.fetchone()[0] == [1, 2, 3]
assert cur.fetchone() is None

def test_serialize_decimal_large(cur):
cur.execute('DROP TABLE IF EXISTS t')
cur.execute('CREATE TABLE t(i INTEGER NOT NULL, a DECIMAL(1) NOT NULL, PRIMARY KEY(i))')
cur.execute('INSERT INTO t(i, a) VALUES (0, ?)', (2**77,))

cur.execute('SELECT a FROM t')
assert cur.fetchone()[0] == 2**77
assert cur.fetchone() is None

def test_serialize_decimal_large2(cur):
cur.execute('DROP TABLE IF EXISTS t')
cur.execute('CREATE TABLE t(i INTEGER NOT NULL, a DECIMAL NOT NULL, PRIMARY KEY(i))')
cur.execute('INSERT INTO t(i, a) VALUES (0, ?)', (2**77,))
cur.execute('SELECT a FROM t')

assert cur.fetchone()[0] == 151115727451828646838272
assert cur.fetchone() is None


def test_deserialize_number(cur):
cur.execute('SELECT 1')
assert cur.fetchone()[0] == 1
Expand Down

0 comments on commit 8258d54

Please sign in to comment.