# Path: brew/cli/temp.py
# def get_parser():
#     parser = argparse.ArgumentParser(description=u"Temperature Conversion")
#     parser.add_argument(
#         u"-c", u"--celsius", metavar=u"C", type=float, help=u"Temperature in Celsius"
#     )
#     parser.add_argument(
#         u"-f",
#         u"--fahrenheit",
#         metavar=u"F",
#         type=float,
#         help=u"Temperature in Fahrenheit",
#     )
#     return parser
# 
# Path: brew/cli/temp.py
# def get_temp_conversion(fahrenheit, celsius):
#     """
#     Convert temperature between fahrenheit and celsius
#     """
#     if fahrenheit:
#         return round(fahrenheit_to_celsius(fahrenheit), 1)
#     elif celsius:
#         return round(celsius_to_fahrenheit(celsius), 1)
# 
# Path: brew/cli/temp.py
# def main(parser_fn=get_parser, parser_kwargs=None):
#     parser = None
#     if not parser_kwargs:
#         parser = parser_fn()
#     else:
#         parser = parser_fn(**parser_kwargs)
#     args = parser.parse_args()
#     if args.fahrenheit and args.celsius:
#         print(u"Must provide only one of Fahrenheit or Celsius")
#         sys.exit(1)
#     elif not (args.fahrenheit or args.celsius):
#         print(u"Must provide one of Fahrenheit or Celsius")
#         sys.exit(1)
#     out = get_temp_conversion(args.fahrenheit, args.celsius)
#     print(out)


import unittest
from brew.cli.temp import get_parser
from brew.cli.temp import get_temp_conversion
from brew.cli.temp import main
                    for k, v in self.output.items():
                        setattr(args, k, v)
                return args

        def g_parser(output=None):
            return Parser(output)

        self.parser_fn = g_parser
        self.main = main

    def test_main_no_args(self):
        args = {u"output": {u"celsius": None, u"fahrenheit": None}}
        with self.assertRaises(SystemExit):
            self.main(parser_fn=self.parser_fn, parser_kwargs=args)

    def test_main_both_args(self):
        args = {u"output": {u"celsius": 25.0, u"fahrenheit": 62.0}}
        with self.assertRaises(SystemExit):
            self.main(parser_fn=self.parser_fn, parser_kwargs=args)

    def test_main_no_kwargs(self):
        with self.assertRaises(AttributeError):
            self.main(parser_fn=self.parser_fn)

    def test_main_celsius(self):
        args = {u"output": {u"celsius": 25.0, u"fahrenheit": None}}
        self.main(parser_fn=self.parser_fn, parser_kwargs=args)

    def test_main_fahrenheit(self):
        args = {u"output": {u"celsius": None, u"fahrenheit": 62.0}}

# Path: brew/cli/temp.py
# def get_parser():
#     parser = argparse.ArgumentParser(description=u"Temperature Conversion")
#     parser.add_argument(
#         u"-c", u"--celsius", metavar=u"C", type=float, help=u"Temperature in Celsius"
#     )
#     parser.add_argument(
#         u"-f",
#         u"--fahrenheit",
#         metavar=u"F",
#         type=float,
#         help=u"Temperature in Fahrenheit",
#     )
#     return parser
# 
# Path: brew/cli/temp.py
# def get_temp_conversion(fahrenheit, celsius):
#     """
#     Convert temperature between fahrenheit and celsius
#     """
#     if fahrenheit:
#         return round(fahrenheit_to_celsius(fahrenheit), 1)
#     elif celsius:
#         return round(celsius_to_fahrenheit(celsius), 1)
# 
# Path: brew/cli/temp.py
# def main(parser_fn=get_parser, parser_kwargs=None):
#     parser = None
#     if not parser_kwargs:
#         parser = parser_fn()
#     else:
#         parser = parser_fn(**parser_kwargs)
#     args = parser.parse_args()
#     if args.fahrenheit and args.celsius:
#         print(u"Must provide only one of Fahrenheit or Celsius")
#         sys.exit(1)
#     elif not (args.fahrenheit or args.celsius):
#         print(u"Must provide one of Fahrenheit or Celsius")
#         sys.exit(1)
#     out = get_temp_conversion(args.fahrenheit, args.celsius)
#     print(out)


# Path: tests/test_cli_temp.py
import unittest
from brew.cli.temp import get_parser
from brew.cli.temp import get_temp_conversion
from brew.cli.temp import main

                    for k, v in self.output.items():
                        setattr(args, k, v)
                return args

        def g_parser(output=None):
            return Parser(output)

        self.parser_fn = g_parser
        self.main = main

    def test_main_no_args(self):
        args = {u"output": {u"celsius": None, u"fahrenheit": None}}
        with self.assertRaises(SystemExit):
            self.main(parser_fn=self.parser_fn, parser_kwargs=args)

    def test_main_both_args(self):
        args = {u"output": {u"celsius": 25.0, u"fahrenheit": 62.0}}
        with self.assertRaises(SystemExit):
            self.main(parser_fn=self.parser_fn, parser_kwargs=args)

    def test_main_no_kwargs(self):
        with self.assertRaises(AttributeError):
            self.main(parser_fn=self.parser_fn)

    def test_main_celsius(self):
        args = {u"output": {u"celsius": 25.0, u"fahrenheit": None}}
        self.main(parser_fn=self.parser_fn, parser_kwargs=args)

    def test_main_fahrenheit(self):
        args = {u"output": {u"celsius": None, u"fahrenheit": 62.0}}

        self.main(parser_fn=self.parser_fn, parser_kwargs=args)