Skip to content

Commit

Permalink
Add new fields to status/dom_sensor/pm tables in STATE_DB for CMIS/C-…
Browse files Browse the repository at this point in the history
…CMIS (#304)
  • Loading branch information
longhuan-cisco authored Dec 7, 2022
1 parent adcd69b commit 56046dc
Show file tree
Hide file tree
Showing 3 changed files with 393 additions and 182 deletions.
28 changes: 19 additions & 9 deletions sonic-xcvrd/tests/mock_swsscommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,34 @@ def _del(self, key):
self.mock_keys.remove(key)
pass

def hdel(self, key, field):
if key not in self.mock_dict:
return

# swsscommon.FieldValuePairs
fvs = self.mock_dict[key]
for i, fv in enumerate(fvs):
if fv[0] == field:
del fvs[i]
break
if self.get_size_for_key(key) == 0:
self._del(key)

def set(self, key, fvs):
self.mock_dict[key] = fvs
self.mock_keys.append(key)
pass

def get(self, key):
if key in self.mock_dict:
return self.mock_dict[key]
return None
return True, self.mock_dict[key]
return False, None

def get_size(self):
return (len(self.mock_dict))

def getKeys(self):
return self.mock_keys

def get_size_for_key(self, key):
return len(self.mock_dict[key])

class FieldValuePairs:
def __init__(self, fvs):
self.fv_dict = dict(fvs)
pass
def getKeys(self):
return self.mock_keys
Loading

0 comments on commit 56046dc

Please sign in to comment.