Exemplo n.º 1
0
def load_some_tags():
    t1 = Tag(u'pâtes')
    t2 = Tag(u'tomate')
    r1 = Recipe(u'carbonara')
    r1.tags = [t1]
    r2 = Recipe(u'bolognaise')
    r2.tags = [t1, t2]
    r3 = Recipe(u'tomates farcies')
    r3.tags = [t2]
    r4 = Recipe(u'saucisses-purée')

    tags = [t1, t2]
    recipes = [r1, r2, r3, r4]
    Session.add_all(tags)
    Session.add_all(recipes)
    Session.flush()
    return tags, recipes
Exemplo n.º 2
0
    def test_cant_add_twice_the_same_even_after_reload(self):
        tw = TagsWidget()
        QTest.keyClicks(tw.lineEdit, 'lourd')
        tw.addTag()
        Session.add(Tag(u'Another tag'))
        tw.reload()

        QTest.keyClicks(tw.lineEdit, 'lourd')
        tw.addTag()

        self.assertEqual(tw.listWidget.count(), 1)
Exemplo n.º 3
0
    def test_create_recipe(self):
        fut = RecipeEditionDialog()
        self.assertEqual(fut.name.text(), '')
        self.assertEqual(fut.description.toPlainText(), '')
        self.assertEqual(fut.tags.text(), '')

        fut.name.setText(u'Endive')
        fut.description.setPlainText(u'desc')
        fut.tags.setText(u'légume')
        tag = Tag(u'légume')
        Session.add(tag)

        fut.accept()

        r = fut.recipe
        self.assertEqual(r.name, u'Endive')
        self.assertEqual(r.description, u'desc')
        self.assertEqual(r.tags, [tag])
Exemplo n.º 4
0
    def test_edit_recipe(self):
        r = self.recipes[1]
        fut = RecipeEditionDialog(r)
        self.assertEqual(fut.name.text(), r.name)
        self.assertEqual(fut.description.toPlainText(), r.description)
        self.assertIn(fut.tags.text(), [u'pâtes;tomate', u'tomate;pâtes'])

        fut.name.setText(u'Endive')
        fut.description.setPlainText(u'desc')
        fut.tags.setText(u'légume')
        tag = Tag(u'légume')
        Session.add(tag)

        fut.accept()

        r = fut.recipe
        self.assertEqual(r.name, u'Endive')
        self.assertEqual(r.description, u'desc')
        self.assertEqual(r.tags, [tag])
Exemplo n.º 5
0
    def test_get_existing_tag(self):
        t = Tag('yay')
        Session.add(t)

        self.assertEqual(t, Tag.get('yay'))
Exemplo n.º 6
0
    def test_new_tag(self):
        t = Tag.get('yay')

        self.assertEqual(t.name, 'yay')
Exemplo n.º 7
0
 def setUp(self):
     super(TagsWidgetTestCase, self).setUp()
     Session.add_all(Tag(t) for t in [u'lourd', u'pâtes', u'hiver'])
     self.app = get_app()
Exemplo n.º 8
0
 def save_recipe(self):
     self.recipe.name = self.name.text()
     self.recipe.description = self.description.toPlainText()
     self.recipe.tags = [Tag.get(t) for t in self.tags.text().split(';')] if self.tags.text() else []
     Session.add(self.recipe)
Exemplo n.º 9
0
 def save_recipe(self):
     self.recipe.name = self.name.text()
     self.recipe.description = self.description.toPlainText()
     self.recipe.tags = [Tag.get(t) for t in self.tags.text().split(';')
                         ] if self.tags.text() else []
     Session.add(self.recipe)
Exemplo n.º 10
0
    def test_get_existing_tag(self):
        t = Tag('yay')
        Session.add(t)

        self.assertEqual(t, Tag.get('yay'))
Exemplo n.º 11
0
    def test_new_tag(self):
        t = Tag.get('yay')

        self.assertEqual(t.name, 'yay')