当前位置: 首页>>代码示例>>Python>>正文


Python ProfileManager.get方法代码示例

本文整理汇总了Python中freeseer.framework.config.profile.ProfileManager.get方法的典型用法代码示例。如果您正苦于以下问题:Python ProfileManager.get方法的具体用法?Python ProfileManager.get怎么用?Python ProfileManager.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在freeseer.framework.config.profile.ProfileManager的用法示例。


在下文中一共展示了ProfileManager.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestConfig

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestConfig(unittest.TestCase):

    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a PluginManager

        '''
        self.profile_manager = ProfileManager(tempfile.mkdtemp())
        self.profile = self.profile_manager.get('testing')
        self.config = self.profile.get_config('freeseer.conf',
                                              settings.FreeseerConfig,
                                              ['Global'],
                                              read_only=False)

    def tearDown(self):
        '''
        Generic unittest.TestCase.tearDown()
        '''
        shutil.rmtree(self.profile_manager._base_folder)

    def test_save(self):
        '''
        Tests that the config file was created after being saved.
        '''
        filepath = self.profile.get_filepath('freeseer.conf')
        self.config.save()
        self.assertTrue(os.path.exists(filepath))
开发者ID:LCdevelop,项目名称:freeseer,代码行数:31,代码来源:test_config.py

示例2: TestReportEditorApp

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestReportEditorApp(unittest.TestCase):
    '''
    Test cases for ReportEditorApp.
    '''

    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a QtGui.QApplication and ReportEditorApp object.
        ReportEditorApp() causes the UI to be rendered.
        '''
        self.profile_manager = ProfileManager(tempfile.mkdtemp())
        profile = self.profile_manager.get('testing')
        config = profile.get_config('freeseer.conf', settings.FreeseerConfig, storage_args=['Global'], read_only=False)
        db = profile.get_database()

        self.app = QtGui.QApplication([])
        self.report_editor = ReportEditorApp(config, db)
        self.report_editor.show()

    def tearDown(self):
        shutil.rmtree(self.profile_manager._base_folder)
        del self.app
        del self.report_editor.app

    def test_close_report_editor(self):
        '''
        Tests closing the ReportEditorApp
        '''

        QtTest.QTest.mouseClick(self.report_editor.editorWidget.closeButton, Qt.Qt.LeftButton)
        self.assertFalse(self.report_editor.editorWidget.isVisible())

    def test_file_menu_quit(self):
        '''
        Tests ReportEditorApp's File->Quit
        '''

        self.assertTrue(self.report_editor.isVisible())

        # File->Menu
        self.report_editor.actionExit.trigger()
        self.assertFalse(self.report_editor.isVisible())

    def test_help_menu_about(self):
        '''
        Tests ReportEditorApp's Help->About
        '''

        self.assertTrue(self.report_editor.isVisible())

        # Help->About
        self.report_editor.actionAbout.trigger()
        self.assertFalse(self.report_editor.hasFocus())
        self.assertTrue(self.report_editor.aboutDialog.isVisible())

        # Click "Close"
        QtTest.QTest.mouseClick(self.report_editor.aboutDialog.closeButton, Qt.Qt.LeftButton)
        self.assertFalse(self.report_editor.aboutDialog.isVisible())
开发者ID:chungsharo,项目名称:freeseer,代码行数:62,代码来源:test_reporteditor.py

示例3: TestProfileManager

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestProfileManager(unittest.TestCase):
    """Tests the ProfileManager."""

    def setUp(self):
        self.profiles_path = tempfile.mkdtemp()
        self.profile_manager = ProfileManager(self.profiles_path)

    def tearDown(self):
        shutil.rmtree(self.profiles_path)

    def test_get(self):
        """Tests that get returns a Profile instance."""
        profile = self.profile_manager.get('testing')
        self.assertIsInstance(profile, Profile)

    def test_get_cache(self):
        """Tests that get caching is working as expected."""
        profile1 = self.profile_manager.get('testing')
        profile2 = self.profile_manager.get('testing')
        self.assertEqual(profile1, profile2)
开发者ID:LCdevelop,项目名称:freeseer,代码行数:22,代码来源:test_profile.py

示例4: recording

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
    def recording(self, request, test_client, monkeypatch, tmpdir):

        recording = server.app.blueprints['recording']

        monkeypatch.setattr(settings, 'configdir', str(tmpdir.mkdir('configdir')))
        test_client.get('/recordings')

        profile_manager = ProfileManager(str(tmpdir.mkdir('profile')))
        recording.profile = profile_manager.get('testing')
        recording.config = recording.profile.get_config('freeseer.conf', settings.FreeseerConfig, ['Global'], read_only=True)
        recording.config.videodir = str(tmpdir.mkdir('Videos'))
        recording.plugin_manager = PluginManager(recording.profile)

        return recording
