def test__invalid_command_header__raises_exception__wrong_alternative_list_4( self): line = 'command||:' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_INVALID_ALTERNATIVE)
def test__invalid_command_header__raises_exception__wrong_dependency_list_9( self): line = 'command: [dep1,,dep2]' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_INVALID_DEPENDENCY_LIST)
def test__invalid_command_header__raises_exception__comment_in_definition_2( self): line = '#command:' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_MISSING_COLON_ERROR)
def test__invalid_command_header__raises_exception__wrong_colon_syntax_2( self): line = ':command' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_COLON_ERROR)
def test__invalid_command_header__raises_exception__comment_in_dependency_list_1( self): line = 'command: [dep1,#dep2]' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_SYNTAX_ERROR)
def test__valid_command_header__extra_space_before_colon(self): line = 'command :' expected = { 'command': { 'done': False } } result = parse.command_header(line) self.assertEqual(expected, result)
def test__valid_command_header__basic_case(self): line = 'command:' expected = { 'command': { 'done': False } } result = parse.command_header(line) self.assertEqual(expected, result)
def test__valid_command_header__can_tolerate_comment_3(self): line = 'command: # comment' expected = { 'command': { 'done': False } } result = parse.command_header(line) self.assertEqual(expected, result)
def test__valid_command_header__command_name_full_range(self): line = 'command_COMMAND_1234567890.abc-abc:' expected = { 'command_COMMAND_1234567890.abc-abc': { 'done': False } } result = parse.command_header(line) self.assertEqual(expected, result)
def test__valid_command_header__two_alternative_commands(self): line = 'command|com:' expected = { 'command': { 'alternatives': ['com'], 'done': False }, 'com': { 'alias': 'command' } } result = parse.command_header(line) self.assertEqual(expected, result)
def test__valid_command_header__alternatives_with_space(self): line = 'command | com | c :' expected = { 'command': { 'alternatives': ['com', 'c'], 'done': False }, 'com': { 'alias': 'command' }, 'c': { 'alias': 'command' } } result = parse.command_header(line) self.assertEqual(expected, result)
def test__alternatives_are_sorted_in_decending_length_order(self): line = 'command|c|com:' expected = { 'command': { 'alternatives': ['com', 'c'], 'done': False }, 'com': { 'alias': 'command' }, 'c': { 'alias': 'command' } } result = parse.command_header(line) self.assertEqual(expected, result)
def test__valid_command_header__can_tolerate_comment_4(self): line = 'command|com|c:[dep,dep1]#comment' expected = { 'command': { 'alternatives': ['com', 'c'], 'dependencies': ['dep', 'dep1'], 'done': False }, 'com': { 'alias': 'command' }, 'c': { 'alias': 'command' } } result = parse.command_header(line) self.assertEqual(expected, result)
def test__invalid_command_header__raises_exception__indentation_4(self): line = ' command' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_SYNTAX_ERROR)
def test__valid_command_header__multiple_dependencies_with_more_inside_whitespaces( self): line = 'command|com|c: [ dep , dep1 ]' expected = ['dep', 'dep1'] result = parse.command_header(line) self.assertEqual(expected, result['command']['dependencies'])
def test__valid_command_header__dependencies_with_no_whitespaces(self): line = 'command|com|c:[dep]' expected = ['dep'] result = parse.command_header(line) self.assertEqual(expected, result['command']['dependencies'])
def test__valid_command_header__full_range_dependencies(self): line = 'command|com|c: [command_COMMAND_1234567890.abc-abc]' expected = ['command_COMMAND_1234567890.abc-abc'] result = parse.command_header(line) self.assertEqual(expected, result['command']['dependencies'])
def test__valid_command_header__multiple_dependencies(self): line = 'command|com|c: [dep, dep2, dep3]' expected = ['dep', 'dep2', 'dep3'] result = parse.command_header(line) self.assertEqual(expected, result['command']['dependencies'])
def test__invalid_command_header__raises_exception__wrong_alternative_list_4(self): line = 'command||:' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_INVALID_ALTERNATIVE)
def test__valid_command_header__multiple_dependencies_with_more_inside_whitespaces(self): line = 'command|com|c: [ dep , dep1 ]' expected = ['dep', 'dep1'] result = parse.command_header(line) self.assertEqual(expected, result['command']['dependencies'])
def test__prohibited_alternative_name__raises_error(self): line = 'pommand|p:' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_PROHIBITED_COMMAND.format('p'))
def test__invalid_command_header__raises_exception__comment_in_definition_2(self): line = '#command:' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_MISSING_COLON_ERROR)
def test__invalid_command_header__raises_exception__wrong_dependency_list_9(self): line = 'command: [dep1,,dep2]' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_INVALID_DEPENDENCY_LIST)
def test__invalid_command_header__raises_exception__no_colon_3(self): line = 'command [deb]' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_MISSING_COLON_ERROR)
def test__invalid_command_header__raises_exception__wrong_colon_syntax_2(self): line = ':command' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_COLON_ERROR)
def test__invalid_command_header__raises_exception__comment_in_dependency_list_3(self): line = 'command: [dep1, # dep2]' with self.assertRaises(Exception) as cm: parse.command_header(line) assert_exception(self, cm, SyntaxError, error.COMMAND_HEADER_SYNTAX_ERROR)