Esempio n. 1
0
 def test_empty(self):
     """Empty section (has section name)"""
     self.my_title = Title()
     test_text = "[TITLE]\n"
     self.my_title.set_text(test_text)
     actual_text = self.my_title.get_text()  # display purpose
     assert self.my_title.matches(test_text)
Esempio n. 2
0
 def test_one_row(self):
     """One-row title with carriage return"""
     self.my_title = Title()
     test_text = "[TITLE]\n" \
                 "test_title\n"
     self.my_title.set_text(test_text)
     actual_text = self.my_title.get_text()  # display purpose
     assert self.my_title.matches(test_text)
Esempio n. 3
0
 def test_bare(self):
     """Bare section"""
     self.my_title = Title()
     default_text = self.my_title.get_text()
     test_text = ""
     self.my_title.set_text(test_text)
     actual_text = self.my_title.get_text()
     # assert actual_text == test_text
     assert actual_text == default_text
Esempio n. 4
0
 def test_rt_before_title(self):
     """Carriage return before section title"""
     # The first row can not be \n
     self.my_title = Title()
     test_text = "\n"\
                 "[TITLE]\n"\
                 "test_title"
     self.my_title.set_text(test_text)
     actual_text = self.my_title.get_text()  # display purpose
     assert self.my_title.matches(test_text)
Esempio n. 5
0
 def test_multi_row(self):
     """Multiple-row title include empty lines"""
     self.my_title = Title()
     test_text = "[TITLE]\n" \
                 "       \n" \
                 "test_title\n" \
                 "    "
     self.my_title.set_text(test_text)
     actual_text = self.my_title.get_text()  # display purpose
     assert self.my_title.matches(test_text)
Esempio n. 6
0
 def read(new_text):
     """Read properties from text.
         Args:
             new_text (str): Text to parse into properties.
     """
     title = Title()
     lines = new_text.replace(title.SECTION_NAME, '').strip().splitlines()
     if len(lines) > 0:
         title.title = lines[0]
     if len(lines) > 1:
         title.notes = '\n'.join(lines[1:])
     return title
    def __init__(self):
        """Initialize the sections of an EPANET input file.
           Any sections not initialized here will be handled by the generic core.project_base.Section class."""
        self.title = Title()
        self.junctions = SectionAsList("[JUNCTIONS]")  # (list of Junction)
        self.reservoirs = SectionAsList("[RESERVOIRS]")  # (list of Reservoir)
        self.tanks = SectionAsList("[TANKS]")  # (list of Tank)
        self.pipes = SectionAsList("[PIPES]")  # (list of Pipe)
        self.pumps = SectionAsList("[PUMPS]")  # (list of Pump)
        self.valves = SectionAsList("[VALVES]")  # (list of Valve)
        # self.emitters = [(Junction, "emitter_coefficient")]
        self.patterns = SectionAsList("[PATTERNS]")  # (list of Pattern)
        self.curves = SectionAsList("[CURVES]")  # (list of Curve)
        self.energy = EnergyOptions()
        self.status = SectionAsList("[STATUS]")  # (list of Status)
        self.controls = Control()
        self.rules = Rule()
        self.demands = SectionAsList("[DEMANDS]")  # (list of Demand)
        self.reactions = Reactions()
        self.sources = SectionAsList("[SOURCES]")  # (list of Source)
        # self.options = MapOptions,
        self.options = Options()
        self.times = TimesOptions()
        self.report = ReportOptions()
        self.labels = SectionAsList("[LABELS]")  # (list of Label)
        self.backdrop = BackdropOptions()
        self.calibrations = SectionAsList(
            "[CALIBRATIONS]")  # (list of Calibration)

        ProjectBase.__init__(
            self
        )  # Do this after setting attributes so they will all get added to sections[]
 def test_empty(self):
     """Empty section (has section name)"""
     self.my_title = Title()
     test_text = "[TITLE]\n"
     self.my_title.set_text(test_text)
     actual_text = self.my_title.get_text()  # display purpose
     assert self.my_title.matches(test_text)
 def test_one_row(self):
     """One-row title with carriage return"""
     self.my_title = Title()
     test_text = "[TITLE]\n" \
                 "test_title\n"
     self.my_title.set_text(test_text)
     actual_text = self.my_title.get_text()  # display purpose
     assert self.my_title.matches(test_text)
 def test_bare(self):
     """Bare section"""
     self.my_title = Title()
     default_text = self.my_title.get_text()
     test_text = ""
     self.my_title.set_text(test_text)
     actual_text = self.my_title.get_text()
     # assert actual_text == test_text
     assert actual_text == default_text
 def test_rt_before_title(self):
     """Carriage return before section title"""
     # The first row can not be \n
     self.my_title = Title()
     test_text = "\n"\
                 "[TITLE]\n"\
                 "test_title"
     self.my_title.set_text(test_text)
     actual_text = self.my_title.get_text()  # display purpose
     assert self.my_title.matches(test_text)
 def test_multi_row(self):
     """Multiple-row title include empty lines"""
     self.my_title = Title()
     test_text = "[TITLE]\n" \
                 "       \n" \
                 "test_title\n" \
                 "    "
     self.my_title.set_text(test_text)
     actual_text = self.my_title.get_text()  # display purpose
     assert self.my_title.matches(test_text)
