Skip to content

Commit

Permalink
polising
Browse files Browse the repository at this point in the history
  • Loading branch information
chillaq committed Mar 1, 2023
1 parent 60c5541 commit 6f977b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGES.txt
@@ -1,4 +1,4 @@
9.4.0 (Feb 21, 2023)
9.4.0 (Mar 1, 2023)
- Added support to use JSON files in localhost mode.
- Updated default periodic telemetry post time to one hour.
- Fixed unhandeled exception in push.manager.py class when SDK is connected to split proxy
Expand Down
6 changes: 2 additions & 4 deletions splitio/sync/segment.py
Expand Up @@ -255,8 +255,6 @@ def synchronize_segment(self, segment_name, till=None):
"""
try:
fetched = self._read_segment_from_json_file(segment_name)
if fetched is None:
return False
fetched_sha = util._get_sha(json.dumps(fetched))
if not self.segment_exist_in_storage(segment_name):
self._segment_sha[segment_name] = fetched_sha
Expand Down Expand Up @@ -309,10 +307,10 @@ def _sanitize_segment(self, parsed):
"""
if 'name' not in parsed or parsed['name'] is None:
_LOGGER.warning("Segment does not have [name] element, skipping")
return None
raise Exception("Segment does not have [name] element")
if parsed['name'].strip() == '':
_LOGGER.warning("Segment [name] element is blank, skipping")
return None
raise Exception("Segment [name] element is blank")

for element in [('till', -1, -1, None, None, [0]),
('added', [], None, None, None, None),
Expand Down
14 changes: 12 additions & 2 deletions tests/sync/test_segments_synchronizer.py
Expand Up @@ -305,11 +305,21 @@ def test_json_elements_sanitization(self, mocker):

# should reject segment if 'name' is null
segment2 = {"name": None, "added": [], "removed": [], "since": -1, "till": 12}
assert(segment_synchronizer._sanitize_segment(segment2) == None)
exception_called = False
try:
segment_synchronizer._sanitize_segment(segment2)
except:
exception_called = True
assert(exception_called)

# should reject segment if 'name' does not exist
segment2 = {"added": [], "removed": [], "since": -1, "till": 12}
assert(segment_synchronizer._sanitize_segment(segment2) == None)
exception_called = False
try:
segment_synchronizer._sanitize_segment(segment2)
except:
exception_called = True
assert(exception_called)

# should add missing 'added' element
segment2 = {"name": 'seg', "removed": [], "since": -1, "till": 12}
Expand Down

0 comments on commit 6f977b2

Please sign in to comment.