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


Python InputFieldF.build方法代码示例

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


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

示例1: test_xy

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_xy(self):
        WGS_X = 10
        WGS_Y = 20
        RD_X = 110
        RD_Y = 120

        breach = FakeObject(
            geom=FakeObject(
                x=WGS_X, y=WGS_Y))

        inputfieldx = InputFieldF.build(
            name='X coordinaat',
            destination_table='Breach',
            destination_field='geom')
        inputfieldy = InputFieldF.build(
            name='Y coordinaat',
            destination_table='Breach',
            destination_field='geom')

        with mock.patch(
            'flooding_lib.coordinates.wgs84_to_rd',
            return_value=(RD_X, RD_Y)):
            retvaluex = models.find_imported_value(
                inputfieldx, {'breach': breach})
            retvaluey = models.find_imported_value(
                inputfieldy, {'breach': breach})
            self.assertEquals(retvaluex, RD_X)
            self.assertEquals(retvaluey, RD_Y)
开发者ID:pombredanne,项目名称:flooding-lib,代码行数:30,代码来源:test_models.py

示例2: test_has_all_required_metadata

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_has_all_required_metadata(self):
        scenario = ScenarioF.create()
        scenariobreach = ScenarioBreachF.create(
            scenario=scenario,
            extwbaselevel=None)

        if1 = InputFieldF.build(
            destination_table='Scenario',
            destination_field='whee',
            required=True)
        if2 = InputFieldF.build(
            destination_table='ScenarioBreach',
            destination_field='extwbaselevel',
            required=True)

        self.assertFalse(scenario.has_values_for((if1,)))
        scenario.whee = "something"
        self.assertTrue(scenario.has_values_for((if1,)))
        self.assertFalse(scenario.has_values_for((if1, if2)))

        scenariobreach.extwbaselevel = 3.0
        scenariobreach.save()

        del scenario._data_objects  # Clear cache

        self.assertTrue(scenario.has_values_for((if1, if2)))
开发者ID:pombredanne,项目名称:flooding-lib,代码行数:28,代码来源:test_models.py

示例3: test_get_integer_from_scenario

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_get_integer_from_scenario(self):
        scenario = FakeObject(field=3)

        inputfield = InputFieldF.build(
            destination_table='Scenario',
            destination_field='field')

        retvalue = models.find_imported_value(
            inputfield, {'scenario': scenario})
        self.assertEquals(retvalue, 3)
开发者ID:pombredanne,项目名称:flooding-lib,代码行数:12,代码来源:test_models.py

示例4: test_skips_empty_cell

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_skips_empty_cell(self, mocked_setvalue):
        """If a cell isn't filled in, skip it."""
        inputfield = InputFieldF.build(destination_table="Scenario", type=InputField.TYPE_INTEGER)
        cell = MockCell(value="")

        header = self.build_header(inputfield)

        eie.import_scenario_row(header, 66, self.rowstart + [cell], self.allowed_ids)

        self.assertFalse(mocked_setvalue.called)
开发者ID:lizardsystem,项目名称:flooding-lib,代码行数:12,代码来源:test_excel_import_export.py

示例5: test_set_value_raises_not_implemented

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_set_value_raises_not_implemented(self):
        """The function supports only a few destination tables, should
        raise NotImplementedError if another table is asked for."""
        scenario = ScenarioF.build()
        inputfield = InputFieldF.build(
            destination_table="Project")

        self.assertRaises(
            NotImplementedError,
            lambda: scenario.set_value_for_inputfield(inputfield, None))
开发者ID:pombredanne,项目名称:flooding-lib,代码行数:12,代码来源:test_models.py

示例6: test_wrong_value_raises_error

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_wrong_value_raises_error(self):
        """A nonsensical value in a cell returns an error message."""
        inputfield = InputFieldF.build(destination_table="scenario", type=InputField.TYPE_INTEGER)
        cell = MockCell(value="whee")

        header = self.build_header(inputfield)

        errors = eie.import_scenario_row(header, 66, self.rowstart + [cell], self.allowed_ids)

        self.assertEquals(len(errors), 1)
        self.assertTrue("66" in errors[0])
开发者ID:lizardsystem,项目名称:flooding-lib,代码行数:13,代码来源:test_excel_import_export.py

示例7: test_skips_ignored_inputfield

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_skips_ignored_inputfield(self, mocked_setvalue):
        """Some destination tables, e.g. Project, can't be modified
        from this import and should be skipped."""
        inputfield = InputFieldF.build(destination_table="Project", type=InputField.TYPE_INTEGER)
        cell = MockCell(value=3)

        header = self.build_header(inputfield)

        eie.import_scenario_row(header, 66, self.rowstart + [cell], self.allowed_ids)

        self.assertFalse(mocked_setvalue.called)
开发者ID:lizardsystem,项目名称:flooding-lib,代码行数:13,代码来源:test_excel_import_export.py

示例8: test_false_at_incorrect_options

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_false_at_incorrect_options(self):
        inputfield = InputFieldF.build(
            type=InputField.TYPE_SELECT,
            options="not a dictionary at all!")

        header = {
            'fieldtype': 'Select',
            'inputfield': inputfield
            }

        self.assertFalse(eie.write_domeinlijst(None, 0, header))
开发者ID:pombredanne,项目名称:flooding-lib,代码行数:13,代码来源:test_excel_import_export.py

