コード例 #1
0
 def test_init_invalid_demand(self):
     with pytest.raises(TypeError) as e:
         c = Coverage(None, "Population")
     assert (
         e.value.args[0] ==
         "Expected 'Dataframe' type for dataframe, got '<class 'NoneType'>'"
     )
コード例 #2
0
 def test_init_invalid_demand_col3(self, binary_coverage_dataframe):
     with pytest.raises(ValueError) as e:
         c = Coverage(binary_coverage_dataframe,
                      demand_col=None,
                      coverage_type="partial")
     assert (e.value.args[0] ==
             "'demand_col' is required when generating partial coverage")
コード例 #3
0
 def test_init_invalid_demand_col(self, binary_coverage_dataframe):
     with pytest.raises(TypeError) as e:
         c = Coverage(binary_coverage_dataframe,
                      demand_col=[],
                      coverage_type="partial")
     assert (e.value.args[0] ==
             "Expected 'str' type for demand_col, got '<class 'list'>'")
コード例 #4
0
 def test_init_invalid_coverage_type2(self, binary_coverage_dataframe):
     with pytest.raises(ValueError) as e:
         c = Coverage(binary_coverage_dataframe, coverage_type="test")
     assert (e.value.args[0] == "Invalid coverage type 'test'")
コード例 #5
0
 def test_init_invalid_coverage_type(self, binary_coverage_dataframe):
     with pytest.raises(TypeError) as e:
         c = Coverage(binary_coverage_dataframe, coverage_type=[])
     assert (e.value.args[0] ==
             "Expected 'str' type for coverage_type, got '<class 'list'>'")
コード例 #6
0
 def test_init(self, binary_coverage_dataframe):
     c = Coverage(binary_coverage_dataframe, "Population")
     assert (isinstance(c, Coverage))
コード例 #7
0
 def test_demand_col_property2(self, binary_coverage_dataframe):
     c = Coverage(binary_coverage_dataframe)
     assert (c.demand_col is None)
コード例 #8
0
 def test_demand_col_property(self, binary_coverage_dataframe):
     c = Coverage(binary_coverage_dataframe, "Population")
     assert (c.demand_col == "Population")
コード例 #9
0
 def test_coverage_type_property2(self, binary_coverage_dataframe):
     c = Coverage(binary_coverage_dataframe,
                  "Population",
                  coverage_type="partial")
     assert (c.coverage_type == "partial")
コード例 #10
0
 def test_supply_name_property(self, binary_coverage_dataframe):
     c = Coverage(binary_coverage_dataframe,
                  "Population",
                  supply_name="test")
     assert (c.supply_name == "test")
コード例 #11
0
 def test_supply_name_property_default(self, binary_coverage_dataframe):
     c = Coverage(binary_coverage_dataframe, "Population")
     assert (isinstance(c.supply_name, str))
コード例 #12
0
 def test_demand_name_property(self, binary_coverage_dataframe):
     c = Coverage(binary_coverage_dataframe,
                  "Population",
                  demand_name="test")
     assert (c.demand_name == "test")
コード例 #13
0
 def test_df_property(self, binary_coverage_dataframe):
     c = Coverage(binary_coverage_dataframe, "Population")
     assert (c.df is binary_coverage_dataframe)
コード例 #14
0
 def test_init_invalid_demand_col2(self, binary_coverage_dataframe):
     with pytest.raises(ValueError) as e:
         c = Coverage(binary_coverage_dataframe,
                      demand_col="Test",
                      coverage_type="partial")
     assert (e.value.args[0] == "'Test' not in dataframe")