# Path: brew/cli/sugar.py
# def get_parser():
#     parser = argparse.ArgumentParser(description=u"Sugar Conversion")
#     parser.add_argument(
#         u"-b", u"--brix", metavar=u"B", type=float, help=u"Degrees Brix"
#     )
#     parser.add_argument(
#         u"-p", u"--plato", metavar=u"P", type=float, help=u"Degrees Plato"
#     )
#     parser.add_argument(
#         u"-s", u"--sg", metavar=u"S", type=float, help=u"Specific Gravity"
#     )
#     parser.add_argument(
#         u"-o",
#         u"--out",
#         metavar=u"O",
#         type=str,
#         help=u"Desired Output (b, p, s accepted)",
#     )
#     return parser
# 
# Path: brew/cli/sugar.py
# def get_sugar_conversion(brix_in, plato_in, sg_in, sugar_out):
#     """
#     Convert one sugar unit to another or print all.
# 
#     brix_in - Degrees Brix Input
#     plato_in - Degrees Plato Input
#     sg_in - Specific Gravity Input
#     sugar_out - Type of conversion ('b', 'p', 's', or None)
#     """
#     brix, plato, sg = 0.0, 0.0, 0.0
#     if brix_in:
#         brix = brix_in
#         plato = brix_to_plato(brix_in)
#         sg = brix_to_sg(brix_in)
#     elif plato_in:
#         brix = plato_to_brix(plato_in)
#         plato = plato_in
#         sg = plato_to_sg(plato_in)
#     elif sg_in:
#         brix = sg_to_brix(sg_in)
#         plato = sg_to_plato(sg_in)
#         sg = sg_in
# 
#     brix = round(brix, 1)
#     plato = round(plato, 1)
#     sg = round(sg, 3)
#     if sugar_out and sugar_out in [u"b", u"p", u"s"]:
#         if sugar_out == u"b":
#             return brix
#         elif sugar_out == u"p":
#             return plato
#         elif sugar_out == u"s":
#             return sg
#     else:
#         out = textwrap.dedent(
#             u"""\
#         SG\tPlato\tBrix
#         {:0.3f}\t{:0.1f}\t{:0.1f}""".format(
#                 sg, plato, brix
#             )
#         )
#         return out
# 
# Path: brew/cli/sugar.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 sum(bool(arg) for arg in [args.brix, args.plato, args.sg]) != 1:
#         print(u"Must provide only one of Brix, Plato or Specific Gravity")
#         sys.exit(1)
#     print(get_sugar_conversion(args.brix, args.plato, args.sg, args.out))


import unittest
from brew.cli.sugar import get_parser
from brew.cli.sugar import get_sugar_conversion
from brew.cli.sugar import main
        out = get_sugar_conversion(None, self.plato, None, u"p")
        self.assertEquals(round(out, 1), self.plato)

    def test_get_sugar_conversion_plato_to_sg(self):
        out = get_sugar_conversion(None, self.plato, None, u"s")
        self.assertEquals(round(out, 3), self.sg)

    def test_get_sugar_conversion_sg_to_brix(self):
        out = get_sugar_conversion(None, None, self.sg, u"b")
        self.assertEquals(round(out, 1), self.brix)

    def test_get_sugar_conversion_sg_to_plato(self):
        out = get_sugar_conversion(None, None, self.sg, u"p")
        self.assertEquals(round(out, 1), self.plato)

    def test_get_sugar_conversion_sg_to_sg(self):
        out = get_sugar_conversion(None, None, self.sg, u"s")
        self.assertEquals(round(out, 3), self.sg)

    def test_get_sugar_conversion_all_brix(self):
        out = get_sugar_conversion(self.brix, None, None, None)
        expected = u"SG\tPlato\tBrix\n1.092\t22.0\t22.0"
        self.assertEquals(out, expected)

    def test_get_sugar_conversion_all_plato(self):
        out = get_sugar_conversion(None, self.plato, None, None)
        expected = u"SG\tPlato\tBrix\n1.092\t22.0\t22.0"
        self.assertEquals(out, expected)

    def test_get_sugar_conversion_all_sg(self):