开发者ID:Blakstar26,项目名称:freeseer,代码行数:16,代码来源:test_server.py

示例5: TestMultimedia

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestMultimedia(unittest.TestCase):

    def setUp(self):
        self.profile_manager = ProfileManager(tempfile.mkdtemp())
        profile = self.profile_manager.get('testing')
        config = profile.get_config('freeseer.conf', settings.FreeseerConfig, ['Global'], read_only=True)
        plugin_manager = PluginManager(profile)
        self.multimedia = Multimedia(config, plugin_manager)

    def tearDown(self):
        shutil.rmtree(self.profile_manager._base_folder)

    def test_load_backend(self):
        self.multimedia.load_backend(filename=u"test.ogg")

    def test_record_functions(self):
        self.multimedia.load_backend(filename=u"test.ogg")
        self.multimedia.record()
        self.multimedia.pause()
        self.multimedia.stop()
开发者ID:chungsharo,项目名称:freeseer,代码行数:22,代码来源:test_multimedia.py

示例6: TestMultimedia

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestMultimedia(unittest.TestCase):

    def setUp(self):
        self.profile_manager = ProfileManager(tempfile.mkdtemp())
        self.temp_video_dir = tempfile.mkdtemp()
        profile = self.profile_manager.get('testing')
        config = profile.get_config('freeseer.conf', settings.FreeseerConfig, ['Global'], read_only=True)
        config.videodir = self.temp_video_dir
        plugin_manager = PluginManager(profile)
        self.multimedia = Multimedia(config, plugin_manager)

    def tearDown(self):
        shutil.rmtree(self.temp_video_dir)
        shutil.rmtree(self.profile_manager._base_folder)

    def test_load_backend(self):
        self.multimedia.load_backend(filename=u"test.ogg")

    def test_record_functions(self):
        self.multimedia.load_backend(filename=u"test.ogg")
        self.multimedia.record()
        self.multimedia.pause()
        self.multimedia.stop()

    def test_current_state_is_record(self):
        self.multimedia.record()
        self.assertEqual(self.multimedia.current_state, self.multimedia.RECORD)
        self.assertEqual(self.multimedia.player.get_state()[1], gst.STATE_PLAYING)

    def test_current_state_is_pause(self):
        self.multimedia.pause()
        self.assertEqual(self.multimedia.current_state, self.multimedia.PAUSE)
        self.assertEqual(self.multimedia.player.get_state()[1], gst.STATE_PAUSED)

    def test_current_state_is_not_stop(self):
        self.multimedia.player.set_state(self.multimedia.NULL)  # set to NULL
        self.multimedia.stop()
        self.assertNotEqual(self.multimedia.current_state, self.multimedia.STOP)
        self.assertEqual(self.multimedia.player.get_state()[1], gst.STATE_NULL)
开发者ID:LCdevelop,项目名称:freeseer,代码行数:41,代码来源:test_multimedia.py

