Skip to content

Commit

Permalink
add feature config parsing test
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyshchak <[email protected]>
  • Loading branch information
stepanblyschak committed Nov 16, 2020
1 parent 1d2b20a commit 6f47365
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/sonic-host-services/tests/hostcfgd_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import imp
import sys
import os
import pytest

import swsssdk

from .mock_connector import MockConnector

swsssdk.SonicV2Connector = MockConnector

test_path = os.path.dirname(os.path.abspath(__file__))
modules_path = os.path.dirname(test_path)
scripts_path = os.path.join(modules_path, "scripts")
sys.path.insert(0, modules_path)

imp.load_source('hostcfgd', scripts_path + '/hostcfgd')
from hostcfgd import *

class TestHostConfigurationDaemon(object):
def test_feature_config_parsing(self):
swss_feature = Feature('swss', {
'state': 'enabled',
'auto_restart': 'enabled',
'has_timer': 'True',
'has_global_scope': 'False',
'has_per_asic_scope': 'True',
})

assert swss_feature.name == 'swss'
assert swss_feature.state == 'enabled'
assert swss_feature.auto_restart == 'enabled'
assert swss_feature.has_timer
assert not swss_feature.has_global_scope
assert swss_feature.has_per_asic_scope

def test_feature_config_parsing_defaults(self):
swss_feature = Feature('swss', {
'state': 'enabled',
})

assert swss_feature.name == 'swss'
assert swss_feature.state == 'enabled'
assert swss_feature.auto_restart == 'disabled'
assert not swss_feature.has_timer
assert swss_feature.has_global_scope
assert not swss_feature.has_per_asic_scope

0 comments on commit 6f47365

Please sign in to comment.