Esempio n. 13
0
    def test_bare(self):
        """Bare section"""
        test_text = "[TITLE]"
        my_title = Title()
        # default_text = self.my_title.get_text()
        default_text = TitleWriter.as_text(my_title)
        msg = '\nSet:' + test_text + '\nGet:' + default_text
        self.assertTrue(match(default_text, test_text), msg)

        my_title = TitleReader.read(test_text)
        actual_text = TitleWriter.as_text(my_title)
        # assert actual_text == test_text
        msg = '\nSet:' + test_text + '\nGet:' + actual_text
        self.assertTrue(match(actual_text, test_text), msg)
Esempio n. 14
0
    def __init__(self):
        """Initialize the sections of an EPANET input file.
           Any sections not initialized here will be handled by the generic core.project_base.Section class."""
        ProjectBase.__init__(self)

        self.title = Title()
        self.backdrop = BackdropOptions()       # BACKDROP      bounding rectangle and file name of backdrop image
        self.map = MapOptions()                 # MAP           map's bounding rectangle and units
        self.junctions = SectionAsList("[JUNCTIONS]")  # (list of Junction)
        self.reservoirs = SectionAsList("[RESERVOIRS]")  # (list of Reservoir)
        self.tanks = SectionAsList("[TANKS]")  # (list of Tank)
        self.pipes = SectionAsList("[PIPES]")  # (list of Pipe)
        self.pumps = SectionAsList("[PUMPS]")  # (list of Pump)
        self.valves = SectionAsList("[VALVES]")  # (list of Valve)
        # self.emitters = [(Junction, "emitter_coefficient")]
        self.patterns = SectionAsList("[PATTERNS]")  # (list of Pattern)
        self.curves = SectionAsList("[CURVES]")  # (list of Curve)
        self.energy = EnergyOptions()
        self.status = SectionAsList("[STATUS]")  # (list of Status)
        self.controls = Control()
        self.rules = Rule()
        self.demands = SectionAsList("[DEMANDS]")  # (list of Demand)
        self.reactions = Reactions()
        self.sources = SectionAsList("[SOURCES]")  # (list of Source)
        # self.options = MapOptions,
        self.options = Options()
        self.times = TimesOptions()
        self.report = ReportOptions()
        self.labels = SectionAsList("[LABELS]")  # (list of Label)
        self.backdrop = BackdropOptions()
        self.calibrations = SectionAsList("[CALIBRATIONS]") # (list of Calibration)

        self.sections = [
            self.title,
            self.options,
            self.report,
            self.junctions,
            self.tanks,
            self.reservoirs,
            self.pipes,
            self.pumps,
            self.valves,
            self.controls,
            self.patterns,
            self.curves,
            self.backdrop,
            self.map,
            self.labels]  # Start with a sensible order of sections.
        self.add_sections_from_attributes()  # Add any sections not added in the line above, should not be any left.