示例7: TestTalkEditorApp

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestTalkEditorApp(unittest.TestCase):
    '''
    Test suite to verify the functionality of the TalkEditorApp class.

    Tests interact like an end user (using QtTest). Expect the app to be rendered.

    '''

    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a QtGui.QApplication and TalkEditorApp object.
        TalkEditorApp.show() causes the UI to be rendered.
        '''
        self.profile_manager = ProfileManager(tempfile.mkdtemp())
        profile = self.profile_manager.get('testing')
        config = profile.get_config('freeseer.conf', settings.FreeseerConfig,
                                    storage_args=['Global'], read_only=True)
        db = profile.get_database()

        self.app = QtGui.QApplication([])
        self.talk_editor = TalkEditorApp(config, db)
        self.talk_editor.show()

    def tearDown(self):
        '''
        Standard tear down method. Runs after each test_* method.

        This method closes the TalkEditorApp by clicking the "close" button
        '''
        shutil.rmtree(self.profile_manager._base_folder)

        del self.app
        del self.talk_editor.app

    # def test_add_talk(self):
    #     '''
    #     Tests a user creating a talk and adding it.
    #     '''

    #     QtTest.QTest.mouseClick(self.talk_editor.editorWidget.addButton, Qt.Qt.LeftButton)
    #     self.assertFalse(self.talk_editor.editorWidget.isVisible())
    #     self.assertTrue(self.talk_editor.addTalkWidget.isVisible())

    #     mTitle = "This is a test"
    #     mPresenter = "Me, myself, and I"
    #     mEvent = "0 THIS St."
    #     mRoom = "Room 13"

    #     # populate talk data (date and time are prepopulated)
    #     self.talk_editor.addTalkWidget.titleLineEdit.setText(mTitle)
    #     self.talk_editor.addTalkWidget.presenterLineEdit.setText(mPresenter)
    #     self.talk_editor.addTalkWidget.eventLineEdit.setText(mEvent)
    #     self.talk_editor.addTalkWidget.roomLineEdit.setText(mRoom)

    #     # add in the talk
    #     QtTest.QTest.mouseClick(self.talk_editor.addTalkWidget.addButton, Qt.Qt.LeftButton)

    #     # find our talk (ensure it was added)
    #     found = False
    #     row_count = self.talk_editor.editorWidget.editor.model().rowCount() - 1
    #     while row_count >= 0 and not found:  # should be at the end, but you never know
    #         if self.talk_editor.editorWidget.editor.model().index(row_count, 1).data() == mTitle and \
    #                 self.talk_editor.editorWidget.editor.model().index(row_count, 2).data() == mPresenter and \
    #                 self.talk_editor.editorWidget.editor.model().index(row_count, 5).data() == mEvent and \
    #                 self.talk_editor.editorWidget.editor.model().index(row_count, 6).data() == mRoom:
    #                 found = True
    #                 # TODO: Select this row
    #         row_count -= 1

    #     self.assertTrue(found, "Couldn't find talk just inserted...")

    #     # now delete the talk we just created
    #     QtTest.QTest.mouseClick(self.talk_editor.editorWidget.removeButton, Qt.Qt.LeftButton)

    def test_file_menu_quit(self):
        '''
        Tests TalkEditorApp's File->Quit
        '''

        self.assertTrue(self.talk_editor.isVisible())

        # File->Quit
        self.talk_editor.actionExit.trigger()
        self.assertFalse(self.talk_editor.isVisible())

    def test_help_menu_about(self):
        '''
        Tests TalkEditorApp's Help->About
        '''

        self.assertTrue(self.talk_editor.isVisible())

        # Help->About
        self.talk_editor.actionAbout.trigger()
        self.assertFalse(self.talk_editor.hasFocus())
        self.assertTrue(self.talk_editor.aboutDialog.isVisible())

        # Click "Close"
#.........这里部分代码省略.........
开发者ID:chungsharo,项目名称:freeseer,代码行数:103,代码来源:test_talkeditor.py