示例9: test_a_string_isnt_a_dict

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_a_string_isnt_a_dict(self):
        inputfield = InputFieldF.build(
            type=InputField.TYPE_SELECT,
            options=repr("not a dictionary at all!"))

        header = {
            'fieldtype': 'Select',
            'inputfield': inputfield
            }

        self.assertFalse(eie.write_domeinlijst(None, 0, header))
开发者ID:pombredanne,项目名称:flooding-lib,代码行数:13,代码来源:test_excel_import_export.py

示例10: test_one_inputfield_one_code

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_one_inputfield_one_code(self):
        worksheet = mock.MagicMock()

        inputfield = InputFieldF.build(type=InputField.TYPE_SELECT, options=repr({1: "first line"}))

        header = {"fieldtype": "Select", "inputfield": inputfield, "fieldname": "Test"}

        self.assertTrue(eie.write_domeinlijst(worksheet, 0, header))

        expected = [mock.call(0, 0, "Code"), mock.call(0, 1, "Test"), mock.call(1, 0, 1), mock.call(1, 1, "first line")]

        self.assertEquals(worksheet.write.call_args_list, expected)
开发者ID:lizardsystem,项目名称:flooding-lib,代码行数:14,代码来源:test_excel_import_export.py

示例11: test_rest_calls_value_for_inputfield

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_rest_calls_value_for_inputfield(self):
        field_value = 3
        inputfield = InputFieldF.build(type=InputField.TYPE_INTEGER)

        with mock.patch("flooding_lib.models.Scenario.value_for_inputfield", return_value=field_value) as patched:
            headers = ({}, {"inputfield": inputfield})
            scenariorow = eie.ScenarioRow(ScenarioF.build(), headers)

            columns = scenariorow.columns()
            columns.next()  # Skip scenario id
            self.assertEquals(columns.next().value, field_value)
            patched.assert_called_with(inputfield)
开发者ID:lizardsystem,项目名称:flooding-lib,代码行数:14,代码来源:test_excel_import_export.py

示例12: test_headers_from_inputfields

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_headers_from_inputfields(self):
        """Test that it uses the headers from
        grouped_input_fields()."""
        inputfield = InputFieldF.build(name="testfield")
        grouped_input_fields = [{"id": 1, "title": "testheader", "fields": [inputfield]}]

        with mock.patch(
            "flooding_lib.tools.importtool.models.InputField.grouped_input_fields", return_value=grouped_input_fields
        ):
            fieldinfo = eie.FieldInfo([])
            headers = list(fieldinfo.headers_from_inputfields())

            self.assertEquals(len(headers), 1)
            self.assertEquals(headers[0]["headername"], "testheader")
            self.assertEquals(headers[0]["inputfield"], inputfield)
开发者ID:lizardsystem,项目名称:flooding-lib,代码行数:17,代码来源:test_excel_import_export.py

示例13: test_some_inputfield

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_some_inputfield(self, mocked_setvalue):
        """Test with an integer inputfield and see what happens."""

        inputfield = InputFieldF.build(destination_table="scenario", type=InputField.TYPE_INTEGER)
        cell = MockCell(value=3)

        header = self.build_header(inputfield)

        eie.import_scenario_row(header, 66, self.rowstart + [cell], self.allowed_ids)

        self.assertTrue(mocked_setvalue.called)
        c_inputfield, c_value = mocked_setvalue.call_args[0]

        self.assertTrue(c_inputfield is inputfield)
        self.assertTrue(isinstance(c_value, IntegerValue))
开发者ID:lizardsystem,项目名称:flooding-lib,代码行数:17,代码来源:test_excel_import_export.py

示例14: test_set_value_for_inputfield_sets_extrascenarioinfo

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_set_value_for_inputfield_sets_extrascenarioinfo(self):
        """See if an inputfield using ExtraScenarioInfo is set."""
        scenario = ScenarioF.create()
        ExtraInfoFieldF.create(name="test")
        inputfield = InputFieldF.build(
            destination_table='ExtraScenarioInfo',
            destination_field='test',
            type=importmodels.InputField.TYPE_FLOAT)

        value_object = inputfield.build_value_object()
        value_object.set(0.5)

        scenario.set_value_for_inputfield(inputfield, value_object)

        # Was it saved?
        esi = models.ExtraScenarioInfo.get(scenario, 'test')
        self.assertEquals(esi.value, u'0.5')
开发者ID:pombredanne,项目名称:flooding-lib,代码行数:19,代码来源:test_models.py

示例15: test_headers_from_inputfields

# 需要导入模块: from flooding_lib.tools.importtool.test_models import InputFieldF [as 别名]
# 或者: from flooding_lib.tools.importtool.test_models.InputFieldF import build [as 别名]
    def test_headers_from_inputfields(self):
        """Test that it uses the headers from
        grouped_input_fields()."""
        inputfield = InputFieldF.build(name="testfield")
        grouped_input_fields = [{
                'id': 1, 'title': 'testheader', 'fields': [
                    inputfield]}]

        with mock.patch(
        'flooding_lib.tools.importtool.models.InputField.grouped_input_fields',
            return_value=grouped_input_fields):
            fieldinfo = eie.FieldInfo([])
            headers = list(fieldinfo.headers_from_inputfields())

            self.assertEquals(len(headers), 1)
            self.assertEquals(headers[0]['headername'], 'testheader')
            self.assertEquals(headers[0]['inputfield'], inputfield)
开发者ID:pombredanne,项目名称:flooding-lib,代码行数:19,代码来源:test_excel_import_export.py


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