Esempio n. 15
0
class SimpleTitleTest(unittest.TestCase):
    """Test Title section"""
    def setUp(self):
        """Set up test"""

    def test_bare(self):
        """Bare section"""
        self.my_title = Title()
        default_text = self.my_title.get_text()
        test_text = ""
        self.my_title.set_text(test_text)
        actual_text = self.my_title.get_text()
        # assert actual_text == test_text
        assert actual_text == default_text
        # assert self.my_title.matches(test_text)

    def test_empty(self):
        """Empty section (has section name)"""
        self.my_title = Title()
        test_text = "[TITLE]\n"
        self.my_title.set_text(test_text)
        actual_text = self.my_title.get_text()  # display purpose
        assert self.my_title.matches(test_text)

    def test_one_row(self):
        """One-row title with carriage return"""
        self.my_title = Title()
        test_text = "[TITLE]\n" \
                    "test_title\n"
        self.my_title.set_text(test_text)
        actual_text = self.my_title.get_text()  # display purpose
        assert self.my_title.matches(test_text)

    def test_multi_row(self):
        """Multiple-row title include empty lines"""
        self.my_title = Title()
        test_text = "[TITLE]\n" \
                    "       \n" \
                    "test_title\n" \
                    "    "
        self.my_title.set_text(test_text)
        actual_text = self.my_title.get_text()  # display purpose
        assert self.my_title.matches(test_text)

    def test_rt_before_title(self):
        """Carriage return before section title"""
        # The first row can not be \n
        self.my_title = Title()
        test_text = "\n"\
                    "[TITLE]\n"\
                    "test_title"
        self.my_title.set_text(test_text)
        actual_text = self.my_title.get_text()  # display purpose
        assert self.my_title.matches(test_text)
class SimpleTitleTest(unittest.TestCase):
    """Test Title section"""

    def setUp(self):
        """Set up test"""

    def test_bare(self):
        """Bare section"""
        self.my_title = Title()
        default_text = self.my_title.get_text()
        test_text = ""
        self.my_title.set_text(test_text)
        actual_text = self.my_title.get_text()
        # assert actual_text == test_text
        assert actual_text == default_text
        # assert self.my_title.matches(test_text)

    def test_empty(self):
        """Empty section (has section name)"""
        self.my_title = Title()
        test_text = "[TITLE]\n"
        self.my_title.set_text(test_text)
        actual_text = self.my_title.get_text()  # display purpose
        assert self.my_title.matches(test_text)

    def test_one_row(self):
        """One-row title with carriage return"""
        self.my_title = Title()
        test_text = "[TITLE]\n" \
                    "test_title\n"
        self.my_title.set_text(test_text)
        actual_text = self.my_title.get_text()  # display purpose
        assert self.my_title.matches(test_text)

    def test_multi_row(self):
        """Multiple-row title include empty lines"""
        self.my_title = Title()
        test_text = "[TITLE]\n" \
                    "       \n" \
                    "test_title\n" \
                    "    "
        self.my_title.set_text(test_text)
        actual_text = self.my_title.get_text()  # display purpose
        assert self.my_title.matches(test_text)

    def test_rt_before_title(self):
        """Carriage return before section title"""
        # The first row can not be \n
        self.my_title = Title()
        test_text = "\n"\
                    "[TITLE]\n"\
                    "test_title"
        self.my_title.set_text(test_text)
        actual_text = self.my_title.get_text()  # display purpose
        assert self.my_title.matches(test_text)