# Path: brew/exceptions.py
# class YeastException(BrewdayException):
#     pass
# 
# Path: brew/yeasts.py
# class Yeast(object):
#     """
#     A representation of a type of Yeast as added to a Recipe.
#     """
# 
#     def __init__(self, name, percent_attenuation=0.75):
#         """
#         :param float percent_attenuation: The percentage the yeast is expected to attenuate the sugar in the yeast to create alcohol
#         :raises YeastException: If percent_attenuation is not provided
#         """  # noqa
#         self.name = name
#         if percent_attenuation is None:
#             raise YeastException(
#                 u"{}: Must provide percent attenuation".format(self.name)  # noqa
#             )
#         self.percent_attenuation = validate_percentage(percent_attenuation)
# 
#     def __str__(self):
#         if sys.version_info[0] >= 3:
#             return self.__unicode__()
#         else:
#             return self.__unicode__().encode(u"utf8")
# 
#     def __unicode__(self):
#         return u"{0}, attenuation {1:0.1%}".format(
#             self.name.capitalize(), self.percent_attenuation
#         )
# 
#     def __repr__(self):
#         out = u"{0}('{1}'".format(type(self).__name__, self.name)
#         if self.percent_attenuation:
#             out = u"{0}, percent_attenuation={1}".format(out, self.percent_attenuation)
#         out = u"{0})".format(out)
#         return out
# 
#     def __eq__(self, other):
#         if not isinstance(other, self.__class__):
#             return False
#         if (self.name == other.name) and (
#             self.percent_attenuation == other.percent_attenuation
#         ):
#             return True
#         return False
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     def to_dict(self):
#         return {
#             u"name": self.name,
#             u"data": {u"percent_attenuation": self.percent_attenuation},
#         }
# 
#     def to_json(self):
#         return json.dumps(self.to_dict(), sort_keys=True)
# 
#     @classmethod
#     def validate(cls, yeast_data):
#         required_fields = [(u"name", str)]
#         optional_fields = [(u"percent_attenuation", float)]
#         validate_required_fields(yeast_data, required_fields)
#         validate_optional_fields(yeast_data, optional_fields)
# 
#     def format(self):
#         msg = textwrap.dedent(
#             u"""\
#                 {name} Yeast
#                 -----------------------------------
#                 Attenuation:  {data[percent_attenuation]:0.1%}""".format(
#                 **self.to_dict()
#             )
#         )
#         return msg


import sys
import textwrap
import unittest
from brew.exceptions import YeastException
from brew.yeasts import Yeast
from fixtures import cascade_add
from fixtures import yeast
    def setUp(self):

        # Define Yeasts
        self.yeast = yeast

    def test_str(self):
        out = str(self.yeast)
        self.assertEquals(out, u"Wyeast 1056, attenuation 75.0%")

    def test_unicode(self):
        yeast = Yeast(u"Kölsh", percent_attenuation=0.74)
        out = str(yeast)
        if sys.version_info[0] >= 3:
            self.assertEquals(out, u"Kölsh, attenuation 74.0%")
        else:
            self.assertEquals(out, u"Kölsh, attenuation 74.0%".encode("utf8"))

    def test_repr(self):
        out = repr(self.yeast)
        self.assertEquals(
            out, u"Yeast('Wyeast 1056', percent_attenuation=0.75)"
        )  # noqa

    def test_eq(self):
        yeast1 = Yeast(u"Wyeast 1056", percent_attenuation=0.75)
        yeast2 = Yeast(u"Wyeast 1056", percent_attenuation=0.75)
        self.assertEquals(yeast1, yeast2)

    def test_ne_name(self):
        yeast1 = Yeast(u"Wyeast 1056", percent_attenuation=0.75)

# Path: brew/exceptions.py
# class YeastException(BrewdayException):
#     pass
# 
# Path: brew/yeasts.py
# class Yeast(object):
#     """
#     A representation of a type of Yeast as added to a Recipe.
#     """
# 
#     def __init__(self, name, percent_attenuation=0.75):
#         """
#         :param float percent_attenuation: The percentage the yeast is expected to attenuate the sugar in the yeast to create alcohol
#         :raises YeastException: If percent_attenuation is not provided
#         """  # noqa
#         self.name = name
#         if percent_attenuation is None:
#             raise YeastException(
#                 u"{}: Must provide percent attenuation".format(self.name)  # noqa
#             )
#         self.percent_attenuation = validate_percentage(percent_attenuation)
# 
#     def __str__(self):
#         if sys.version_info[0] >= 3:
#             return self.__unicode__()
#         else:
#             return self.__unicode__().encode(u"utf8")
# 
#     def __unicode__(self):
#         return u"{0}, attenuation {1:0.1%}".format(
#             self.name.capitalize(), self.percent_attenuation
#         )
# 
#     def __repr__(self):
#         out = u"{0}('{1}'".format(type(self).__name__, self.name)
#         if self.percent_attenuation:
#             out = u"{0}, percent_attenuation={1}".format(out, self.percent_attenuation)
#         out = u"{0})".format(out)
#         return out
# 
#     def __eq__(self, other):
#         if not isinstance(other, self.__class__):
#             return False
#         if (self.name == other.name) and (
#             self.percent_attenuation == other.percent_attenuation
#         ):
#             return True
#         return False
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     def to_dict(self):
#         return {
#             u"name": self.name,
#             u"data": {u"percent_attenuation": self.percent_attenuation},
#         }
# 
#     def to_json(self):
#         return json.dumps(self.to_dict(), sort_keys=True)
# 
#     @classmethod
#     def validate(cls, yeast_data):
#         required_fields = [(u"name", str)]
#         optional_fields = [(u"percent_attenuation", float)]
#         validate_required_fields(yeast_data, required_fields)
#         validate_optional_fields(yeast_data, optional_fields)
# 
#     def format(self):
#         msg = textwrap.dedent(
#             u"""\
#                 {name} Yeast
#                 -----------------------------------
#                 Attenuation:  {data[percent_attenuation]:0.1%}""".format(
#                 **self.to_dict()
#             )
#         )
#         return msg


# Path: tests/test_yeasts.py
import sys
import textwrap
import unittest
from brew.exceptions import YeastException
from brew.yeasts import Yeast
from fixtures import cascade_add
from fixtures import yeast

    def setUp(self):

        # Define Yeasts
        self.yeast = yeast

    def test_str(self):
        out = str(self.yeast)
        self.assertEquals(out, u"Wyeast 1056, attenuation 75.0%")

    def test_unicode(self):
        yeast = Yeast(u"Kölsh", percent_attenuation=0.74)
        out = str(yeast)
        if sys.version_info[0] >= 3:
            self.assertEquals(out, u"Kölsh, attenuation 74.0%")
        else:
            self.assertEquals(out, u"Kölsh, attenuation 74.0%".encode("utf8"))

    def test_repr(self):
        out = repr(self.yeast)
        self.assertEquals(
            out, u"Yeast('Wyeast 1056', percent_attenuation=0.75)"
        )  # noqa

    def test_eq(self):
        yeast1 = Yeast(u"Wyeast 1056", percent_attenuation=0.75)
        yeast2 = Yeast(u"Wyeast 1056", percent_attenuation=0.75)
        self.assertEquals(yeast1, yeast2)

    def test_ne_name(self):
        yeast1 = Yeast(u"Wyeast 1056", percent_attenuation=0.75)

        yeast2 = Yeast(u"Wyeast 1057", percent_attenuation=0.75)