def test_gallon_to_l(self):
     assert to_l(*(10, 'GALLON')) == 37.854117799999997
 def test_l_to_l(self):
     assert to_l(*(10, 'LITER')) == 10
 def test_tsp_to_l(self):
     assert to_l(*(5, 'TEASPOON')) == 0.02464460795
 def test_tbsp_to_l(self):
     assert to_l(*(5, 'TABLESPOON')) == 0.073933823999999995
 def test_l_to_l(self):
     assert to_l(*(10, "LITER")) == 10
Exemple #6
0
    def to_xml(self):
        from draughtcraft.lib.beerxml import export

        if self.hop:

            kw = {
                'name'   : self.hop.name,
                'alpha'  : self.hop.alpha_acid,
                'amount' : to_kg(self.amount, self.unit),
                'time'   : self.minutes,
                'notes'  : self.hop.description,
                'form'   : self.form.capitalize(),
                'origin' : self.hop.printed_origin
            }

            kw['use'] = {
                'MASH'       : 'Mash',
                'FIRST WORT' : 'First Wort',
                'BOIL'       : 'Boil',
                'POST-BOIL'  : 'Aroma',
                'FLAME OUT'  : 'Aroma',
                'PRIMARY'    : 'Dry Hop',
                'SECONDARY'  : 'Dry Hop',
                'TERTIARY'   : 'Dry Hop'
            }.get(self.use)

            return export.Hop(**kw)

        if self.fermentable:
            kw = {
                'name'           : self.fermentable.name,
                'amount'         : to_kg(self.amount, self.unit),
                'yield'          : self.fermentable.percent_yield,
                'color'          : self.fermentable.lovibond,
                'add_after_boil' : self.step == 'fermentation',
                'origin'         : self.fermentable.printed_origin,
                'notes'          : self.fermentable.description
            }

            kw['type'] = {
                'MALT'    : 'Grain',
                'GRAIN'   : 'Grain',
                'ADJUNCT' : 'Adjunct',
                'EXTRACT' : 'Extract',
                'SUGAR'   : 'Sugar'
            }.get(self.fermentable.type)

            if self.fermentable.type == 'EXTRACT' and 'DME' in self.fermentable.name:
                kw['type'] = 'Dry Extract'

            return export.Fermentable(**kw)

        if self.yeast:
            kw = {
                'name'        : self.yeast.name,
                'form'        : self.yeast.form.capitalize(),
                'attenuation' : self.yeast.attenuation * 100.00,
                'notes'       : self.yeast.description
            }

            # Map types as appropriately as possible to BeerXML <TYPE>'s.
            kw['type'] = {
                'ALE'   : 'Ale',
                'LAGER' : 'Lager',
                'WILD'  : 'Ale',
                'MEAD'  : 'Wine',
                'CIDER' : 'Wine',
                'WINE'  : 'Wine'
            }.get(self.yeast.type)

            if self.yeast.form == 'LIQUID':
                #
                # If the yeast is liquid, it's probably a activator/vial.  For
                # simplicity, we'll assume Wyeast's volume, 125ml.
                #
                kw['amount'] = 0.125
            else:
                #
                # If the yeast is dry, it's probably a small packet.  For
                # simplicity, we'll assume a standard weight of 11.5g.
                #
                kw['amount'] = 0.0115
                kw['amount_is_weight'] = True

            if self.use in ('SECONDARY', 'TERTIARY'):
                kw['add_to_secondary'] = True

            return export.Yeast(**kw)

        if self.extra:
            kw = {
                'name'  : self.extra.name,
                'type'  : string.capwords(self.extra.type),
                'time'  : self.minutes,
                'notes' : self.extra.description
            }

            kw['use'] = {
                'MASH'       : 'Mash',
                'FIRST WORT' : 'Boil',
                'BOIL'       : 'Boil',
                'POST-BOIL'  : 'Boil',
                'FLAME OUT'  : 'Boil',
                'PRIMARY'    : 'Primary',
                'SECONDARY'  : 'Secondary',
                'TERTIARY'   : 'Secondary'
            }.get(self.use)

            if self.unit is None:
                #
                # If there's no unit (meaning it's just one "unit"), assume
                # a weight of 15 grams.
                #
                kw['amount'] = 0.015
                kw['amount_is_weight'] = True
            elif self.extra.liquid:
                kw['amount'] = to_l(self.amount, self.unit)
            else:
                kw['amount'] = to_kg(self.amount, self.unit)
                kw['amount_is_weight'] = True

            return export.Misc(**kw)
