def runTest(self):
        """Test set_text and get_text"""
        from_text = Project()
        source_text = '\n'.join(self.TEST_TEXT)
        from_text.set_text(source_text)
        project_sources = from_text.sources

        assert Section.match_omit(project_sources.get_text(), source_text,
                                  " \t-;\n")

        assert project_sources.value[0].id == "JUNCTION-9090"
        assert project_sources.value[0].source_type == SourceType.CONCEN
        assert project_sources.value[0].baseline_strength == "8330"
        assert project_sources.value[0].pattern_id == "Pattern-A"

        assert project_sources.value[1].id == "JUNCTION-9091"
        assert project_sources.value[1].source_type == SourceType.MASS
        assert project_sources.value[1].baseline_strength == "8331"
        assert project_sources.value[1].pattern_id == "Pattern-B"

        assert project_sources.value[2].id == "JUNCTION-9092"
        assert project_sources.value[2].source_type == SourceType.FLOWPACED
        assert project_sources.value[2].baseline_strength == "8332"
        assert project_sources.value[2].pattern_id == "Pattern-C"

        assert project_sources.value[3].id == "JUNCTION-9093"
        assert project_sources.value[3].source_type == SourceType.SETPOINT
        assert project_sources.value[3].baseline_strength == "8333"
        assert project_sources.value[3].pattern_id == "Pattern-D"

        assert project_sources.value[4].id == "JUNCTION-9094"
        assert project_sources.value[4].source_type == SourceType.CONCEN
        assert project_sources.value[4].baseline_strength == "8334"
        assert project_sources.value[4].pattern_id == ""
