def test_create_ip_list_dicts_none_json(self): """ Given - dictionary of ip list command result When - the dictionary is None Then - raise TypeError Exception """ with pytest.raises(TypeError): ip_dict = None create_ip_list_dicts(ip_dict)
def test_create_ip_list_dicts_bad_keys(self): """ Given - dictionary of ip list command result When - the dictionary has wrong keys Then - raise DemistoException exception """ with pytest.raises(DemistoException): ip_dict = {'bad_key_1': ['1.1.1.1', '1.2.3.4'], 'bad_key_2': ['1.1.1.3-1.1.2.1']} create_ip_list_dicts(ip_dict)
def test_create_ip_list_dicts_expected_format_single_value(self): """ Given - dictionary of ip list command result When - the dictionary has the expected format but only single value Then - create a list of dictionaries """ ip_dict = {'Address': '1.1.1.1'} dicts = create_ip_list_dicts(ip_dict) assert len(dicts) == 1 assert len(dicts[0]) == 1
def test_create_ip_list_dicts_one_good_key(self): """ Given - dictionary of ip list command result When - the dictionary has one wrong key Then - change only one key """ ip_dict = {'Address': ['1.1.1.1', '1.2.3.4'], 'bad_key_2': ['1.1.1.3-1.1.2.1']} dicts = create_ip_list_dicts(ip_dict) assert len(dicts) == 1 assert len(dicts[0]) == 2
def test_create_ip_list_dicts_expected_format_single_value_is_dict(self): """ Given - dictionary of ip list command result When - the dictionary has the expected format but only single value and is a dictionary of values Then - create a list of dictionaries """ ip_dict = {'Address': {'key1': 'value1', 'key2': 'value2'}} dicts = create_ip_list_dicts(ip_dict) assert len(dicts) == 1 assert len(dicts[0]) == 1
def test_create_ip_list_dicts_expected_format(self): """ Given - dictionary of ip list command result When - the dictionary has the expected format Then - create a list of dictionaries """ ip_dict = {'Address': ['1.1.1.1', '1.2.3.4'], 'Range': ['1.1.1.3-1.1.2.1']} dicts = create_ip_list_dicts(ip_dict) assert len(dicts[0]) == 2 assert len(dicts[1]) == 1