Exemple #7
0
    def to_xml(self):
        from draughtcraft.lib.beerxml import export

        if self.hop:

            kw = {
                'name': self.hop.name,
                'alpha': self.hop.alpha_acid,
                'amount': to_kg(self.amount, self.unit),
                'time': self.minutes,
                'notes': self.hop.description,
                'form': self.form.capitalize(),
                'origin': self.hop.printed_origin
            }

            kw['use'] = {
                'MASH': 'Mash',
                'FIRST WORT': 'First Wort',
                'BOIL': 'Boil',
                'POST-BOIL': 'Aroma',
                'FLAME OUT': 'Aroma',
                'PRIMARY': 'Dry Hop',
                'SECONDARY': 'Dry Hop',
                'TERTIARY': 'Dry Hop'
            }.get(self.use)

            return export.Hop(**kw)

        if self.fermentable:
            kw = {
                'name': self.fermentable.name,
                'amount': to_kg(self.amount, self.unit),
                'yield': self.fermentable.percent_yield,
                'color': self.fermentable.lovibond,
                'add_after_boil': self.step == 'fermentation',
                'origin': self.fermentable.printed_origin,
                'notes': self.fermentable.description
            }

            kw['type'] = {
                'MALT': 'Grain',
                'GRAIN': 'Grain',
                'ADJUNCT': 'Adjunct',
                'EXTRACT': 'Extract',
                'SUGAR': 'Sugar'
            }.get(self.fermentable.type)

            if self.fermentable.type == 'EXTRACT' and \
                    'DME' in self.fermentable.name:
                kw['type'] = 'Dry Extract'

            return export.Fermentable(**kw)

        if self.yeast:
            kw = {
                'name': self.yeast.name,
                'form': self.yeast.form.capitalize(),
                'attenuation': self.yeast.attenuation * 100.00,
                'notes': self.yeast.description
            }

            # Map types as appropriately as possible to BeerXML <TYPE>'s.
            kw['type'] = {
                'ALE': 'Ale',
                'LAGER': 'Lager',
                'WILD': 'Ale',
                'MEAD': 'Wine',
                'CIDER': 'Wine',
                'WINE': 'Wine'
            }.get(self.yeast.type)

            if self.yeast.form == 'LIQUID':
                #
                # If the yeast is liquid, it's probably a activator/vial.  For
                # simplicity, we'll assume Wyeast's volume, 125ml.
                #
                kw['amount'] = 0.125
            else:
                #
                # If the yeast is dry, it's probably a small packet.  For
                # simplicity, we'll assume a standard weight of 11.5g.
                #
                kw['amount'] = 0.0115
                kw['amount_is_weight'] = True

            if self.use in ('SECONDARY', 'TERTIARY'):
                kw['add_to_secondary'] = True

            return export.Yeast(**kw)

        if self.extra:
            kw = {
                'name': self.extra.name,
                'type': string.capwords(self.extra.type),
                'time': self.minutes,
                'notes': self.extra.description
            }

            kw['use'] = {
                'MASH': 'Mash',
                'FIRST WORT': 'Boil',
                'BOIL': 'Boil',
                'POST-BOIL': 'Boil',
                'FLAME OUT': 'Boil',
                'PRIMARY': 'Primary',
                'SECONDARY': 'Secondary',
                'TERTIARY': 'Secondary'
            }.get(self.use)

            if self.unit is None:
                #
                # If there's no unit (meaning it's just one "unit"), assume
                # a weight of 15 grams.
                #
                kw['amount'] = 0.015
                kw['amount_is_weight'] = True
            elif self.extra.liquid:
                kw['amount'] = to_l(self.amount, self.unit)
            else:
                kw['amount'] = to_kg(self.amount, self.unit)
                kw['amount_is_weight'] = True

            return export.Misc(**kw)
Exemple #8
0
 def test_l_to_l(self):
     assert to_l(*(10, 'LITER')) == 10
Exemple #9
0
 def test_gallon_to_l(self):
     assert to_l(*(10, 'GALLON')) == 37.854117799999997
Exemple #10
0
 def test_tbsp_to_l(self):
     assert to_l(*(5, 'TABLESPOON')) == 0.073933823999999995
Exemple #11
0
 def test_tsp_to_l(self):
     assert to_l(*(5, 'TEASPOON')) == 0.02464460795