def test_CreateFinalFunctions(self): stub = Stub() mod = Model() us = Country(mod, 'US', 'USA') h1 = Sector(us, 'HH', 'Household') h2 = Sector(us, 'H2', 'Household2') h1._CreateFinalEquations = stub.stub_return h2._CreateFinalEquations = stub.stub_return out = mod._CreateFinalEquations() out = out.split('\n') self.assertTrue('1' in out[0]) self.assertTrue('2' in out[1])
def test_GenerateFinalEquations(self): mod = Model() us = Country(mod, 'US', 'USA') s = Sector(us, 'HH', 'Household', has_F=False) mod._GenerateFullSectorCodes() # Can no longer directly inject data into the Sector object s.AddVariableFromEquation('x=a+1 # foo') s.AddVariableFromEquation('a=cat') out = s._CreateFinalEquations() # Since F has an empty equation, does not appear. targ = [('HH__a', 'cat', '[a] '), ('HH__x', 'HH__a+1', '[x] foo')] # Kill spacing in equations out = [(x[0], x[1].replace(' ', ''), x[2]) for x in out] self.assertEqual(targ, out)