Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Publish stream.hashing_algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
roll committed May 20, 2020
1 parent 9b7a87b commit b635dda
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tabulator/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ def field_positions(self):
self.__field_positions.append(index + 1)
return self.__field_positions

@property
def hashing_algorithm(self):
return self.__hashing_algorithm

def iter(self, keyed=False, extended=False):
"""Iterate over the rows.
Expand Down
5 changes: 5 additions & 0 deletions tests/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,30 +766,35 @@ def test_stream_hash():
with Stream('data/special/doublequote.csv') as stream:
rows = stream.read()
assert stream.hash == '41fdde1d8dbcb3b2d4a1410acd7ad842781f076076a73b049863d6c1c73868db'
assert stream.hashing_algorithm == 'sha256'


def test_stream_hash_md5():
with Stream('data/special/doublequote.csv', hashing_algorithm='md5') as stream:
rows = stream.read()
assert stream.hash == 'd82306001266c4343a2af4830321ead8'
assert stream.hashing_algorithm == 'md5'


def test_stream_hash_sha1():
with Stream('data/special/doublequote.csv', hashing_algorithm='sha1') as stream:
rows = stream.read()
assert stream.hash == '2842768834a6804d8644dd689da61c7ab71cbb33'
assert stream.hashing_algorithm == 'sha1'


def test_stream_hash_sha256():
with Stream('data/special/doublequote.csv', hashing_algorithm='sha256') as stream:
rows = stream.read()
assert stream.hash == '41fdde1d8dbcb3b2d4a1410acd7ad842781f076076a73b049863d6c1c73868db'
assert stream.hashing_algorithm == 'sha256'


def test_stream_hash_sha512():
with Stream('data/special/doublequote.csv', hashing_algorithm='sha512') as stream:
rows = stream.read()
assert stream.hash == 'fa555b28a01959c8b03996cd4757542be86293fd49641d61808e4bf9fe4115619754aae9ae6af6a0695585eaade4488ce00dfc40fc4394b6376cd20d6967769c'
assert stream.hashing_algorithm == 'sha512'


def test_stream_hash_not_supported():
Expand Down

0 comments on commit b635dda

Please sign in to comment.