Example #1
0
    def test_draft_merge_style(self):
        model.Recipe(name='Rocky Mountain River IPA',
                     style=model.Style(name='American IPA'),
                     state=u'PUBLISHED')
        model.commit()

        # Make a new draft of the recipe
        model.Recipe.query.first().draft()
        model.commit()

        assert model.Recipe.query.count() == 2

        # Change the style of the draft
        draft = model.Recipe.query.filter(
            model.Recipe.state == 'DRAFT').first()
        draft.style = model.Style(name='Baltic Porter')
        model.commit()

        # Merge the draft back into its origin recipe.
        draft = model.Recipe.query.filter(
            model.Recipe.state == 'DRAFT').first()
        draft.publish()
        model.commit()

        # Make sure the remaining version is the (newly saved) draft
        assert model.Recipe.query.count() == 1
        assert model.Style.query.count() == 2
        published = model.Recipe.query.first()

        assert published.style == model.Style.get_by(name='Baltic Porter')
Example #2
0
    def setUp(self):
        super(TestAllGrainBuilder, self).setUp()

        model.Style(name='American IPA',
                    min_og=1.056,
                    max_og=1.075,
                    min_fg=1.01,
                    max_fg=1.018,
                    min_ibu=40,
                    max_ibu=70,
                    min_srm=6,
                    max_srm=15,
                    min_abv=.055,
                    max_abv=.075,
                    category_number=14,
                    style_letter='B')
        model.Style(name='Spice, Herb, or Vegetable Beer',
                    category_number=21,
                    style_letter='A')
        model.commit()

        self.get("/")
        self.b.find_element_by_link_text("Create Your Own Recipe").click()

        time.sleep(.1)
        self.b.find_element_by_id("name").clear()
        self.b.find_element_by_id("name").send_keys("Rocky Mountain River IPA")
        Select(self.b.find_element_by_id("type")).select_by_visible_text(
            "All Grain")
        self.b.find_element_by_css_selector("button.ribbon").click()
Example #3
0
    def test_sort_by_style(self):
        R({
            'name': 'Recipe 1',
            'state': 'PUBLISHED',
            'style': model.Style(name='Baltic Porter')
        })
        R({
            'name': 'Recipe 2',
            'state': 'PUBLISHED',
            'style': model.Style(name='American IPA')
        })
        R({
            'name': 'Recipe 3',
            'state': 'PUBLISHED',
            'style': model.Style(name='Schwarzbier')
        })
        R({
            'name': 'Recipe 4',
            'state': 'PUBLISHED',
            'style': model.Style(name='Belgian Golden Ale')
        })
        model.commit()

        self._get({'order_by': 'style'})
        self._eq('pages', 1)
        self._eq('current_page', 1)
        self._eq('offset', 0)
        self._eq('perpage', 25)
        self._eq('total', 4)
        self._eq('order_by', 'style')
        self._eq('direction', 'DESC')
        assert len(self._ns['recipes']) == 4
        assert self._ns['recipes'][0].name == 'Recipe 3'
        assert self._ns['recipes'][1].name == 'Recipe 4'
        assert self._ns['recipes'][2].name == 'Recipe 1'
        assert self._ns['recipes'][3].name == 'Recipe 2'

        self._get({'order_by': 'style', 'direction': 'ASC'})
        self._eq('pages', 1)
        self._eq('current_page', 1)
        self._eq('offset', 0)
        self._eq('perpage', 25)
        self._eq('total', 4)
        self._eq('order_by', 'style')
        self._eq('direction', 'ASC')
        assert len(self._ns['recipes']) == 4
        assert self._ns['recipes'][0].name == 'Recipe 2'
        assert self._ns['recipes'][1].name == 'Recipe 1'
        assert self._ns['recipes'][2].name == 'Recipe 4'
        assert self._ns['recipes'][3].name == 'Recipe 3'
Example #4
0
    def test_style_copy_with_overrides(self):
        model.Recipe(name='Rocky Mountain River IPA',
                     style=model.Style(name=u'American IPA'))
        model.commit()

        recipe = model.Recipe.query.first()
        recipe.duplicate({'style': model.Style(name=u'Baltic Porter')})
        model.commit()

        assert model.Recipe.query.count() == 2
        assert model.Style.query.count() == 2

        r1, r2 = model.Recipe.get(1), model.Recipe.get(2)
        assert r1.style and r2.style
        assert r1.style != r2.style
Example #5
0
    def test_browse_index(self):
        model.Style(name='American IPA')
        model.commit()

        response = self.get('/recipes/')
        assert response.status_int == 200
        assert len(response.namespace.get('styles')) == 1
Example #6
0
    def test_style_copy(self):
        model.Recipe(name='Rocky Mountain River IPA',
                     style=model.Style(name=u'American IPA'))
        model.commit()

        recipe = model.Recipe.query.first()
        recipe.duplicate()
        model.commit()

        assert model.Recipe.query.count() == 2
        assert model.Style.query.count() == 1

        r1, r2 = model.Recipe.get(1), model.Recipe.get(2)
        assert r1.style == r2.style == model.Style.get(1)
Example #7
0
    def test_filter_by_style(self):
        style = model.Style(name='American IPA')
        R({'name': 'Simple Recipe', 'state': 'PUBLISHED', 'style': style})
        model.commit()

        self._get()
        self._eq('pages', 1)
        self._eq('current_page', 1)
        self._eq('offset', 0)
        self._eq('perpage', 25)
        self._eq('total', 1)
        self._eq('order_by', 'last_updated')
        self._eq('direction', 'DESC')
        assert self._ns['recipes'][0].id == model.Recipe.query.first().id

        self._get({'style': '1'})
        self._eq('pages', 1)
        self._eq('current_page', 1)
        self._eq('offset', 0)
        self._eq('perpage', 25)
        self._eq('total', 1)
        self._eq('order_by', 'last_updated')
        self._eq('direction', 'DESC')
        assert self._ns['recipes'][0].id == model.Recipe.query.first().id

        model.Style(name='American Stout')
        model.commit()

        self._get({'style': '2'})
        self._eq('pages', 1)
        self._eq('current_page', 1)
        self._eq('offset', 0)
        self._eq('perpage', 25)
        self._eq('total', 0)
        self._eq('order_by', 'last_updated')
        self._eq('direction', 'DESC')
        assert len(self._ns['recipes']) == 0
Example #8
0
    def test_style_remove(self):
        model.Recipe(name='American IPA',
                     slugs=[
                         model.RecipeSlug(name='American IPA'),
                         model.RecipeSlug(name='American IPA (Revised)')
                     ],
                     style=model.Style(name='Some Style'),
                     author=model.User.get(1))
        model.commit()

        response = self.post('/recipes/1/american-ipa/builder?_method=PUT',
                             params={'recipe': dumps({'style': None})})
        assert response.status_int == 200
        recipe = model.Recipe.query.first()
        assert recipe.style is None