Skip to content

Instantly share code, notes, and snippets.

@SRomansky
Created September 27, 2014 07:14
Show Gist options
  • Save SRomansky/0178611f4a31d2326847 to your computer and use it in GitHub Desktop.
Save SRomansky/0178611f4a31d2326847 to your computer and use it in GitHub Desktop.
framework/test_presentation.py version 2 with out odd decorator.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# freeseer - vga/presentation capture software
#
# Copyright (C) 2013 Free and Open Source Software Learning Centre
# http://fosslc.org
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# For support, questions, suggestions or any other inquiries, visit:
# http://wiki.github.com/Freeseer/freeseer/
import os
import shutil
import tempfile
import unittest
import pytest
from PyQt4 import QtSql
from freeseer.framework.config.profile import Profile
from freeseer.framework.database import QtDBConnector
from freeseer.framework.plugin import PluginManager
from freeseer.framework.presentation import Presentation
profile_path = ""
@pytest.fixture
def db(scope="session"):
global profile_path
profile_path = tempfile.mkdtemp()
profile = Profile(profile_path, 'testing')
db_file = os.path.join(profile_path, 'presentations.db')
db = QtDBConnector(db_file, PluginManager(profile))
return db
def test_query_result_types(db):
# Tests that check if a query is returned
assert isinstance(db.get_talks(), QtSql.QSqlQuery)
assert isinstance(db.get_events(), QtSql.QSqlQuery)
assert isinstance(db.get_talk_ids(), QtSql.QSqlQuery)
assert isinstance(db.get_talks_by_event("SC2011"), QtSql.QSqlQuery)
assert isinstance(db.get_talks_by_room("T105"), QtSql.QSqlQuery)
# Test that a presentation is returned
assert isinstance(db.get_presentation(1), Presentation)
# Tests that check if a model is returned
assert isinstance(db.get_presentations_model(), QtSql.QSqlTableModel)
assert isinstance(db.get_events_model(), QtSql.QSqlQueryModel)
assert isinstance(db.get_rooms_model("SC2011"), QtSql.QSqlQueryModel)
assert isinstance(db.get_talks_model("SC2011", "T105"), QtSql.QSqlQueryModel)
def test_add_talks_from_rss(db):
"""Test that talks are retrieved from the RSS feed"""
feed1 = "http://fosslc.org/drupal/presentations_rss/summercamp2010"
feed2 = "http://fosslc.org/drupal/presentations_rss/sc2011"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment