Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/decode-syseeprom
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ def main():

(opts, args) = get_cmdline_opts()

use_db = opts.db and support_eeprom_db

# Get platform name
platform = device_info.get_platform()

Expand All @@ -238,6 +236,8 @@ def main():
if any(re.match(p, platform) for p in platforms_without_eeprom_db):
support_eeprom_db = False

use_db = opts.db and support_eeprom_db

if opts.mgmtmac:
print_mgmt_mac(use_db)
elif opts.serial:
Expand Down
9 changes: 9 additions & 0 deletions tests/decode_syseeprom_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,12 @@ def test_print_model(self, capsys):
decode_syseeprom.print_model(True)
captured = capsys.readouterr()
assert captured.out == 'S6100-ON\n'

@mock.patch('os.geteuid', lambda: 0)
@mock.patch('sonic_py_common.device_info.get_platform', lambda: 'arista')
@mock.patch('decode-syseeprom.read_and_print_eeprom')
@mock.patch('decode-syseeprom.read_eeprom_from_db')
def test_support_platforms_not_db_based(self, mockDbBased, mockNotDbBased):
decode_syseeprom.main()
assert mockNotDbBased.called
assert not mockDbBased.called