# Path: brew/cli/sugar.py
# def get_parser():
#     parser = argparse.ArgumentParser(description=u"Sugar Conversion")
#     parser.add_argument(
#         u"-b", u"--brix", metavar=u"B", type=float, help=u"Degrees Brix"
#     )
#     parser.add_argument(
#         u"-p", u"--plato", metavar=u"P", type=float, help=u"Degrees Plato"
#     )
#     parser.add_argument(
#         u"-s", u"--sg", metavar=u"S", type=float, help=u"Specific Gravity"
#     )
#     parser.add_argument(
#         u"-o",
#         u"--out",
#         metavar=u"O",
#         type=str,
#         help=u"Desired Output (b, p, s accepted)",
#     )
#     return parser
# 
# Path: brew/cli/sugar.py
# def get_sugar_conversion(brix_in, plato_in, sg_in, sugar_out):
#     """
#     Convert one sugar unit to another or print all.
# 
#     brix_in - Degrees Brix Input
#     plato_in - Degrees Plato Input
#     sg_in - Specific Gravity Input
#     sugar_out - Type of conversion ('b', 'p', 's', or None)
#     """
#     brix, plato, sg = 0.0, 0.0, 0.0
#     if brix_in:
#         brix = brix_in
#         plato = brix_to_plato(brix_in)
#         sg = brix_to_sg(brix_in)
#     elif plato_in:
#         brix = plato_to_brix(plato_in)
#         plato = plato_in
#         sg = plato_to_sg(plato_in)
#     elif sg_in:
#         brix = sg_to_brix(sg_in)
#         plato = sg_to_plato(sg_in)
#         sg = sg_in
# 
#     brix = round(brix, 1)
#     plato = round(plato, 1)
#     sg = round(sg, 3)
#     if sugar_out and sugar_out in [u"b", u"p", u"s"]:
#         if sugar_out == u"b":
#             return brix
#         elif sugar_out == u"p":
#             return plato
#         elif sugar_out == u"s":
#             return sg
#     else:
#         out = textwrap.dedent(
#             u"""\
#         SG\tPlato\tBrix
#         {:0.3f}\t{:0.1f}\t{:0.1f}""".format(
#                 sg, plato, brix
#             )
#         )
#         return out
# 
# Path: brew/cli/sugar.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 sum(bool(arg) for arg in [args.brix, args.plato, args.sg]) != 1:
#         print(u"Must provide only one of Brix, Plato or Specific Gravity")
#         sys.exit(1)
#     print(get_sugar_conversion(args.brix, args.plato, args.sg, args.out))


# Path: tests/test_cli_sugar.py
import unittest
from brew.cli.sugar import get_parser
from brew.cli.sugar import get_sugar_conversion
from brew.cli.sugar import main

        out = get_sugar_conversion(None, self.plato, None, u"p")
        self.assertEquals(round(out, 1), self.plato)

    def test_get_sugar_conversion_plato_to_sg(self):
        out = get_sugar_conversion(None, self.plato, None, u"s")
        self.assertEquals(round(out, 3), self.sg)

    def test_get_sugar_conversion_sg_to_brix(self):
        out = get_sugar_conversion(None, None, self.sg, u"b")
        self.assertEquals(round(out, 1), self.brix)

    def test_get_sugar_conversion_sg_to_plato(self):
        out = get_sugar_conversion(None, None, self.sg, u"p")
        self.assertEquals(round(out, 1), self.plato)

    def test_get_sugar_conversion_sg_to_sg(self):
        out = get_sugar_conversion(None, None, self.sg, u"s")
        self.assertEquals(round(out, 3), self.sg)

    def test_get_sugar_conversion_all_brix(self):
        out = get_sugar_conversion(self.brix, None, None, None)
        expected = u"SG\tPlato\tBrix\n1.092\t22.0\t22.0"
        self.assertEquals(out, expected)

    def test_get_sugar_conversion_all_plato(self):
        out = get_sugar_conversion(None, self.plato, None, None)
        expected = u"SG\tPlato\tBrix\n1.092\t22.0\t22.0"
        self.assertEquals(out, expected)

    def test_get_sugar_conversion_all_sg(self):

        out = get_sugar_conversion(None, None, self.sg, None)