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


Python MagicMock.settingsdict方法代码示例

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


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

示例1: test_get_stored_settings_parameter_browser

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import settingsdict [as 别名]
 def test_get_stored_settings_parameter_browser():
     mock_ms = MagicMock()
     mock_ms.settingsdict = {'fieldlogger_export_parameter_browser': '((0, ("input_field_group_list", ("p1.u1;input;hint", "np2.u2;input2;hint2"), ), ), )'}
     settingskey = 'fieldlogger_export_parameter_browser'
     stored_settings = create_test_string(utils.get_stored_settings(mock_ms, settingskey))
     reference_string = '((0, (input_field_group_list, (p1.u1;input;hint, np2.u2;input2;hint2))))'
     assert stored_settings == reference_string
开发者ID:jkall,项目名称:qgis-midvatten-plugin,代码行数:9,代码来源:test_export_fieldlogger.py

示例2: test_get_stored_settings

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import settingsdict [as 别名]
 def test_get_stored_settings():
     mock_ms = MagicMock()
     mock_ms.settingsdict = {"test_settings_key": '((0, ("final_parameter_name", "testname"), ("test", "gotten_test")), (1, ("key1", "value1"), ("key2", "value2"), ("key3", "value3")))'}
     settingskey = 'test_settings_key'
     stored_settings = create_test_string(utils.get_stored_settings(mock_ms, settingskey))
     reference_string = '((0, (final_parameter_name, testname), (test, gotten_test)), (1, (key1, value1), (key2, value2), (key3, value3)))'
     assert stored_settings == reference_string
开发者ID:jkall,项目名称:qgis-midvatten-plugin,代码行数:9,代码来源:test_export_fieldlogger.py

示例3: _test_wlvllogg_import_from_diveroffice_files

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import settingsdict [as 别名]
                    def _test_wlvllogg_import_from_diveroffice_files(self, filenames, mock_filenames, mock_skippopup, mock_encoding, mock_iface, mock_askuser, mock_notfoundquestion, mock_messagebarandlog):

                        mocks_notfoundquestion = []
                        for answer, value in [['ok', 'rb1'],
                                              ['ok', 'rb2'],
                                              ['skip', 'rb3']]:
                            a_mock = MagicMock()
                            a_mock.answer = answer
                            a_mock.value = value
                            a_mock.reuse_column = 'location'
                            mocks_notfoundquestion.append(a_mock)

                        mock_notfoundquestion.side_effect = mocks_notfoundquestion

                        mock_filenames.return_value = filenames
                        mock_encoding.return_value = ['utf-8']

                        ms = MagicMock()
                        ms.settingsdict = OrderedDict()
                        importer = DiverofficeImport(self.iface.mainWindow(), ms)
                        importer.select_files_and_load_gui()

                        importer.start_import(importer.files, importer.skip_rows.checked, importer.confirm_names.checked, importer.import_all_data.checked)

                        print('\n'.join([str(x) for x in mock_messagebarandlog.mock_calls]))
开发者ID:jkall,项目名称:qgis-midvatten-plugin,代码行数:27,代码来源:test_import_diveroffice_spatialite.py

示例4: test_get_stored_settings_parameter_browser_real_parameter_name

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import settingsdict [as 别名]
 def test_get_stored_settings_parameter_browser_real_parameter_name():
     mock_ms = MagicMock()
     mock_ms.settingsdict = {"fieldlogger_pbrowser": '[(0, ("input_field_group_list", ["Aveflow.m3/s;numberDecimal|numberSigned;measure flow", "Accflow.m3;numberDecimal|numberSigned;measure flow"]))]'}
     settingskey = 'fieldlogger_pbrowser'
     test_string = create_test_string(utils.get_stored_settings(mock_ms, settingskey))
     reference_string = '[(0, (input_field_group_list, [Aveflow.m3/s;numberDecimal|numberSigned;measure flow, Accflow.m3;numberDecimal|numberSigned;measure flow]))]'
     assert test_string == reference_string
开发者ID:jkall,项目名称:qgis-midvatten-plugin,代码行数:9,代码来源:test_export_fieldlogger.py

示例5: test_save_stored_settings_real_parameter_name

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import settingsdict [as 别名]
    def test_save_stored_settings_real_parameter_name():
        mock_ms = MagicMock()
        mock_ms.settingsdict = {}
        stored_settings = [(0, (('input_field_group_list', ['Aveflow.m3/s;numberDecimal|numberSigned;measure flow', 'Accflow.m3;numberDecimal|numberSigned;measure flow']), ('key0_2', 'value0_2'))),
                           (1, (('location_suffix', 'value1_1'), ('key1_2', 'value1_2')))]
        testkey = 'fieldlogger_pgroups'
        utils.save_stored_settings(mock_ms, stored_settings, testkey)

        teststring = create_test_string(mock_ms.settingsdict[testkey])
        reference_string = '[(0, (("input_field_group_list", ["Aveflow.m3/s;numberDecimal|numberSigned;measure flow", "Accflow.m3;numberDecimal|numberSigned;measure flow"], ), ("key0_2", "value0_2", ), ), ), (1, (("location_suffix", "value1_1", ), ("key1_2", "value1_2", ), ), )]'
        assert teststring == reference_string
开发者ID:jkall,项目名称:qgis-midvatten-plugin,代码行数:13,代码来源:test_export_fieldlogger.py

