Skip to content

Commit

Permalink
Fix Python 3 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Teemu Kokkonen committed Feb 26, 2015
1 parent 0ff6945 commit 1cc3d64
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions stellar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ def get_table_name(self, postfix, old=False):
)
else:
return 'stellar_%s' % hashlib.md5(
'%s|%s|%s' % (
('%s|%s|%s' % (
self.table_name,
self.snapshot.hash,
postfix
)
)).encode('utf-8')
).hexdigest()[0:16]

def __repr__(self):
Expand Down
2 changes: 1 addition & 1 deletion stellar/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_engine_url(raw_conn, database):
def terminate_database_connections(raw_conn, database):
logger.debug('terminate_database_connections(%r)', database)
if raw_conn.engine.dialect.name == 'postgresql':
version = map(int, raw_conn.execute('SHOW server_version;').first()[0].split('.'))
version = [int(x) for x in raw_conn.execute('SHOW server_version;').first()[0].split('.')]
pid_column = 'pid' if (version[0] >= 9 and version[1] >= 2) else 'procpid'

raw_conn.execute(
Expand Down
14 changes: 13 additions & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
from stellar.models import get_unique_hash
from stellar.models import get_unique_hash, Table, Snapshot


def test_get_unique_hash():
assert get_unique_hash()
assert get_unique_hash() != get_unique_hash()
assert len(get_unique_hash()) == 32


def test_table():
table = Table(
table_name='hapsu',
snapshot=Snapshot(
snapshot_name='snapshot',
project_name='myproject',
hash='3330484d0a70eecab84554b5576b4553'
)
)
assert len(table.get_table_name('master')) == 24

0 comments on commit 1cc3d64

Please sign in to comment.