Esempio n. 2
0
    def test_curves(self):
        """Test Curves section"""
        self.my_curve = curves.Curve()
        self.my_curve = curves.Curve()
        self.my_curve.curve_id = "XXX"
        self.my_curve.description = "test curve"
        self.my_curve.curve_type = curves.CurveType.HEADLOSS
        self.my_curve.curve_xy = ((1500, 250), (1400, 200))

        assert self.my_curve.curve_id == "XXX"
        assert self.my_curve.description == "test curve"
        assert self.my_curve.get_text().split() == [
            ';HEADLOSS:', 'test', 'curve', 'XXX', '1500', '250', 'XXX', '1400',
            '200'
        ], "incorrect pattern block"

        # Create new project with new text
        test_text = ("[CURVES]", ";ID\tX-Value\tY-Value",
                     ";--\t-------\t-------", ";PUMP: Pump Curve for Pump 9",
                     " 1\t1500\t250\t")
        from_text = Project()
        from_text.set_text('\n'.join(test_text))
        project_curves = from_text.curves
        assert Section.match_omit(project_curves.get_text(),
                                  '\n'.join(test_text), " -;\t\n")

        assert len(project_curves.value) == 1
        this_curve = project_curves.value[0]
        assert this_curve.curve_id == '1'
        assert this_curve.description == "Pump Curve for Pump 9"
        assert this_curve.curve_type == curves.CurveType.PUMP
        assert this_curve.curve_xy == [("1500", "250")]
    def runTest(self):
        """Test set_text and get_text"""
        from_text = Project()
        source_text = '\n'.join(self.TEST_TEXT)
        from_text.set_text(source_text)
        project_sources = from_text.sources

        assert Section.match_omit(project_sources.get_text(), source_text, " \t-;\n")

        assert project_sources.value[0].id == "JUNCTION-9090"
        assert project_sources.value[0].source_type == SourceType.CONCEN
        assert project_sources.value[0].baseline_strength == "8330"
        assert project_sources.value[0].pattern_id == "Pattern-A"

        assert project_sources.value[1].id == "JUNCTION-9091"
        assert project_sources.value[1].source_type == SourceType.MASS
        assert project_sources.value[1].baseline_strength == "8331"
        assert project_sources.value[1].pattern_id == "Pattern-B"

        assert project_sources.value[2].id == "JUNCTION-9092"
        assert project_sources.value[2].source_type == SourceType.FLOWPACED
        assert project_sources.value[2].baseline_strength == "8332"
        assert project_sources.value[2].pattern_id == "Pattern-C"

        assert project_sources.value[3].id == "JUNCTION-9093"
        assert project_sources.value[3].source_type == SourceType.SETPOINT
        assert project_sources.value[3].baseline_strength == "8333"
        assert project_sources.value[3].pattern_id == "Pattern-D"

        assert project_sources.value[4].id == "JUNCTION-9094"
        assert project_sources.value[4].source_type == SourceType.CONCEN
        assert project_sources.value[4].baseline_strength == "8334"
        assert project_sources.value[4].pattern_id == ""
    def test_curves(self):
        """Test Curves section"""
        self.my_curve = curves.Curve()
        self.my_curve = curves.Curve()
        self.my_curve.curve_id = "XXX"
        self.my_curve.description = "test curve"
        self.my_curve.curve_type = curves.CurveType.HEADLOSS
        self.my_curve.curve_xy = ((1500, 250), (1400, 200))

        assert self.my_curve.curve_id == "XXX"
        assert self.my_curve.description == "test curve"
        assert self.my_curve.get_text().split() == [';HEADLOSS:', 'test', 'curve',
                                                    'XXX', '1500', '250', 'XXX', '1400', '200'], "incorrect pattern block"

        # Create new project with new text
        test_text = ("[CURVES]",
                     ";ID\tX-Value\tY-Value",
                     ";--\t-------\t-------",
                     ";PUMP: Pump Curve for Pump 9",
                     " 1\t1500\t250\t")
        from_text = Project()
        from_text.set_text('\n'.join(test_text))
        project_curves = from_text.curves
        assert Section.match_omit(project_curves.get_text(), '\n'.join(test_text), " -;\t\n")

        assert len(project_curves.value) == 1
        this_curve = project_curves.value[0]
        assert this_curve.curve_id == '1'
        assert this_curve.description == "Pump Curve for Pump 9"
        assert this_curve.curve_type == curves.CurveType.PUMP
        assert this_curve.curve_xy == [("1500", "250")]
    def test_patterns(self):
        """Test one Pattern section"""
        self.my_pattern = patterns.Pattern()
        self.my_pattern.description = "test pattern"
        self.my_pattern.pattern_id = "XXX"
        self.my_pattern.multipliers = ("1.0", "1.1", "1.2", "1.3")

        assert self.my_pattern.pattern_id == "XXX"
        assert self.my_pattern.description == "test pattern"
        assert self.my_pattern.get_text().split() == [";test", "pattern", "XXX", "1.0", "1.1", "1.2", "1.3"], "get_text"

        # Create new Project with this section populated from TEST_TEXT
        test_text = ("[PATTERNS]",
                     ";ID\tMultipliers",
                     ";Demand Pattern",
                     " 1\t1.0\t1.2\t1.4\t1.6\t1.4\t1.2",
                     " 1\t1.0\t0.8\t0.6\t0.4\t0.6\t0.8",
                     " 2\t2.0\t2.2\t2.4\t2.6\t2.4\t2.2",
                     " 2\t2.0\t2.8\t2.6\t2.4\t2.6\t2.8")

        from_text = Project()
        from_text.set_text('\n'.join(test_text))
        pattern_list = from_text.patterns.value
        assert len(pattern_list) == 2
        assert int(pattern_list[0].pattern_id) == 1
        assert int(pattern_list[1].pattern_id) == 2

        assert float(pattern_list[0].multipliers[0]) == 1.0
        assert float(pattern_list[0].multipliers[1]) == 1.2
        assert float(pattern_list[0].multipliers[2]) == 1.4
        assert float(pattern_list[0].multipliers[3]) == 1.6
        assert float(pattern_list[0].multipliers[4]) == 1.4
        assert float(pattern_list[0].multipliers[5]) == 1.2

        assert float(pattern_list[0].multipliers[6]) == 1.0
        assert float(pattern_list[0].multipliers[7]) == 0.8
        assert float(pattern_list[0].multipliers[8]) == 0.6
        assert float(pattern_list[0].multipliers[9]) == 0.4
        assert float(pattern_list[0].multipliers[10]) == 0.6
        assert float(pattern_list[0].multipliers[11]) == 0.8

        assert float(pattern_list[1].multipliers[0]) == 2.0
        assert float(pattern_list[1].multipliers[1]) == 2.2
        assert float(pattern_list[1].multipliers[2]) == 2.4
        assert float(pattern_list[1].multipliers[3]) == 2.6
        assert float(pattern_list[1].multipliers[4]) == 2.4
        assert float(pattern_list[1].multipliers[5]) == 2.2

        assert float(pattern_list[1].multipliers[6]) == 2.0
        assert float(pattern_list[1].multipliers[7]) == 2.8
        assert float(pattern_list[1].multipliers[8]) == 2.6
        assert float(pattern_list[1].multipliers[9]) == 2.4
        assert float(pattern_list[1].multipliers[10]) == 2.6
        assert float(pattern_list[1].multipliers[11]) == 2.8
    def runTest(self):
        """Test set_text and get_text of demand options"""
        from_text = Project()
        source_text = '\n'.join(self.TEST_TEXT)
        from_text.set_text(source_text)
        project_demands = from_text.demands

        assert Section.match_omit(project_demands.get_text(), source_text, " \t-;\n")

        assert project_demands.value[0].junction_id == "JUNCTION-0"
        assert project_demands.value[0].base_demand == "0.0"
        assert project_demands.value[0].demand_pattern == "PATTERN-1"
        assert project_demands.value[0].category == ''

        assert project_demands.value[1].junction_id == "JUNCTION-1"
        assert project_demands.value[1].base_demand == "0.1"
        assert project_demands.value[1].demand_pattern == "PATTERN-2"
        assert project_demands.value[1].category == ''

        assert project_demands.value[2].junction_id == "JUNCTION-12"
        assert project_demands.value[2].base_demand == "0.2"
        assert project_demands.value[2].demand_pattern == "PATTERN-12"
        assert project_demands.value[2].category == "Category-12"
    def runTest(self):
        """Test set_text and get_text of demand options"""
        from_text = Project()
        source_text = '\n'.join(self.TEST_TEXT)
        from_text.set_text(source_text)
        project_demands = from_text.demands

        assert Section.match_omit(project_demands.get_text(), source_text,
                                  " \t-;\n")

        assert project_demands.value[0].junction_id == "JUNCTION-0"
        assert project_demands.value[0].base_demand == "0.0"
        assert project_demands.value[0].demand_pattern == "PATTERN-1"
        assert project_demands.value[0].category == ''

        assert project_demands.value[1].junction_id == "JUNCTION-1"
        assert project_demands.value[1].base_demand == "0.1"
        assert project_demands.value[1].demand_pattern == "PATTERN-2"
        assert project_demands.value[1].category == ''

        assert project_demands.value[2].junction_id == "JUNCTION-12"
        assert project_demands.value[2].base_demand == "0.2"
        assert project_demands.value[2].demand_pattern == "PATTERN-12"
        assert project_demands.value[2].category == "Category-12"