示例6: test_save_stored_settings

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import settingsdict [as 别名]
    def test_save_stored_settings():
        mock_ms = MagicMock()
        mock_ms.settingsdict = {}
        stored_settings = [(0, (('input_field_group_list', ['p1.u1;it1:h1', 'p2.u2;it2:h2']), ('key0_2', 'value0_2'))),
                           (1, (('location_suffix', 'value1_1'), ('key1_2', 'value1_2')))]
        testkey = 'thekey'
        utils.save_stored_settings(mock_ms, stored_settings, testkey)

        teststring = mock_ms.settingsdict[testkey]
        reference_string = '[(0, (("input_field_group_list", ["p1.u1;it1:h1", "p2.u2;it2:h2"], ), ("key0_2", "value0_2", ), ), ), (1, (("location_suffix", "value1_1", ), ("key1_2", "value1_2", ), ), )]'
        assert teststring == reference_string
开发者ID:jkall,项目名称:qgis-midvatten-plugin,代码行数:13,代码来源:test_export_fieldlogger.py

示例7: test_create_parameter_groups_using_stored_settings_string

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import settingsdict [as 别名]
    def test_create_parameter_groups_using_stored_settings_string(self, mock_iface, mock_tables_columns, mock_settingsstrings, mock_settingsbarandlog, mock_popup):
        mock_tables_columns.return_value = {}
        mock_ms = MagicMock()
        mock_ms.settingsdict = {'fieldlogger_export_pbrowser': '',
                                'fieldlogger_export_pgroups': ''}
        mock_settingsstrings.side_effect = [('[[0, (("input_field_list", ["DO.mg/L;numberDecimal|numberSigned; ", "comment;text;Obsid related comment"], ), )]]', True),
                                            ('[[0, (("input_field_group_list", ["DO.mg/L;numberDecimal|numberSigned; ", "comment;text;Obsid related comment"], ), ("location_suffix", "2766", ), ("sublocation_suffix", "level", ), )], [1, (("input_field_group_list", ["comment;text;Obsid related comment"], ), ("location_suffix", "1234", ), ("sublocation_suffix", "comment", ), )]]', True)]

        exportfieldlogger = ExportToFieldLogger(None, mock_ms)

        exportfieldlogger.settings_strings_dialogs()

        assert mock_ms.settingsdict['fieldlogger_export_pbrowser'] == '[[0, (("input_field_list", ["DO.mg/L;numberDecimal|numberSigned; ", "comment;text;Obsid related comment"], ), )]]'
        assert mock_ms.settingsdict['fieldlogger_export_pgroups'] == '[[0, (("input_field_group_list", ["DO.mg/L;numberDecimal|numberSigned; ", "comment;text;Obsid related comment"], ), ("location_suffix", "2766", ), ("sublocation_suffix", "level", ), )], [1, (("input_field_group_list", ["comment;text;Obsid related comment"], ), ("location_suffix", "1234", ), ("sublocation_suffix", "comment", ), )]]'
开发者ID:jkall,项目名称:qgis-midvatten-plugin,代码行数:16,代码来源:test_export_fieldlogger.py

示例8: test_calculate_statistics

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import settingsdict [as 别名]
    def test_calculate_statistics(self, mock_selected_features, mock_iface, mock_messagebar):
        dbconnection = db_utils.DbConnectionManager()
        db_utils.sql_alter_db("""INSERT INTO obs_points(obsid) VALUES('1')""")
        db_utils.sql_alter_db("""INSERT INTO obs_points(obsid) VALUES('2')""")
        db_utils.sql_alter_db("""INSERT INTO w_levels(obsid, date_time, meas) VALUES('1', '2017-01-01', '1')""")
        db_utils.sql_alter_db("""INSERT INTO w_levels(obsid, date_time, meas) VALUES('1', '2017-01-02', '3')""")
        db_utils.sql_alter_db("""INSERT INTO w_levels(obsid, date_time, meas) VALUES('1', '2017-01-03', '5')""")
        db_utils.sql_alter_db("""INSERT INTO w_levels(obsid, date_time, meas) VALUES('2', '2017-01-04', '2')""")
        db_utils.sql_alter_db("""INSERT INTO w_levels(obsid, date_time, meas) VALUES('2', '2017-01-05', '8')""")
        db_utils.sql_alter_db("""INSERT INTO w_levels(obsid, date_time, meas) VALUES('2', '2017-01-06', '9')""")
        db_utils.sql_alter_db("""INSERT INTO w_levels(obsid, date_time, meas) VALUES('2', '2017-01-07', '10')""")

        mock_selected_features.return_value = ['1', '2']
        ms = MagicMock()
        ms.settingsdict = OrderedDict()

        calc_stats = calculate_statistics.CalculateStatisticsGui(self.iface.mainWindow(), ms)
        calc_stats.db_browser.table_list = 'w_levels'
        calc_stats.db_browser.column_list = 'meas'
        calc_stats.calculate()
        ref = call.info(bar_msg='Statistics for table w_levels column meas done, see log for results.', button=True, duration=15, log_msg='Obsid;Min;Median;Average;Max;Nr of values\n1;1.0;3.0;3.0;5.0;3\n2;2.0;8.5;7.25;10.0;4')
        print(str(mock_messagebar.mock_calls))
        assert ref in mock_messagebar.mock_calls
开发者ID:jkall,项目名称:qgis-midvatten-plugin,代码行数:25,代码来源:test_calculate_statistics_postgis.py


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