def test_add_details_seg_start_old(self): '''Tests method of core.Network: add_details. Tests that add_details method correctly handles the situation where the details reference a node that already exists. This test is against adding a segment start. ''' focus = core.PipeSegment() # Use nd to make sure that node 'A' doesn't change nd = self.network.nodes['A'] = core.Node() self.network.add_details(focus, ['start', 'A']) self.assertIs(nd, focus.start) self.assertIs(nd, self.network.nodes['A']) self.assertIs(nd.outputs[0], focus)
def test_add_details_seg_start_new(self): '''Tests method of core.Network: add_details. Tests that add_details method correctly handles the situation where the details reference a node that doesn't exist. This test is against adding a segment start. ''' focus = core.PipeSegment() # Check that nodes dict is empty before function runs self.assertDictEqual(self.network.nodes, dict()) self.network.add_details(focus, ['start', 'A']) self.assertIsInstance(self.network.nodes['A'], core.Node) self.assertIs(self.network.nodes['A'], focus.start) self.assertIs(self.network.nodes['A'].outputs[0], focus)
def test__find_unknowns(self): '''Tests method core.Network: _find_unknowns''' # Create network elements self.network.nodes['A'] = core.Node() self.network.segments['1'] = core.PipeSegment() self.network.nodes['B'] = core.Node() # Setup network connections self.network.nodes['A'].outputs.append(self.network.segments['1']) self.network.nodes['B'].inputs.append(self.network.segments['1']) self.network.segments['1'].start = self.network.nodes['A'] self.network.segments['1'].end = self.network.nodes['B'] # Set knowns self.network.nodes['A'].head = 10.0 * ureg.feet self.network.nodes['B'].head = 5.0 * ureg.feet # Run the method self.network._find_unknowns() self.assertEqual(len(self.network.unknowns), 1) self.assertEqual(self.network.unknowns[0], self.network.segments['1'].set_val)
def setUp(self): self.seg = core.PipeSegment()