Esempio n. 1
0
    def test_remove_recipe(self):
        rw = RecipesWidget()
        self.assertEqual(len(rw.selectedItems()), 0)
        before = Session.query(Recipe).count()

        rw.item(0).setSelected(True)
        rw.item(3).setSelected(True)
        QTest.keyClick(rw, Qt.Key_Delete)

        self.assertEqual(Session.query(Recipe).count(), before - 2)
        self.assertEqual(rw.count(), before - 2)
Esempio n. 2
0
    def test_remove_recipe(self):
        rw = RecipesWidget()
        self.assertEqual(len(rw.selectedItems()), 0)
        before = Session.query(Recipe).count()

        rw.item(0).setSelected(True)
        rw.item(3).setSelected(True)
        QTest.keyClick(rw, Qt.Key_Delete)

        self.assertEqual(Session.query(Recipe).count(), before - 2)
        self.assertEqual(rw.count(), before - 2)
Esempio n. 3
0
    def test_double_click_open_the_recipe_dialog(self, mock_dialog):
        r = self.recipes[0]
        rw = RecipesWidget()
        rw.doubleClick(rw.item(0))

        mock_dialog.assert_called_once_with(r, rw)
        mock_dialog(r, rw).exec_.assert_called_once_with()
Esempio n. 4
0
    def test_double_click_open_the_recipe_dialog(self, mock_dialog):
        r = self.recipes[0]
        rw = RecipesWidget()
        rw.doubleClick(rw.item(0))

        mock_dialog.assert_called_once_with(r, rw)
        mock_dialog(r, rw).exec_.assert_called_once_with()
Esempio n. 5
0
    def test_drag_information_are_correct(self):
        rw = RecipesWidget()
        self.assertIn('application/vnd.re-eat.recipe', rw.mimeTypes())

        items = [rw.item(i) for i in (0, 1)]
        ids = [item.data(Qt.UserRole) for item in items]
        data = rw.mimeData(items)
        stream = QDataStream(data.data('application/vnd.re-eat.recipe'))
        result = []
        while not stream.atEnd():
            result.append(stream.readInt())
        self.assertListEqual(result, ids)
Esempio n. 6
0
    def test_drag_information_are_correct(self):
        rw = RecipesWidget()
        self.assertIn('application/vnd.re-eat.recipe', rw.mimeTypes())

        items = [rw.item(i) for i in (0, 1)]
        ids = [item.data(Qt.UserRole) for item in items]
        data = rw.mimeData(items)
        stream = QDataStream(data.data('application/vnd.re-eat.recipe'))
        result = []
        while not stream.atEnd():
            result.append(stream.readInt())
        self.assertListEqual(result, ids)
Esempio n. 7
0
 def test_drag_is_enabled(self):
     rw = RecipesWidget()
     assert rw.dragEnabled()
     assert rw.item(0).flags() & Qt.ItemIsDragEnabled
Esempio n. 8
0
    def test_the_widget_is_correcty_populated(self):
        rw = RecipesWidget()

        self.assertEqual(rw.count(), 4)
        self.assertEqual(rw.item(0).text(), self.recipes[0].name)
Esempio n. 9
0
 def test_drag_is_enabled(self):
     rw = RecipesWidget()
     assert rw.dragEnabled()
     assert rw.item(0).flags() & Qt.ItemIsDragEnabled
Esempio n. 10
0
    def test_the_widget_is_correcty_populated(self):
        rw = RecipesWidget()

        self.assertEqual(rw.count(), 4)
        self.assertEqual(rw.item(0).text(), self.recipes[0].name)