def test_split_content_by_section_exceptions(self): lp_str = """ Maximize objective section """ with pytest.raises(Exception) as e: LpReader._split_content_by_sections(lp_str) assert str(e.value) == 'file must end with an "end" keyword' lp_str = """ { "foo": "bar" } """ with pytest.raises(Exception) as e: LpReader._split_content_by_sections(lp_str) assert str(e.value) == 'file must start with an objective'
def test_split_content_by_section_minimal(self): lp_str = """ Maximize objective section End """ is_maximize, sections = LpReader._split_content_by_sections(lp_str) assert is_maximize assert sections['objective'] == 'objective section' assert 'constraints' not in sections assert 'bounds' not in sections assert 'generals' not in sections assert 'binaries' not in sections
def test_split_content_by_section_different_order(self): lp_str = """ Maximize objective section Subject To constraints section Binary binaries section Generals generals section Bounds bounds section End """ is_maximize, sections = LpReader._split_content_by_sections(lp_str) assert is_maximize assert sections['objective'] == 'objective section' assert sections['constraints'] == 'constraints section' assert sections['bounds'] == 'bounds section' assert sections['generals'] == 'generals section' assert sections['binaries'] == 'binaries section'