def test_default(self):
     """Test default, default is empty string, no adjustments"""
     self.my_options = Temperature()
     name = self.my_options.SECTION_NAME
     assert name == "[TEMPERATURE]"
     actual_text = self.my_options.get_text()
     assert actual_text == ''
 def test_snowmelt_wo_adc(self):
     """Test snowmelt -- Remove both ADCs"""
     test_snowmelt = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES daily_temperature.txt
     WINDSPEED FILE
     SNOWMELT 2 0.5 0.6 0.0 50 0
     """
     self.my_options = Temperature()
     self.my_options.set_text(test_snowmelt)
     actual_text = self.my_options.get_text()  # display purpose
     self.assertTrue(self.my_options.matches(test_snowmelt))
 def test_snowmelt_wo_temperature(self):
     """Test snowmelt -- without temperature"""
     # -- I do no think daily temperature has to be provided for this
     # --Once temperature is defined this passes
     test_snowmelt = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     SNOWMELT 2 0.5 0.6 0.0 50 0
     """
     self.my_options = Temperature()
     self.my_options.set_text(test_snowmelt)
     actual_text = self.my_options.get_text()  # display purpose
     self.assertFalse(self.my_options.matches(test_snowmelt))
 def test_file_wt_date(self):
     """Test daily temperature in tepmerature.txt(file name with space) and start date"""
     # Will failed if SNOW_MELT not given
     test_file = "[TEMPERATURE]\n" \
                 " ;;Parameter  Fname (Start)\n" \
                 " FILE daily temperature 1-1-1999.txt 2/2/2012\n"\
                 " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                 " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                 " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     self.my_options = Temperature()
     self.my_options.set_text(test_file)
     actual_text = self.my_options.get_text()  # display purpose
     assert self.my_options.matches(test_file)
 def test_file(self):
     """Test daily temperature in file daily_temperature.txt"""
     # Will failed if SNOW_MELT not given
     test_file = "[TEMPERATURE]\n" \
                 " ;;Parameter  Fname (Start)\n" \
                 " FILE daily_tmperature.txt\n" \
                 " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                 " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                 " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     self.my_options = Temperature()
     self.my_options.set_text(test_file)
     actual_text = self.my_options.get_text()  # display purpose
     self.assertTrue(self.my_options.matches(test_file),
                     'Failed because SNOW_MELT default values are written')
 def test_timeseries(self):
     """Test daily temperature in time series
      Must have SNOW_MELT, otherwise will fail
      because SNOW_MELT default values are written """
     test_time_series = "[TEMPERATURE]\n" \
                        " ;;Parameter  TSeries\n" \
                        " TIMESERIES TS1\n" \
                        " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                        " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                        " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     self.my_options = Temperature()
     self.my_options.set_text(test_time_series)
     actual_text = self.my_options.get_text()  # display purpose
     assert self.my_options.matches(test_time_series)
 def test_snowmelt_fail(self):
     """Test snowmelt wo one ADC PERVIOUS, assert failed
       Should both be specified. It should allow two or none"""
     test_snowmelt = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES daily_temperature.txt
     WINDSPEED FILE
     SNOWMELT 2 0.5 0.6 0.0 50 0
     ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
     """
     self.my_options = Temperature()
     self.my_options.set_text(test_snowmelt)
     actual_text = self.my_options.get_text()  # display purpose
     self.assertFalse(self.my_options.matches(test_snowmelt))
 def test_windspeed_file_wt_temperature(self):
     """Test windspeed file wt temperature"""
     # --Will fail if snow_melt not provided, same issue as above
     # --Will fail if temperature not defined
     test_windspeed_file = "[TEMPERATURE]\n" \
                           ";;Parameter  Monthly Adjustments\n" \
                           "FILE daily_tmperature.txt\n" \
                           "WINDSPEED FILE\n"\
                           " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                           " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                           " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     self.my_options = Temperature()
     self.my_options.set_text(test_windspeed_file)
     actual_text = self.my_options.get_text()  # display purpose
     assert self.my_options.matches(test_windspeed_file)
 def test_windspeed_file_fail(self):
     """Test windspeed file - 2"""
     # -- This should report fail because Windspeed file should be the same climate file used for air temperature
     # -- in this case the air temperature is not provided as file
     # --Once temperature is defined this passes
     test_windspeed_file = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES TS1
     WINDSPEED FILE
     """
     self.my_options = Temperature()
     self.my_options.set_text(test_windspeed_file)
     actual_text = self.my_options.get_text()  # display purpose
     self.assertFalse(self.my_options.matches(test_windspeed_file),
                      "Should fail")
 def test_snowmelt(self):
     """Test snowmelt"""
     # --Once temperature is defined this passes
     test_snowmelt = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES daily_temperature.txt
     WINDSPEED FILE
     SNOWMELT 2 0.5 0.6 0.0 50 0
     ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
     ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
     """
     self.my_options = Temperature()
     self.my_options.set_text(test_snowmelt)
     actual_text = self.my_options.get_text()  # display purpose
     assert self.my_options.matches(test_snowmelt)
 def test_default(self):
     """Test default, default is empty string, no adjustments"""
     self.my_options = Temperature()
     name = self.my_options.SECTION_NAME
     assert name == "[TEMPERATURE]"
     actual_text = self.my_options.get_text()
     assert actual_text == ''
 def test_windspeed_monthly(self):
     """Test WindSpeed monthly"""
     # --Will fail if snow_melt not provided, same issue as above
     # --Will fail because get_text created empty string if only WINDSPEED
     # Note: WINDSPEED must be provided along with temperature for evaporation calculation
     test_windspeed_monthly = "[TEMPERATURE]\n" \
                              " ;;Parameter  Monthly Adjustments\n" \
                              " FILE daily temperature 1-1-1999.txt 2/2/2012\n" \
                              " WINDSPEED MONTHLY   1.0    1.0    3.0    2.0    2.0" \
                              "    2.0    2.0    2.0    2.0    2.0    1.0    0.0\n"\
                              " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                              " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                              " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     self.my_options = Temperature()
     self.my_options.set_text(test_windspeed_monthly)
     actual_text = self.my_options.get_text()  # display purpose
     assert self.my_options.matches(test_windspeed_monthly)
 def test_snowmelt_wo_adc(self):
     """Test snowmelt -- Remove both ADCs"""
     test_snowmelt = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES daily_temperature.txt
     WINDSPEED FILE
     SNOWMELT 2 0.5 0.6 0.0 50 0
     """
     self.my_options = Temperature()
     self.my_options.set_text(test_snowmelt)
     actual_text = self.my_options.get_text() # display purpose
     self.assertTrue(self.my_options.matches(test_snowmelt))
 def test_file_wt_date(self):
     """Test daily temperature in tepmerature.txt(file name with space) and start date"""
     # Will failed if SNOW_MELT not given
     test_file = "[TEMPERATURE]\n" \
                 " ;;Parameter  Fname (Start)\n" \
                 " FILE daily temperature 1-1-1999.txt 2/2/2012\n"\
                 " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                 " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                 " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     self.my_options = Temperature()
     self.my_options.set_text(test_file)
     actual_text = self.my_options.get_text() # display purpose
     assert self.my_options.matches(test_file)
 def test_snowmelt_wo_temperature(self):
     """Test snowmelt -- without temperature"""
     # -- I do no think daily temperature has to be provided for this
     # --Once temperature is defined this passes
     test_snowmelt = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     SNOWMELT 2 0.5 0.6 0.0 50 0
     """
     self.my_options = Temperature()
     self.my_options.set_text(test_snowmelt)
     actual_text = self.my_options.get_text() # display purpose
     self.assertFalse(self.my_options.matches(test_snowmelt))
 def test_timeseries(self):
     """Test daily temperature in time series
      Must have SNOW_MELT, otherwise will fail
      because SNOW_MELT default values are written """
     test_time_series = "[TEMPERATURE]\n" \
                        " ;;Parameter  TSeries\n" \
                        " TIMESERIES TS1\n" \
                        " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                        " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                        " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     self.my_options = Temperature()
     self.my_options.set_text(test_time_series)
     actual_text = self.my_options.get_text() # display purpose
     assert self.my_options.matches(test_time_series)
 def test_file(self):
     """Test daily temperature in file daily_temperature.txt"""
     # Will failed if SNOW_MELT not given
     test_file = "[TEMPERATURE]\n" \
                 " ;;Parameter  Fname (Start)\n" \
                 " FILE daily_tmperature.txt\n" \
                 " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                 " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                 " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     self.my_options = Temperature()
     self.my_options.set_text(test_file)
     actual_text = self.my_options.get_text() # display purpose
     self.assertTrue(self.my_options.matches(test_file),
                     'Failed because SNOW_MELT default values are written')
 def test_snowmelt_fail(self):
     """Test snowmelt wo one ADC PERVIOUS, assert failed
       Should both be specified. It should allow two or none"""
     test_snowmelt = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES daily_temperature.txt
     WINDSPEED FILE
     SNOWMELT 2 0.5 0.6 0.0 50 0
     ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
     """
     self.my_options = Temperature()
     self.my_options.set_text(test_snowmelt)
     actual_text = self.my_options.get_text() # display purpose
     self.assertFalse(self.my_options.matches(test_snowmelt))
 def test_windspeed_file_wt_temperature(self):
     """Test windspeed file wt temperature"""
     # --Will fail if snow_melt not provided, same issue as above
     # --Will fail if temperature not defined
     test_windspeed_file = "[TEMPERATURE]\n" \
                           ";;Parameter  Monthly Adjustments\n" \
                           "FILE daily_tmperature.txt\n" \
                           "WINDSPEED FILE\n"\
                           " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                           " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                           " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     self.my_options = Temperature()
     self.my_options.set_text(test_windspeed_file)
     actual_text = self.my_options.get_text() # display purpose
     assert self.my_options.matches(test_windspeed_file)
 def test_windspeed_file_fail(self):
     """Test windspeed file - 2"""
     # -- This should report fail because Windspeed file should be the same climate file used for air temperature
     # -- in this case the air temperature is not provided as file
     # --Once temperature is defined this passes
     test_windspeed_file = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES TS1
     WINDSPEED FILE
     """
     self.my_options = Temperature()
     self.my_options.set_text(test_windspeed_file)
     actual_text = self.my_options.get_text() # display purpose
     self.assertFalse(self.my_options.matches(test_windspeed_file),"Should fail")
 def test_snowmelt(self):
     """Test snowmelt"""
     # --Once temperature is defined this passes
     test_snowmelt = r"""
     [TEMPERATURE]
     ;;Parameter  TimeSeries
     TIMESERIES daily_temperature.txt
     WINDSPEED FILE
     SNOWMELT 2 0.5 0.6 0.0 50 0
     ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
     ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
     """
     self.my_options = Temperature()
     self.my_options.set_text(test_snowmelt)
     actual_text = self.my_options.get_text() # display purpose
     assert self.my_options.matches(test_snowmelt)
 def test_windspeed_monthly(self):
     """Test WindSpeed monthly"""
     # --Will fail if snow_melt not provided, same issue as above
     # --Will fail because get_text created empty string if only WINDSPEED
     # Note: WINDSPEED must be provided along with temperature for evaporation calculation
     test_windspeed_monthly = "[TEMPERATURE]\n" \
                              " ;;Parameter  Monthly Adjustments\n" \
                              " FILE daily temperature 1-1-1999.txt 2/2/2012\n" \
                              " WINDSPEED MONTHLY   1.0    1.0    3.0    2.0    2.0" \
                              "    2.0    2.0    2.0    2.0    2.0    1.0    0.0\n"\
                              " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                              " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                              " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
     self.my_options = Temperature()
     self.my_options.set_text(test_windspeed_monthly)
     actual_text = self.my_options.get_text() # display purpose
     assert self.my_options.matches(test_windspeed_monthly)
    def __init__(self):
        """Define the fields of a SWMM Project by creating an empty placeholder for each section"""

        self.title = Title()  # TITLE         project title
        self.options = General()  # OPTIONS       analysis options
        self.report = Report()  # REPORT        output reporting instructions
        self.files = Files()  # FILES         interface file options
        self.backdrop = BackdropOptions(
        )  # BACKDROP      bounding rectangle and file name of backdrop image
        self.map = MapOptions(
        )  # MAP           map's bounding rectangle and units
        # self.raingages = [RainGage]             # RAINGAGES     rain gage information
        self.hydrographs = SectionAsListGroupByID(
            "[HYDROGRAPHS]", UnitHydrograph,
            ";;Hydrograph    \tRain Gage/Month \tResponse\tR       \tT       \tK       \tDmax    \tDrecov  \tDinit   \n"
            ";;--------------\t----------------\t--------\t--------\t--------\t--------\t--------\t--------\t--------"
        )
        # unit hydrograph data used to construct RDII inflows

        self.evaporation = Evaporation()  # EVAPORATION   evaporation data
        self.temperature = Temperature(
        )  # TEMPERATURE   air temperature and snow melt data
        self.adjustments = Adjustments(
        )  # ADJUSTMENTS   monthly climate adjustments
        self.subcatchments = SectionAsListOf(
            "[SUBCATCHMENTS]", Subcatchment,
            ";;Name          \tRain Gage       \tOutlet          \tArea    \t%Imperv \tWidth   \t%Slope  \tCurbLen \tSnowPack        \n"
            ";;--------------\t----------------\t----------------\t--------\t--------\t--------\t--------\t--------\t----------------"
        )
        # basic subcatchment information

        # self.subareas = [Section]               # SUBAREAS      subcatchment impervious/pervious sub-area data

        self.infiltration = SectionAsListOf("[INFILTRATION]", basestring)
        # This is set to SectionAsListOf HortonInfiltration or GreenAmptInfiltration or CurveNumberInfiltration on read
        # subcatchment infiltration parameters

        self.lid_controls = SectionAsListGroupByID(
            "[LID_CONTROLS]", LIDControl,
            ";;Name          \tType/Layer\tParameters\n"
            ";;--------------\t----------\t----------")
        # low impact development control information

        self.lid_usage = SectionAsListOf(
            "[LID_USAGE]", LIDUsage,
            ";;Subcatchment  \tLID Process     \tNumber \tArea      \tWidth     \tInitSat   \tFromImp   \tToPerv    \tRptFile                 \tDrainTo\n"
            ";;--------------\t----------------\t-------\t----------\t----------\t----------\t----------\t----------\t------------------------\t----------------"
        )
        # assignment of LID controls to subcatchments

        self.aquifers = SectionAsListOf(
            "[AQUIFERS]", Aquifer,
            ";;Aquifer       \tPhi   \tWP    \tFC    \tHydCon\tKslope\tTslope\tUEF   \tLED   \tLGLR  \tBEL   \tWTEL  \tUZM   \tUEF Pat\n"
            ";;--------------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t-------"
        )
        # groundwater aquifer parameters

        self.groundwater = SectionAsListOf(
            "[GROUNDWATER]", Groundwater,
            ";;Subcatchment  \tAquifer         \tNode            \tEsurf \tA1    \tB1    \tA2    \tB2    \tA3    \tDsw   \tEgwt  \tEbot  \tWgr   \tUmc   \n"
            ";;--------------\t----------------\t----------------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t------\t------"
        )
        # subcatchment groundwater parameters

        self.snowpacks = SectionAsListGroupByID(
            "[SNOWPACKS]", SnowPack,
            ";;Name          \tSurface   \tParameters\n"
            ";;--------------\t----------\t----------")
        # subcatchment snow pack parameters

        self.junctions = SectionAsListOf(
            "[JUNCTIONS]", Junction,
            ";;Name          \tElevation \tMaxDepth  \tInitDepth \tSurDepth  \tAponded\n"
            ";;--------------\t----------\t----------\t----------\t----------\t----------"
        )
        # junction node information

        # self.outfalls = [Outfall] # OUTFALLS # outfall node information
        # self.dividers = [Divider] # DIVIDERS # flow divider node information
        # self.storage = [StorageUnit] # STORAGE # storage node information

        self.conduits = SectionAsListOf(
            "[CONDUITS]", Conduit,
            ";;Name          \tFrom Node       \tTo Node         \tLength    \tRoughness \tInOffset  \tOutOffset \tInitFlow  \tMaxFlow   \n"
            ";;--------------\t----------------\t----------------\t----------\t----------\t----------\t----------\t----------\t----------"
        )
        # conduit link information

        self.pumps = SectionAsListOf(
            "[PUMPS]", Pump,
            ";;Name          \tFrom Node       \tTo Node         \tPump Curve      \tStatus  \tStartup \tShutoff \n"
            ";;--------------\t----------------\t----------------\t----------------\t--------\t--------\t--------"
        )
        # pump link information

        # self.orifices = [Orifice] # ORIFICES # orifice link information
        # self.weirs = [Weir] # WEIRS # weir link information
        # self.outlets = [Outlet] # OUTLETS # outlet link information

        self.xsections = SectionAsListOf(
            "[XSECTIONS]", CrossSection,
            ";;Link          \tShape       \tGeom1           \tGeom2     \tGeom3     \tGeom4     \tBarrels   \tCulvert   \n"
            ";;--------------\t------------\t----------------\t----------\t----------\t----------\t----------\t----------"
        )
        # conduit, orifice, and weir cross-section geometry

        self.transects = Transects(
        )  # TRANSECTS # transect geometry for conduits with irregular cross-sections
        # self.losses = [Section] # LOSSES # conduit entrance/exit losses and flap valves
        self.controls = SectionAsListOf(
            "[CONTROLS]",
            basestring)  # rules that control pump and regulator operation
        self.landuses = SectionAsListOf(
            "[LANDUSES]", Landuse,
            ";;              \tSweeping  \tFraction  \tLast\n"
            ";;Name          \tInterval  \tAvailable \tSwept\n"
            ";;--------------\t----------\t----------\t----------")
        # land use categories

        self.buildup = SectionAsListOf(
            "[BUILDUP]", Buildup,
            ";;Land Use      \tPollutant       \tFunction  \tCoeff1    \tCoeff2    \tCoeff3    \tPer Unit\n"
            ";;--------------\t----------------\t----------\t----------\t----------\t----------\t----------"
        )
        # buildup functions for pollutants and land uses

        self.washoff = SectionAsListOf(
            "[WASHOFF]", Washoff,
            ";;Land Use      \tPollutant       \tFunction  \tCoeff1    \tCoeff2    \tSweepRmvl \tBmpRmvl\n"
            ";;--------------\t----------------\t----------\t----------\t----------\t----------\t----------"
        )
        # washoff functions for pollutants and land uses

        self.pollutants = SectionAsListOf(
            "[POLLUTANTS]", Pollutant,
            ";;Name          \tUnits \tCrain     \tCgw       \tCrdii     \tKdecay    \tSnowOnly  \tCo-Pollutant    \tCo-Frac   \tCdwf      \tCinit\n"
            ";;--------------\t------\t----------\t----------\t----------\t----------\t----------\t----------------\t----------\t----------\t----------"
        )
        # pollutant information

        self.coverages = Coverages(
        )  # COVERAGES # assignment of land uses to subcatchments
        self.treatment = SectionAsListOf(
            "[TREATMENT]", Treatment,
            ";;Node          \tPollutant       \tFunction\n"
            ";;--------------\t----------------\t--------")

        # pollutant removal functions at conveyance system nodes

        self.inflows = SectionAsListOf(
            "[INFLOWS]", DirectInflow,
            ";;Node          \tConstituent     \tTime Series     \tType    \tMfactor \tSfactor \tBaseline\tPattern\n"
            ";;--------------\t----------------\t----------------\t--------\t--------\t--------\t--------\t--------"
        )
        # INFLOWS # external hydrograph/pollutograph inflow at nodes

        self.dwf = SectionAsListOf(
            "[DWF]", DryWeatherInflow,
            ";;Node          \tConstituent     \tBaseline  \tPatterns  \n"
            ";;--------------\t----------------\t----------\t----------")
        # baseline dry weather sanitary inflow at nodes

        self.patterns = SectionAsListGroupByID(
            "[PATTERNS]", Pattern,
            ";;Name          \tType      \tMultipliers\n"
            ";;--------------\t----------\t-----------")
        # PATTERNS      periodic variation in dry weather inflow

        self.rdii = SectionAsListOf(
            "[RDII]", RDIInflow,
            ";;Node          \tUnit Hydrograph \tSewer Area\n"
            ";;--------------\t----------------\t----------")
        # rainfall-dependent I/I information at nodes

        self.loadings = SectionAsListOf(
            "[LOADINGS]", InitialLoading,
            ";;Subcatchment  \tPollutant       \tBuildup\n"
            ";;--------------\t----------------\t----------")
        # initial pollutant loads on subcatchments

        self.curves = SectionAsListGroupByID(
            "[CURVES]", Curve,
            ";;Name          \tType      \tX-Value   \tY-Value   \n"
            ";;--------------\t----------\t----------\t----------")
        # CURVES        x-y tabular data referenced in other sections

        self.timeseries = SectionAsListGroupByID(
            "[TIMESERIES]", TimeSeries,
            ";;Name          \tDate      \tTime      \tValue\n"
            ";;--------------\t----------\t----------\t----------")
        # time series data referenced in other sections

        # self.polygons = [Section] # POLYGONS # X,Y coordinates for each vertex of subcatchment polygons
        # self.coordinates = [Section] # COORDINATES # X,Y coordinates for nodes
        # self.vertices = [Section] # VERTICES # X,Y coordinates for each interior vertex of polyline links
        # self.labels = [Section] # LABELS # X,Y coordinates and text of labels
        # self.symbols = [Section] # SYMBOLS # X,Y coordinates for rain gages
        #  X,Y coordinates of the bounding rectangle and file name of the backdrop image.
        # [TAGS]
        InputFile.__init__(
            self
        )  # Do this after setting attributes so they will all get added to sections[]
class TemperatureTest(unittest.TestCase):  # TODO: go over the tests
    """Test TEMPERATURE section"""

    def test_default(self):
        """Test default, default is empty string, no adjustments"""
        self.my_options = Temperature()
        name = self.my_options.SECTION_NAME
        assert name == "[TEMPERATURE]"
        actual_text = self.my_options.get_text()
        assert actual_text == ''

    def test_timeseries(self):
        """Test daily temperature in time series
         Must have SNOW_MELT, otherwise will fail
         because SNOW_MELT default values are written """
        test_time_series = "[TEMPERATURE]\n" \
                           " ;;Parameter  TSeries\n" \
                           " TIMESERIES TS1\n" \
                           " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                           " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                           " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
        self.my_options = Temperature()
        self.my_options.set_text(test_time_series)
        actual_text = self.my_options.get_text() # display purpose
        assert self.my_options.matches(test_time_series)

    def test_file(self):
        """Test daily temperature in file daily_temperature.txt"""
        # Will failed if SNOW_MELT not given
        test_file = "[TEMPERATURE]\n" \
                    " ;;Parameter  Fname (Start)\n" \
                    " FILE daily_tmperature.txt\n" \
                    " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                    " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                    " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
        self.my_options = Temperature()
        self.my_options.set_text(test_file)
        actual_text = self.my_options.get_text() # display purpose
        self.assertTrue(self.my_options.matches(test_file),
                        'Failed because SNOW_MELT default values are written')

    def test_file_wt_date(self):
        """Test daily temperature in tepmerature.txt(file name with space) and start date"""
        # Will failed if SNOW_MELT not given
        test_file = "[TEMPERATURE]\n" \
                    " ;;Parameter  Fname (Start)\n" \
                    " FILE daily temperature 1-1-1999.txt 2/2/2012\n"\
                    " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                    " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                    " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
        self.my_options = Temperature()
        self.my_options.set_text(test_file)
        actual_text = self.my_options.get_text() # display purpose
        assert self.my_options.matches(test_file)

    def test_windspeed_monthly(self):
        """Test WindSpeed monthly"""
        # --Will fail if snow_melt not provided, same issue as above
        # --Will fail because get_text created empty string if only WINDSPEED
        # Note: WINDSPEED must be provided along with temperature for evaporation calculation
        test_windspeed_monthly = "[TEMPERATURE]\n" \
                                 " ;;Parameter  Monthly Adjustments\n" \
                                 " FILE daily temperature 1-1-1999.txt 2/2/2012\n" \
                                 " WINDSPEED MONTHLY   1.0    1.0    3.0    2.0    2.0" \
                                 "    2.0    2.0    2.0    2.0    2.0    1.0    0.0\n"\
                                 " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                                 " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                                 " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
        self.my_options = Temperature()
        self.my_options.set_text(test_windspeed_monthly)
        actual_text = self.my_options.get_text() # display purpose
        assert self.my_options.matches(test_windspeed_monthly)

    def test_windspeed_file_wt_temperature(self):
        """Test windspeed file wt temperature"""
        # --Will fail if snow_melt not provided, same issue as above
        # --Will fail if temperature not defined
        test_windspeed_file = "[TEMPERATURE]\n" \
                              ";;Parameter  Monthly Adjustments\n" \
                              "FILE daily_tmperature.txt\n" \
                              "WINDSPEED FILE\n"\
                              " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                              " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                              " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
        self.my_options = Temperature()
        self.my_options.set_text(test_windspeed_file)
        actual_text = self.my_options.get_text() # display purpose
        assert self.my_options.matches(test_windspeed_file)

    def test_windspeed_file_fail(self):
        """Test windspeed file - 2"""
        # -- This should report fail because Windspeed file should be the same climate file used for air temperature
        # -- in this case the air temperature is not provided as file
        # --Once temperature is defined this passes
        test_windspeed_file = r"""
        [TEMPERATURE]
        ;;Parameter  TimeSeries
        TIMESERIES TS1
        WINDSPEED FILE
        """
        self.my_options = Temperature()
        self.my_options.set_text(test_windspeed_file)
        actual_text = self.my_options.get_text() # display purpose
        self.assertFalse(self.my_options.matches(test_windspeed_file),"Should fail")

    def test_snowmelt(self):
        """Test snowmelt"""
        # --Once temperature is defined this passes
        test_snowmelt = r"""
        [TEMPERATURE]
        ;;Parameter  TimeSeries
        TIMESERIES daily_temperature.txt
        WINDSPEED FILE
        SNOWMELT 2 0.5 0.6 0.0 50 0
        ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
        ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
        """
        self.my_options = Temperature()
        self.my_options.set_text(test_snowmelt)
        actual_text = self.my_options.get_text() # display purpose
        assert self.my_options.matches(test_snowmelt)

    def test_snowmelt_fail(self):
        """Test snowmelt wo one ADC PERVIOUS, assert failed
          Should both be specified. It should allow two or none"""
        test_snowmelt = r"""
        [TEMPERATURE]
        ;;Parameter  TimeSeries
        TIMESERIES daily_temperature.txt
        WINDSPEED FILE
        SNOWMELT 2 0.5 0.6 0.0 50 0
        ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
        """
        self.my_options = Temperature()
        self.my_options.set_text(test_snowmelt)
        actual_text = self.my_options.get_text() # display purpose
        self.assertFalse(self.my_options.matches(test_snowmelt))

    def test_snowmelt_wo_adc(self):
        """Test snowmelt -- Remove both ADCs"""
        test_snowmelt = r"""
        [TEMPERATURE]
        ;;Parameter  TimeSeries
        TIMESERIES daily_temperature.txt
        WINDSPEED FILE
        SNOWMELT 2 0.5 0.6 0.0 50 0
        """
        self.my_options = Temperature()
        self.my_options.set_text(test_snowmelt)
        actual_text = self.my_options.get_text() # display purpose
        self.assertTrue(self.my_options.matches(test_snowmelt))

    def test_snowmelt_wo_temperature(self):
        """Test snowmelt -- without temperature"""
        # -- I do no think daily temperature has to be provided for this
        # --Once temperature is defined this passes
        test_snowmelt = r"""
        [TEMPERATURE]
        ;;Parameter  TimeSeries
        SNOWMELT 2 0.5 0.6 0.0 50 0
        """
        self.my_options = Temperature()
        self.my_options.set_text(test_snowmelt)
        actual_text = self.my_options.get_text() # display purpose
        self.assertFalse(self.my_options.matches(test_snowmelt))
class TemperatureTest(unittest.TestCase):  # TODO: go over the tests
    """Test TEMPERATURE section"""
    def test_default(self):
        """Test default, default is empty string, no adjustments"""
        self.my_options = Temperature()
        name = self.my_options.SECTION_NAME
        assert name == "[TEMPERATURE]"
        actual_text = self.my_options.get_text()
        assert actual_text == ''

    def test_timeseries(self):
        """Test daily temperature in time series
         Must have SNOW_MELT, otherwise will fail
         because SNOW_MELT default values are written """
        test_time_series = "[TEMPERATURE]\n" \
                           " ;;Parameter  TSeries\n" \
                           " TIMESERIES TS1\n" \
                           " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                           " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                           " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
        self.my_options = Temperature()
        self.my_options.set_text(test_time_series)
        actual_text = self.my_options.get_text()  # display purpose
        assert self.my_options.matches(test_time_series)

    def test_file(self):
        """Test daily temperature in file daily_temperature.txt"""
        # Will failed if SNOW_MELT not given
        test_file = "[TEMPERATURE]\n" \
                    " ;;Parameter  Fname (Start)\n" \
                    " FILE daily_tmperature.txt\n" \
                    " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                    " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                    " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
        self.my_options = Temperature()
        self.my_options.set_text(test_file)
        actual_text = self.my_options.get_text()  # display purpose
        self.assertTrue(self.my_options.matches(test_file),
                        'Failed because SNOW_MELT default values are written')

    def test_file_wt_date(self):
        """Test daily temperature in tepmerature.txt(file name with space) and start date"""
        # Will failed if SNOW_MELT not given
        test_file = "[TEMPERATURE]\n" \
                    " ;;Parameter  Fname (Start)\n" \
                    " FILE daily temperature 1-1-1999.txt 2/2/2012\n"\
                    " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                    " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                    " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
        self.my_options = Temperature()
        self.my_options.set_text(test_file)
        actual_text = self.my_options.get_text()  # display purpose
        assert self.my_options.matches(test_file)

    def test_windspeed_monthly(self):
        """Test WindSpeed monthly"""
        # --Will fail if snow_melt not provided, same issue as above
        # --Will fail because get_text created empty string if only WINDSPEED
        # Note: WINDSPEED must be provided along with temperature for evaporation calculation
        test_windspeed_monthly = "[TEMPERATURE]\n" \
                                 " ;;Parameter  Monthly Adjustments\n" \
                                 " FILE daily temperature 1-1-1999.txt 2/2/2012\n" \
                                 " WINDSPEED MONTHLY   1.0    1.0    3.0    2.0    2.0" \
                                 "    2.0    2.0    2.0    2.0    2.0    1.0    0.0\n"\
                                 " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                                 " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                                 " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
        self.my_options = Temperature()
        self.my_options.set_text(test_windspeed_monthly)
        actual_text = self.my_options.get_text()  # display purpose
        assert self.my_options.matches(test_windspeed_monthly)

    def test_windspeed_file_wt_temperature(self):
        """Test windspeed file wt temperature"""
        # --Will fail if snow_melt not provided, same issue as above
        # --Will fail if temperature not defined
        test_windspeed_file = "[TEMPERATURE]\n" \
                              ";;Parameter  Monthly Adjustments\n" \
                              "FILE daily_tmperature.txt\n" \
                              "WINDSPEED FILE\n"\
                              " SNOWMELT 2 0.5 0.6 0.0 50 0\n" \
                              " ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0\n" \
                              " ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0"
        self.my_options = Temperature()
        self.my_options.set_text(test_windspeed_file)
        actual_text = self.my_options.get_text()  # display purpose
        assert self.my_options.matches(test_windspeed_file)

    def test_windspeed_file_fail(self):
        """Test windspeed file - 2"""
        # -- This should report fail because Windspeed file should be the same climate file used for air temperature
        # -- in this case the air temperature is not provided as file
        # --Once temperature is defined this passes
        test_windspeed_file = r"""
        [TEMPERATURE]
        ;;Parameter  TimeSeries
        TIMESERIES TS1
        WINDSPEED FILE
        """
        self.my_options = Temperature()
        self.my_options.set_text(test_windspeed_file)
        actual_text = self.my_options.get_text()  # display purpose
        self.assertFalse(self.my_options.matches(test_windspeed_file),
                         "Should fail")

    def test_snowmelt(self):
        """Test snowmelt"""
        # --Once temperature is defined this passes
        test_snowmelt = r"""
        [TEMPERATURE]
        ;;Parameter  TimeSeries
        TIMESERIES daily_temperature.txt
        WINDSPEED FILE
        SNOWMELT 2 0.5 0.6 0.0 50 0
        ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
        ADC PERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
        """
        self.my_options = Temperature()
        self.my_options.set_text(test_snowmelt)
        actual_text = self.my_options.get_text()  # display purpose
        assert self.my_options.matches(test_snowmelt)

    def test_snowmelt_fail(self):
        """Test snowmelt wo one ADC PERVIOUS, assert failed
          Should both be specified. It should allow two or none"""
        test_snowmelt = r"""
        [TEMPERATURE]
        ;;Parameter  TimeSeries
        TIMESERIES daily_temperature.txt
        WINDSPEED FILE
        SNOWMELT 2 0.5 0.6 0.0 50 0
        ADC IMPERVIOUS 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
        """
        self.my_options = Temperature()
        self.my_options.set_text(test_snowmelt)
        actual_text = self.my_options.get_text()  # display purpose
        self.assertFalse(self.my_options.matches(test_snowmelt))

    def test_snowmelt_wo_adc(self):
        """Test snowmelt -- Remove both ADCs"""
        test_snowmelt = r"""
        [TEMPERATURE]
        ;;Parameter  TimeSeries
        TIMESERIES daily_temperature.txt
        WINDSPEED FILE
        SNOWMELT 2 0.5 0.6 0.0 50 0
        """
        self.my_options = Temperature()
        self.my_options.set_text(test_snowmelt)
        actual_text = self.my_options.get_text()  # display purpose
        self.assertTrue(self.my_options.matches(test_snowmelt))

    def test_snowmelt_wo_temperature(self):
        """Test snowmelt -- without temperature"""
        # -- I do no think daily temperature has to be provided for this
        # --Once temperature is defined this passes
        test_snowmelt = r"""
        [TEMPERATURE]
        ;;Parameter  TimeSeries
        SNOWMELT 2 0.5 0.6 0.0 50 0
        """
        self.my_options = Temperature()
        self.my_options.set_text(test_snowmelt)
        actual_text = self.my_options.get_text()  # display purpose
        self.assertFalse(self.my_options.matches(test_snowmelt))