示例8: TestRecordApp

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestRecordApp(unittest.TestCase):
    '''
    Test suite to verify the functionality of the RecordApp class.

    Tests interact like an end user (using QtTest). Expect the app to be rendered.

    '''

    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a QtGui.QApplication and RecordApp object.
        RecordApp.show() causes the UI to be rendered.
        '''
        self.profile_manager = ProfileManager(tempfile.mkdtemp())
        profile = self.profile_manager.get('testing')
        config = profile.get_config('freeseer.conf', settings.FreeseerConfig, storage_args=['Global'], read_only=False)

        self.app = QtGui.QApplication([])
        self.record_app = RecordApp(profile, config)
        self.record_app.show()

    def tearDown(self):
        '''
        Generic unittest.TestCase.tearDown()
        '''
        shutil.rmtree(self.profile_manager._base_folder)

        self.record_app.actionExit.trigger()
        del self.app

    def test_init_conditions(self):
        '''
        Tests the initial state of the RecordApp
        '''
        # TODO
        pass

    def test_standby_to_recording(self):
        '''
        Tests pre and post conditions when entering Standby, Record, Stop modes

        '''

        # TODO: ROADBLOCK
        # The Gstreamer takes a while to initialize the preview.
        # Due to this, when the unitest clicks "Record", the preview has not yet been initialized
        # and Freeseer freezes
        # It is not trivial or clear how to detect whether or not the preview has loaded
        # It turns out that even if the state is Multimedia.PAUSE, the preview has not quite loaded

#       self.assertTrue(self.record_app.mainWidget.standbyPushButton.isVisible(), "[PRE STANDBY] Expected Standby button to be visible")
#       self.assertFalse(self.record_app.mainWidget.recordPushButton.isVisible(), "[PRE STANDBY] Expected Record button to be invisible")

        # Click the Standby button with the left mouse button
#       QtTest.QTest.mouseClick(self.record_app.mainWidget.standbyPushButton, Qt.Qt.LeftButton)

#       self.assertFalse(self.record_app.mainWidget.standbyPushButton.isVisible(), "[STANDBY] Expected Standby button to be invisible")
#       self.assertTrue(self.record_app.mainWidget.recordPushButton.isVisible(), "[STANDBY] Expected Record button to be visible")

        # TODO: Check if preview has loaded

        # Click the Record button with the left mouse button
#       QtTest.QTest.mouseClick(self.record_app.mainWidget.recordPushButton, Qt.Qt.LeftButton)

#       self.assertFalse(self.record_app.mainWidget.standbyPushButton.isVisible(), "[RECORDING] Expected Standby button to be invisible")
#       self.assertTrue(self.record_app.mainWidget.recordPushButton.isVisible(), "[RECORDING] Expected Record button to be visible")
#       self.assertTrue(self.record_app.mainWidget.recordPushButton.text() == self.record_app.stopString, "[RECORDING] Incorrect button text for this phase")

        # Click the Record button again in 5 seconds with the left mouse button
#       QtTest.QTest.mouseClick(self.record_app.mainWidget.recordPushButton, Qt.Qt.LeftButton)

    def test_reset_timer(self):
        '''
        Tests RecordApp.reset_timer()
        '''

        # set our own values
        self.record_app.time_minutes = 15
        self.record_app.time_seconds = 30

        # reset timer and check that the values are 0
        self.record_app.reset_timer()
        self.assertTrue(self.record_app.time_minutes == 0 and self.record_app.time_seconds == 0)

    def test_file_menu_quit(self):
        '''
        Tests RecordApp's File->Quit
        '''

        self.assertTrue(self.record_app.isVisible())

        # File->Menu
        self.record_app.actionExit.trigger()
        self.assertFalse(self.record_app.isVisible())

    def test_help_menu_about(self):
        '''
        Tests RecordApp's Help->About
#.........这里部分代码省略.........
开发者ID:thatsnotright,项目名称:freeseer,代码行数:103,代码来源:test_record.py

示例9: TestProfileManager

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestProfileManager(unittest.TestCase):
    """Tests the ProfileManager."""

    def setUp(self):
        self.profiles_path = tempfile.mkdtemp()
        self.profile_manager = ProfileManager(self.profiles_path)

    def tearDown(self):
        shutil.rmtree(self.profiles_path)

    def test_get(self):
        """Tests that get returns a Profile instance."""
        profile = self.profile_manager.get('testing')
        self.assertIsInstance(profile, Profile)

    def test_get_non_existent(self):
        """Test for non-existent profile."""
        self.assertRaises(ProfileDoesNotExist, self.profile_manager.get, 'non-existent_profile', create_if_needed=False)

    def test_get_non_existent_creates(self):
        """Test that get creates non-existent profile if create_if_needed=True."""
        self.assertRaises(ProfileDoesNotExist, self.profile_manager.get, 'non-existent_profile', create_if_needed=False)
        profile = self.profile_manager.get('non_existent_profile')
        self.assertIsInstance(profile, Profile)

    def test_get_cache(self):
        """Tests that get caching is working as expected."""
        profile1 = self.profile_manager.get('testing')
        profile2 = self.profile_manager.get('testing')
        self.assertEqual(profile1, profile2)

    def test_list_profiles(self):
        """Tests that list_profiles returns all profiles on file."""
        self.profile_manager.create('testing1')
        self.profile_manager.create('testing2')
        profiles = self.profile_manager.list_profiles()
        self.assertItemsEqual(['testing1', 'testing2'], profiles)

    def test_create_profile(self):
        """Tests that create_profile returns an instance of Profile.."""
        profile = self.profile_manager.create('testing1')
        self.assertIsInstance(profile, Profile)

    def test_create_profile_existing(self):
        """Tests that exception is raised if trying to overwrite existing profile."""
        self.profile_manager.create('testing1')
        self.assertRaises(ProfileAlreadyExists, self.profile_manager.create, 'testing1')

    def test_create_profile_caches(self):
        """Tests that create_profile adds the new Profile instance to cache."""
        self.assertNotIn('testing1', self.profile_manager._cache)
        self.profile_manager.create('testing1')
        self.assertIn('testing1', self.profile_manager._cache)

    def test_delete_profile_existing(self):
        """Tests that delete_profile deletes the profile from cache and file."""
        self.profile_manager.create('testing1')
        self.profile_manager.delete('testing1')
        self.assertRaises(ProfileDoesNotExist, self.profile_manager.get, 'testing1', create_if_needed=False)

    def test_delete_profile_non_existing(self):
        """Non-existent profiles can't be deleted."""
        self.assertRaises(ProfileDoesNotExist, self.profile_manager.delete, 'testing')
