def test_processLine_EmptyArguemnts_ReturnLine(self): """ Test that given empty arguments, the line is returned """ line = "line of text" ret, none = readfile._process_line(line, None, None, None) assert ret == line assert none is None
def test_processLine_InvalidDictsep_ReturnLine(self): """ Test that given a valid ``dictsep``, a valid ``subsep`` and an invalid ``valsep``, a dict is returned """ line = "key0:key1;val-val2" ret, none = readfile._process_line(line, '?', '.', '-') assert ret == line assert none is None
def test_processLine_ValidDictsepInvalidValsep_ReturnList(self): """ Test that given a valid ``dictsep`` and an invalid ``valsep``, a list is returned """ expected_key, expected_val = 'key0', ['key1;key2;val'] line = "key0:key1;key2;val" key, val = readfile._process_line(line, ':', '-', None) assert expected_key == key assert expected_val == val
def test_processLine_ValidDictsepSubsepInvalidValsep_ReturnDict(self): """ Test that given a valid ``dictsep``, a valid ``subsep`` and an invalid ``valsep``, a dict is returned """ expected_key, expected_val = 'key0', {'key1;val': 'val2'} line = "key0:key1;val-val2" key, val = readfile._process_line(line, ':', '.', '-') assert expected_key == key assert expected_val == val
def test_processLine_ValidDictsepValsepInvalidSubsep_ReturnDict(self): """ Test that given a valid ``dictsep``, a valid ``valsep`` and an invalid ``subsep``, a dict is returned """ expected_key, expected_val = 'APP_ATTRIBUTES', { 'cluster_role:controol': None, 'provider:aws': None, 'zone:3': None } line = "APP_ATTRIBUTES=cluster_role:controol;zone:3;provider:aws" key, val = readfile._process_line(line, '=', ';', '-') assert expected_key == key assert expected_val == val
def test_processLine_ValidArguments_ReturnDict(self): """ Test that given valid arguments, the function returns a valid dictionary """ expected_key, expected_val = 'APP_ATTRIBUTES', { 'cluster_role': 'controol', 'provider': 'aws', 'zone': '3' } line = "APP_ATTRIBUTES=cluster_role:controol;zone:3;provider:aws" key, val = readfile._process_line(line, dictsep='=', valsep=';', subsep=':') assert expected_key == key assert expected_val == val
def test_processLine_ValidArgumentsDuplicateKeys_ReturnDict(self): """ Test that given valid arguments, if the input data contains duplicate keys, they will be removed from the return dict """ expected_key, expected_val = 'APP_ATTRIBUTES', { 'cluster_role': 'controol', 'provider': 'aws', 'zone': '3' } line = "APP_ATTRIBUTES=cluster_role:controol;zone:6;provider:aws;zone:3" key, val = readfile._process_line(line, dictsep='=', valsep=';', subsep=':') assert expected_key == key assert expected_val == val