Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rgonalo committed Apr 9, 2021
1 parent 8d75e58 commit 9bfb15b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
4 changes: 4 additions & 0 deletions toolium/test/conf/properties.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ complete_report: true
baseline_name: {Driver_type}
engine: pil

[Capabilities]
goog___loggingPrefs: {'performance': 'ALL', 'browser': 'ALL', 'driver': 'ALL'}
goog___chromeOptions: {​​​​​​​​'excludeSwitches': [ 'enable-automation' ],'useAutomationExtension': False}​​​​​​​​

[AppiumCapabilities]
automationName: Appium
platformName: Android
Expand Down
53 changes: 22 additions & 31 deletions toolium/test/test_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ def config():
return config


@pytest.fixture
def special_config():
root_path = os.path.dirname(os.path.realpath(__file__))
conf_properties_file = os.path.join(root_path, 'conf', 'special-properties.cfg')
config = ExtendedConfigParser()
config.read(conf_properties_file)
return config


@pytest.mark.parametrize("section, option, default, response", optional_values)
def test_get_optional(section, option, default, response, config):
if default:
Expand All @@ -81,56 +72,56 @@ def test_get(config):
assert value == config.get(section, option)


def test_get_with_colon_in_option(special_config):
def test_get_with_colon_in_option(config):
section = 'Capabilities'
option = 'goog:loggingPrefs'
value = "{'performance': 'ALL', 'browser': 'ALL', 'driver': 'ALL'}"
assert value == special_config.get(section, option)
assert value == config.get(section, option)


def test_set_with_colon_in_option(special_config):
def test_set_with_colon_in_option(config):
section = 'Capabilities'
option = 'goog:loggingPrefs'
orig_value = "{'performance': 'ALL', 'browser': 'ALL', 'driver': 'ALL'}"
new_value = "{'performance': 'ALL', 'browser': 'ALL'}"

# Check previous value
assert orig_value == special_config.get(section, option)
assert orig_value == config.get(section, option)

# Modify property value and check new value
special_config.set(section, option, new_value)
assert new_value == special_config.get(section, option)
config.set(section, option, new_value)
assert new_value == config.get(section, option)


def test_options_with_colon_in_option(special_config):
def test_options_with_colon_in_option(config):
section = 'Capabilities'
options = ['goog:loggingPrefs', 'goog:chromeOptions']
assert options == special_config.options(section)
assert options == config.options(section)


def test_has_option_with_colon_in_option(special_config):
def test_has_option_with_colon_in_option(config):
section = 'Capabilities'
option = 'goog:loggingPrefs'
wrong_option = 'goog:loggingPrefsWrong'
assert True == special_config.has_option(section, option)
assert False == special_config.has_option(section, wrong_option)
assert True == config.has_option(section, option)
assert False == config.has_option(section, wrong_option)


def test_remove_option_with_colon_in_option(special_config):
def test_remove_option_with_colon_in_option(config):
section = 'Capabilities'
option = 'goog:loggingPrefs'
wrong_option = 'goog:loggingPrefsWrong'
assert True == special_config.remove_option(section, option)
assert False == special_config.remove_option(section, wrong_option)
assert None == special_config.get_optional(section, option, default=None)
assert True == config.remove_option(section, option)
assert False == config.remove_option(section, wrong_option)
assert None == config.get_optional(section, option, default=None)


def test_items_with_colon_in_option(special_config):
def test_items_with_colon_in_option(config):
section = 'Capabilities'
items = [('goog:loggingPrefs', "{'performance': 'ALL', 'browser': 'ALL', 'driver': 'ALL'}"),
('goog:chromeOptions',
"{​​​​​​​​'excludeSwitches': [ 'enable-automation' ],'useAutomationExtension': False}​​​​​​​​")]
assert items == special_config.items(section)
assert items == config.items(section)


def test_deepcopy(config):
Expand All @@ -157,28 +148,28 @@ def test_deepcopy(config):
assert new_value == new_config.get(section, option)


def test_deepcopy_with_colon(special_config):
def test_deepcopy_and_modify_option_with_colon(config):
section = 'Capabilities'
configured_option = 'goog___loggingPrefs'
option = 'goog:loggingPrefs'
orig_value = "{'performance': 'ALL', 'browser': 'ALL', 'driver': 'ALL'}"
new_value = "{'performance': 'ALL', 'browser': 'ALL'}"

# Check previous value
assert orig_value == special_config.get(section, option)
assert orig_value == config.get(section, option)

# Copy config object
new_config = special_config.deepcopy()
new_config = config.deepcopy()

# Check that both configs have the same property value
assert orig_value == special_config.get(section, option)
assert orig_value == config.get(section, option)
assert orig_value == new_config.get(section, option)

# Modify property value
new_config.set(section, configured_option, new_value)

# Check that the value has no changed in original config
assert orig_value == special_config.get(section, option)
assert orig_value == config.get(section, option)
assert new_value == new_config.get(section, option)


Expand Down

0 comments on commit 9bfb15b

Please sign in to comment.