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


Python test_models.InputFieldF类代码示例

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


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

示例1: test_has_all_required_metadata

    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,代码行数:26,代码来源:test_models.py

示例2: test_xy

    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,代码行数:28,代码来源:test_models.py

示例3: test_exception_if_occurs_twice

    def test_exception_if_occurs_twice(self):
        name = "dit is een input field"
        InputFieldF.create(name=name)
        header = eie.ImportedHeader()

        header.find_field_by_name(1, name)

        self.assertRaises(eie.ImportedHeader.HeaderException, lambda: header.find_field_by_name(2, name))
开发者ID:lizardsystem,项目名称:flooding-lib,代码行数:8,代码来源:test_excel_import_export.py

示例4: test_getitem

    def test_getitem(self):
        name = u"dit is een input field"
        InputFieldF.create(name=name)
        header = eie.ImportedHeader()

        foundfield = header.find_field_by_name(1, name)

        self.assertTrue(header[1] is foundfield)
开发者ID:pombredanne,项目名称:flooding-lib,代码行数:8,代码来源:test_excel_import_export.py

示例5: setUp

    def setUp(self):
        # Lots of setup

        InputFieldF.create(name="Scenario Identificatie")

        self.approvalobjecttype = testapprovalmodels.ApprovalObjectTypeF()
        self.approvalrule = approvalmodels.ApprovalRule.objects.create(name="some rule", description="some description")
        self.approvalobjecttype.approvalrule.add(self.approvalrule)

        self.project = ProjectF.create(approval_object_type=self.approvalobjecttype)
        self.scenario = ScenarioF.create(name="scenario name")
        self.scenario.set_project(self.project)
开发者ID:lizardsystem,项目名称:flooding-lib,代码行数:12,代码来源:test_excel_import_export.py

示例6: test_can_iterate

    def test_can_iterate(self):
        name = u"dit is een input field"
        field = InputFieldF.create(name=name)
        header = eie.ImportedHeader()

        header.find_field_by_name(1, name)

        for i, iterfield in enumerate(header):
            self.assertEquals(i, 0)  # We should only come here once
            self.assertEquals(field, iterfield)
开发者ID:pombredanne,项目名称:flooding-lib,代码行数:10,代码来源:test_excel_import_export.py

示例7: test_get_integer_from_scenario

    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,代码行数:10,代码来源:test_models.py

示例8: test_skips_empty_cell

    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,代码行数:10,代码来源:test_excel_import_export.py

示例9: test_set_value_raises_not_implemented

    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,代码行数:10,代码来源:test_models.py

示例10: test_a_string_isnt_a_dict

    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,代码行数:11,代码来源:test_excel_import_export.py

示例11: test_false_at_incorrect_options

    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,代码行数:11,代码来源:test_excel_import_export.py

示例12: test_wrong_value_raises_error

    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,代码行数:11,代码来源:test_excel_import_export.py

示例13: test_skips_ignored_inputfield

    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,代码行数:11,代码来源:test_excel_import_export.py

示例14: test_finds_field

    def test_finds_field(self):
        name = u"dit is een input field"
        field = InputFieldF.create(name=name)

        fields = {}
        header = eie.ImportedHeader(fields)

        foundfield = header.find_field_by_name(1, name)

        self.assertEquals(field, foundfield)
        self.assertTrue(fields[1] is foundfield)
开发者ID:pombredanne,项目名称:flooding-lib,代码行数:11,代码来源:test_excel_import_export.py

示例15: test_rest_calls_value_for_inputfield

    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,代码行数:12,代码来源:test_excel_import_export.py


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