def OpenPressed(self): openfilename = QtWidgets.QFileDialog.getOpenFileName(self, 'Выберите игру', "")[0] if openfilename and openfilename.endswith(".xlsx"): self.game, error = questiondata.create_game(openfilename) if self.game: if error: ErrorMessage(error) self.state.set_game(self.game) self.category_form = category.CategoryForm(self.game) self.category_form.category_signal[str].connect(self.CategorySelected) self.category_form.show() else: ErrorMessage('Файл не выбран или формат неверный (выберите .xlxs файл')
def test_GameOpened(self): game, _ = questiondata.create_game("Example.xlsx") self.assertIsNotNone(game)
def test_CategoryQuestionPoints(self): game, _ = questiondata.create_game("Example.xlsx") total_points = 0 for category in game.categories: total_points += category.get_total_points() self.assertEqual(60, total_points)
def test_CategoryQuestionNumber(self): game, _ = questiondata.create_game("Example.xlsx") total = 0 for category in game.categories: total += category.get_question_number() self.assertEqual(4, total)
def test_CategoryQuestionLen(self): game, _ = questiondata.create_game("Example.xlsx") category = game.get_category_by_name('Красивые картинки') self.assertEqual(2, len(category.questions))
def test_Category(self): game, _ = questiondata.create_game("Example.xlsx") category = game.get_category_by_name('Красивые картинки') self.assertIsNotNone(category)
def test_CategoryLen(self): game, _ = questiondata.create_game("Example.xlsx") self.assertEqual(2, len(game.categories))
def test_GameLen(self): game, _ = questiondata.create_game("Example.xlsx") self.assertEqual(2, game.length)