开发者ID:Blakstar26,项目名称:freeseer,代码行数:65,代码来源:test_profile.py

示例10: TestConfigToolApp

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestConfigToolApp(unittest.TestCase):
    '''
    Test suite to verify the functionality of the ConfigToolApp class.

    Tests interact like an end user (using QtTest). Expect the app to be rendered.

    NOTE: most tests will follow this format:
        1. Get current config setting
        2. Make UI change (config change happens immediately)
        3. Reparse config file
        4. Test that has changed (using the previous and new)
    '''

    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a QtGui.QApplication and ConfigToolApp object.
        ConfigToolApp.show() causes the UI to be rendered.
        '''
        self.profile_manager = ProfileManager(tempfile.mkdtemp())
        profile = self.profile_manager.get('testing')
        config = profile.get_config('freeseer.conf', settings.FreeseerConfig, storage_args=['Global'], read_only=False)

        self.app = QtGui.QApplication([])
        self.config_tool = ConfigToolApp(profile, config)
        self.config_tool.show()

    def tearDown(self):
        '''
        Standard tear down method. Runs after each test_* method.

        This method closes the ConfigToolApp by clicking the "close" button
        '''

        QtTest.QTest.mouseClick(self.config_tool.mainWidget.closePushButton, Qt.Qt.LeftButton)
        shutil.rmtree(self.profile_manager._base_folder)
        del self.config_tool.app
        self.app.deleteLater()

    def test_default_widget(self):
        self.assertTrue(self.config_tool.currentWidget == self.config_tool.generalWidget)

    def test_general_settings(self):
        '''
        Tests for the config tool's General Tab
        '''

        # Select "General" tab
        item = self.config_tool.mainWidget.optionsTreeWidget.findItems(self.config_tool.generalString, QtCore.Qt.MatchExactly)
        self.assertFalse(not item or item[0] is None)
        self.config_tool.mainWidget.optionsTreeWidget.setCurrentItem(item[0])
        QtTest.QTest.mouseClick(self.config_tool.mainWidget.optionsTreeWidget, Qt.Qt.LeftButton)

        # Language drop-down
        # TODO

        # Record directory
        # TODO

        # AutoHide Checkbox
        for i in range(2):
            state = self.config_tool.currentWidget.autoHideCheckBox.checkState()
            expected_state = QtCore.Qt.Unchecked
            if state == QtCore.Qt.Unchecked:
                expected_state = QtCore.Qt.Checked
            self.config_tool.currentWidget.autoHideCheckBox.click()
            self.assertEquals(
                self.config_tool.currentWidget.autoHideCheckBox.checkState(), expected_state)

            self.assertEquals(self.config_tool.config.auto_hide, expected_state == QtCore.Qt.Checked)

    def test_recording_settings(self):
        '''
        Tests for config tool's Recording tab
        '''

        # Select "Recording" tab
        item = self.config_tool.mainWidget.optionsTreeWidget.findItems(self.config_tool.avString, QtCore.Qt.MatchExactly)
        self.assertFalse(not item or item[0] is None)
        self.config_tool.mainWidget.optionsTreeWidget.setCurrentItem(item[0])
        QtTest.QTest.mouseClick(self.config_tool.mainWidget.optionsTreeWidget, Qt.Qt.LeftButton)

        # Recording tab
        self.assertTrue(self.config_tool.currentWidget == self.config_tool.avWidget)

        # Audio Input

        # Checkbox
        for i in range(2):
            #self.config_tool.config.readConfig()
            if self.config_tool.currentWidget.audioGroupBox.isChecked():
                self.assertTrue(self.config_tool.config.enable_audio_recording)
                self.assertTrue(self.config_tool.config.audiomixer == "Audio Passthrough" or
                    self.config_tool.config.audiomixer == "Multiple Audio Inputs")
                self.config_tool.currentWidget.audioGroupBox.setChecked(False)
            else:
                self.assertFalse(self.config_tool.config.enable_audio_recording)
                self.config_tool.currentWidget.audioGroupBox.setChecked(True)

#.........这里部分代码省略.........
开发者ID:FranciscoCanas,项目名称:freeseer,代码行数:103,代码来源:test_config_tool.py

示例11: TestConfig

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestConfig(unittest.TestCase):

    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a PluginManager

        '''
        self.profile_manager = ProfileManager(tempfile.mkdtemp())
        self.profile = self.profile_manager.get('testing')
        self.config = self.profile.get_config('freeseer.conf',
                                              settings.FreeseerConfig,
                                              ['Global'],
                                              read_only=False)

    def tearDown(self):
        '''
        Generic unittest.TestCase.tearDown()
        '''
        shutil.rmtree(self.profile_manager._base_folder)

    def test_save(self):
        '''
        Tests that the config file was created after being saved.
        '''
        filepath = self.profile.get_filepath('freeseer.conf')
        self.config.save()
        self.assertTrue(os.path.exists(filepath))

    def test_schema(self):
        """Tests that the settings Config returns the correct schema based on all its options."""
        settings_schema = {
            'type': 'object',
            'properties': {
                'videodir': {
                    'default': '~/Videos',
                    'type': 'string',
                },
                'auto_hide': {
                    'default': False,
                    'type': 'boolean',
                },
                'enable_audio_recording': {
                    'default': True,
                    'type': 'boolean',
                },
                'enable_video_recording': {
                    'default': True,
                    'type': 'boolean',
                },
                'videomixer': {
                    'default': 'Video Passthrough',
                    'type': 'string',
                },
                'video_quality': {
                    'default': 3,
                    'type': 'integer',
                },
                'audiomixer': {
                    'default': 'Audio Passthrough',
                    'type': 'string',
                },
                'audio_quality': {
                    'default': 3,
                    'type': 'integer',
                },
                'record_to_file': {
                    'default': True,
                    'type': 'boolean',
                },
                'record_to_file_plugin': {
                    'default': 'Ogg Output',
                    'type': 'string',
                },
                'record_to_stream': {
                    'default': False,
                    'type': 'boolean',
                },
                'record_to_stream_plugin': {
                    'default': 'RTMP Streaming',
                    'type': 'string',
                },
                'audio_feedback': {
                    'default': False,
                    'type': 'boolean',
                },
                'video_preview': {
                    'default': True,
                    'type': 'boolean',
                },
                'default_language': {
                    'default': 'tr_en_US.qm',
                    'type': 'string',
                },
            },
        }
        self.assertDictEqual(self.config.schema(), settings_schema)

    def test_schema_validate(self):
