<reponame>JamesAllen16/oreru<filename>tests/test_arg_parser.py
'''Tests Argument Parsing'''

import unittest
from ..arg_parser import ArgParser

class TestArgParser(unittest.TestCase):
    '''Tests Argument Parsing'''
    def test_help(self):
        '''tests arg_parser when just passing --help'''
        arguments = ['--help']
        test_parser = ArgParser(arguments)
        with self.assertRaises(SystemExit) as raised:
            test_parser.parse_command()
            self.assertEqual(raised.exception.code, 0)

    def test_noargs(self):
        '''tests arg_parser without passing arguments'''
        arguments = None
        test_parser = ArgParser(arguments)
        test_parser.parse_command()
        # Assert that --help is called

    def test_empty_string_arg(self):
        '''tests arg_parser when passing an empty string'''
        arguments = ['']
        test_parser = ArgParser(arguments)
        test_parser.parse_command()

    def test_invalidarg(self):
        '''tests arg_parser with an invalid argument'''
        arguments = ['--invalid']
        test_parser = ArgParser(arguments)
        with self.assertRaises(SystemExit) as raised:
            test_parser.parse_command()
            self.assertEqual(raised.exception.code, 2)

# Flapping Tests, based on runtime context, Fix
    def test_with_command(self):
        '''tests arg_parser with a valid command'''
        arguments = ['archive']
        test_parser = ArgParser(arguments)
        with self.assertRaises(SystemExit) as raised:
            test_parser.parse_command()
            self.assertEqual(raised.exception.code, 0)
        # Assert Dispatch.archive gets called

    def test_with_invalid_command(self):
        '''tests arg_parser with an invalid command'''
        arguments = ['invalid']
        test_parser = ArgParser(arguments)
        with self.assertRaises(SystemExit) as raised:
            with self.assertRaises(NotImplementedError):
                test_parser.parse_command()
            self.assertEqual(raised.exception.code, 0)

'''Tests Argument Parsing'''

import unittest
from ..arg_parser import ArgParser

class TestArgParser(unittest.TestCase):
    '''Tests Argument Parsing'''
    def test_help(self):
        '''tests arg_parser when just passing --help'''
        arguments = ['--help']
        test_parser = ArgParser(arguments)
        with self.assertRaises(SystemExit) as raised:
            test_parser.parse_command()
            self.assertEqual(raised.exception.code, 0)

    def test_noargs(self):
        '''tests arg_parser without passing arguments'''
        arguments = None
        test_parser = ArgParser(arguments)
        test_parser.parse_command()
        # Assert that --help is called

    def test_empty_string_arg(self):
        '''tests arg_parser when passing an empty string'''
        arguments = ['']
        test_parser = ArgParser(arguments)
        test_parser.parse_command()

    def test_invalidarg(self):
        '''tests arg_parser with an invalid argument'''
        arguments = ['--invalid']
        test_parser = ArgParser(arguments)
        with self.assertRaises(SystemExit) as raised:
            test_parser.parse_command()
            self.assertEqual(raised.exception.code, 2)

# Flapping Tests, based on runtime context, Fix
    def test_with_command(self):
        '''tests arg_parser with a valid command'''
        arguments = ['archive']
        test_parser = ArgParser(arguments)
        with self.assertRaises(SystemExit) as raised:
            test_parser.parse_command()
            self.assertEqual(raised.exception.code, 0)
        # Assert Dispatch.archive gets called

    def test_with_invalid_command(self):
        '''tests arg_parser with an invalid command'''
        arguments = ['invalid']
        test_parser = ArgParser(arguments)
        with self.assertRaises(SystemExit) as raised:
            with self.assertRaises(NotImplementedError):
                test_parser.parse_command()
            self.assertEqual(raised.exception.code, 0)
Tests Argument Parsing Tests Argument Parsing tests arg_parser when just passing --help tests arg_parser without passing arguments # Assert that --help is called tests arg_parser when passing an empty string tests arg_parser with an invalid argument # Flapping Tests, based on runtime context, Fix tests arg_parser with a valid command # Assert Dispatch.archive gets called tests arg_parser with an invalid command