Skip to content

Commit

Permalink
Make host optional in VersionedItem (pandas-dev#619) (pandas-dev#620)
Browse files Browse the repository at this point in the history
This makes `VersionedItem` backwards compatible, so any third-party
libraries creating their own `VersionedItem`s won't be affected.
  • Loading branch information
scriada authored and bmoscon committed Sep 6, 2018
1 parent c8bf70d commit f7882b5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arctic/store/versioned_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ class VersionedItem(namedtuple('VersionedItem', ['symbol', 'library', 'data', 'v
"""
Class representing a Versioned object in VersionStore.
"""

def __new__(cls, symbol, library, data, version, metadata, host=None):
return super(VersionedItem, cls).__new__(cls, symbol, library, data, version, metadata, host)

def metadata_dict(self):
return {'symbol': self.symbol, 'library': self.library, 'version': self.version}

Expand Down
17 changes: 17 additions & 0 deletions tests/unit/store/test_version_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ def test_versioned_item_str():
assert repr(item) == expected


def test_versioned_item_default_host():
item = VersionedItem(symbol="sym",
library="ONEMINUTE",
data=[1, 2, 3],
version=1.0,
metadata={'metadata': 'foo'})

expected_item = VersionedItem(symbol="sym",
library="ONEMINUTE",
data=[1, 2, 3],
version=1.0,
host=None,
metadata={'metadata': 'foo'})

assert item == expected_item


def test_versioned_item_str_handles_none():
item = VersionedItem(symbol=None,
library=None,
Expand Down

0 comments on commit f7882b5

Please sign in to comment.