#.........这里部分代码省略.........
开发者ID:Blakstar26,项目名称:freeseer,代码行数:103,代码来源:test_config.py

示例12: plugin_manager

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
def plugin_manager(tmpdir):
    """Constructs a plugin manager using a fake profile with a temporary directory."""
    profile_manager = ProfileManager(str(tmpdir))
    profile = profile_manager.get('testing')
    return PluginManager(profile)
开发者ID:benbuckley,项目名称:freeseer,代码行数:7,代码来源:test_plugins.py

示例13: TestUtil

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestUtil(unittest.TestCase):

    def setUp(self):
        self.config_dir = tempfile.mkdtemp()
        self.profile_manager = ProfileManager(os.path.join(self.config_dir, 'profiles'))

    def tearDown(self):
        shutil.rmtree(self.config_dir)

    def test_reset(self):
        """Test Resetting the configuration directory"""
        profile = self.profile_manager.get('default')
        open(profile.get_filepath('freeseer.conf'), 'w+')
        open(profile.get_filepath('plugin.conf'), 'w+')
        open(profile.get_filepath('presentations.db'), 'w+')
        self.assertTrue(os.path.exists(self.config_dir))
        with mock.patch('__builtin__.raw_input', return_value='yes'):
            reset(self.config_dir)
        self.assertFalse(os.path.exists(self.config_dir))

        # recreate the config_dir for tearDown()
        # while we're at it test that passing a none "yes" answer results in directory not removed
        os.makedirs(self.config_dir)
        with mock.patch('__builtin__.raw_input', return_value='no'):
            reset(self.config_dir)
        self.assertTrue(os.path.exists(self.config_dir))

    def test_reset_configuration(self):
        """Test Resetting configuration files"""
        # Test resetting the default profile (no profile arguments passed)
        profile = self.profile_manager.get('default')
        open(profile.get_filepath('freeseer.conf'), 'w+')
        open(profile.get_filepath('plugin.conf'), 'w+')
        self.assertTrue(os.path.exists(profile.get_filepath('plugin.conf')))
        self.assertTrue(os.path.exists(profile.get_filepath('freeseer.conf')))
        reset_configuration(self.config_dir)
        self.assertFalse(os.path.exists(profile.get_filepath('plugin.conf')))
        self.assertFalse(os.path.exists(profile.get_filepath('freeseer.conf')))

        # Test resetting a non-default profile
        profile = self.profile_manager.get('not-default')
        open(profile.get_filepath('freeseer.conf'), 'w+')
        open(profile.get_filepath('plugin.conf'), 'w+')
        self.assertTrue(os.path.exists(profile.get_filepath('plugin.conf')))
        self.assertTrue(os.path.exists(profile.get_filepath('freeseer.conf')))
        reset_configuration(self.config_dir, 'not-default')
        self.assertFalse(os.path.exists(profile.get_filepath('plugin.conf')))
        self.assertFalse(os.path.exists(profile.get_filepath('freeseer.conf')))

    def test_reset_database(self):
        """Test Resetting database file"""
        # Test resetting the default profile (no profile arguments passed)
        profile = self.profile_manager.get('default')
        open(profile.get_filepath('presentations.db'), 'w+')
        self.assertTrue(os.path.exists(profile.get_filepath('presentations.db')))
        reset_database(self.config_dir)
        self.assertFalse(os.path.exists(profile.get_filepath('presentations.db')))

        # Test resetting a non-default profile
        profile = self.profile_manager.get('not-default')
        open(profile.get_filepath('presentations.db'), 'w+')
        self.assertTrue(os.path.exists(profile.get_filepath('presentations.db')))
        reset_database(self.config_dir, 'not-default')
        self.assertFalse(os.path.exists(profile.get_filepath('presentations.db')))
开发者ID:Blakstar26,项目名称:freeseer,代码行数:66,代码来源:test_util.py

示例14: TestPlugins

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestPlugins(unittest.TestCase):

    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a PluginManager

        '''
        self.profile_manager = ProfileManager(tempfile.mkdtemp())
        profile = self.profile_manager.get('testing')
        self.plugman = PluginManager(profile)

    def tearDown(self):
        '''
        Generic unittest.TestCase.tearDown()
        '''
        shutil.rmtree(self.profile_manager._base_folder)

    def test_audio_input_bin(self):
        '''Check that audio input plugins are returning a gst.Bin object

        Verifies that get_audioinput_bin() is returning the proper object.
        '''
        plugins = self.plugman.get_plugins_of_category("AudioInput")

        for plugin in plugins:
            plugin.plugin_object.load_config(self.plugman)
            plugin_bin = plugin.plugin_object.get_audioinput_bin()
            self.assertIsInstance(plugin_bin, gst.Bin,
                "%s did not return a gst.Bin object" % plugin.name)

    def test_audio_mixer_bin(self):
        '''Check that audio mixer plugins are returning a gst.Bin object

        Verifies that get_audioinput_bin() is returning the proper object.
        '''
        plugins = self.plugman.get_plugins_of_category("AudioMixer")

        for plugin in plugins:
            plugin.plugin_object.load_config(self.plugman)
            plugin_bin = plugin.plugin_object.get_audiomixer_bin()
            self.assertIsInstance(plugin_bin, gst.Bin,
                "%s did not return a gst.Bin object" % plugin.name)

    def test_video_input_bin(self):
        '''Check that video input plugins are returning a gst.Bin object

        Verifies that get_videoinput_bin() is returning the proper object.
        '''
        plugins = self.plugman.get_plugins_of_category("VideoInput")

        for plugin in plugins:
            plugin.plugin_object.load_config(self.plugman)
            if plugin.name == "Firewire Source":
                # There is an issue with Firewire Source in testing
                # Skip until this is resolved
                continue

            plugin_bin = plugin.plugin_object.get_videoinput_bin()
            self.assertIsInstance(plugin_bin, gst.Bin,
                "%s did not return a gst.Bin object" % plugin.name)

    def test_video_mixer_bin(self):
        '''Check that video mixer plugins are returning a gst.Bin object

        Verifies that get_videomixer_bin() is returning the proper object.
        '''
        plugins = self.plugman.get_plugins_of_category("VideoMixer")

        for plugin in plugins:
            plugin.plugin_object.load_config(self.plugman)
            plugin_bin = plugin.plugin_object.get_videomixer_bin()
            self.assertIsInstance(plugin_bin, gst.Bin,
                "%s did not return a gst.Bin object" % plugin.name)

    def test_output_bin(self):
        '''Check that output plugins are returning a gst.Bin object

        Verifies that get_output_bin() is returning the proper object.
        '''
        plugins = self.plugman.get_plugins_of_category("Output")

        for plugin in plugins:
            plugin.plugin_object.load_config(self.plugman)
            plugin_bin = plugin.plugin_object.get_output_bin()
            self.assertIsInstance(plugin_bin, gst.Bin,
                "%s did not return a gst.Bin object" % plugin.name)
开发者ID:Noodle1550,项目名称:freeseer,代码行数:90,代码来源:test_plugins.py

示例15: TestServerApp

# 需要导入模块: from freeseer.framework.config.profile import ProfileManager [as 别名]
# 或者: from freeseer.framework.config.profile.ProfileManager import get [as 别名]
class TestServerApp(unittest.TestCase):
    '''
    Test cases for Server.
    '''

    def setUp(self):
        '''
        Stardard init method: runs before each test_* method
        '''
        server.app.config['TESTING'] = True
        server.app.storage_file_path = "test_storage_file"
        self.app = server.app.test_client()
        self.recording = server.app.blueprints['recording']

        # token call to fire configuration logic
        self.app.get('/recordings')
        print self.recording.record_config.videodir

        self.profile_manager = ProfileManager(tempfile.mkdtemp())
        self.temp_video_dir = tempfile.mkdtemp()
        self.recording.record_config.videodir = self.temp_video_dir
        self.recording.record_profile = self.profile_manager.get('testing')
        self.recording.record_config = self.recording.record_profile.get_config('freeseer.conf', settings.FreeseerConfig, ['Global'], read_only=True)
        self.recording.record_plugin_manager = PluginManager(self.recording.record_profile)
        self.recording.media_dict = {}

        # mock media
        self.mock_media_1 = MockMedia()
        self.mock_media_2 = MockMedia()

        self.test_media_dict_1 = {}
        filepath1 = os.path.join(self.recording.record_config.videodir, 'mock_media_1')
        filepath2 = os.path.join(self.recording.record_config.videodir, 'mock_media_1')
        self.test_media_dict_1[1] = {'media': self.mock_media_1, 'filename': 'mock_media_1', 'filepath': filepath1}
        self.test_media_dict_1[2] = {'media': self.mock_media_2, 'filename': 'mock_media_2', 'filepath': filepath2}

    def tearDown(self):
        '''
        Generic unittest.TestCase.tearDown()
        '''
        shutil.rmtree(self.profile_manager._base_folder)
        shutil.rmtree(self.temp_video_dir)
        del self.app

    def test_get_all_recordings_empty_media_dict(self):
        '''
        Tests GET request retrieving all recordings with from an empty media dict
        '''
        response = self.app.get('/recordings')
        response_data = json.loads(response.data)
        self.assertTrue('recordings' in response_data)
        self.assertTrue(response_data['recordings'] == [])

    def test_get_nonexistent_recording_id(self):
        '''
        Tests GET request retrieving non-existent recording
        '''
        response = self.app.get('/recordings/1')
        response_data = json.loads(response.data)
        self.assertEqual(response_data['error_message'], "recording id could not be found")
        self.assertEqual(response_data['error_code'], 404)
        self.assertEqual(response.status_code, 404)

    def test_get_all_recordings(self):
        '''
        Tests GET request all recordings with 2 entries in media dict
        '''
        self.recording.media_dict = self.test_media_dict_1
        response = self.app.get('/recordings')
        response_data = json.loads(response.data)
        self.assertTrue('recordings' in response_data)
        self.assertTrue(response_data['recordings'] == [1, 2])

    def test_get_recording_id(self):
        '''
        Tests GET request specific valid recording
        '''
        self.recording.media_dict = self.test_media_dict_1
        response = self.app.get('/recordings/1')
        response_data = json.loads(response.data)
        self.assertTrue('recordings' not in response_data)
        self.assertTrue('filename' in response_data)
        self.assertTrue('filesize' in response_data)
        self.assertTrue('status' in response_data)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response_data['filename'], 'mock_media_1')
        self.assertEqual(response_data['filesize'], 'NA')
        self.assertEqual(response_data['id'], 1)
        self.assertEqual(response_data['status'], 'NULL')

    def test_get_invalid_recording_id(self):
        '''
        Tests GET request with an invalid id (a non integer id)
        '''
        self.recording.media_dict = self.test_media_dict_1
        response = self.app.get('/recordings/abc')
        self.assertEqual(response.status_code, 404)

        response = self.app.get('/recordings/1.0')
        self.assertEqual(response.status_code, 404)
#.........这里部分代码省略.........
开发者ID:bossjones,项目名称:freeseer,代码行数:103,代码来源:test_server.py


注:本文中的freeseer.framework.config.profile.ProfileManager.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。