示例#1
0
 def test_k_complete(self):
     in_node = ConnectionNode()
     out_node = EndNode()
     self.nozzle0.input_node = in_node
     self.nozzle0.output_node = out_node
     self.nozzle0.set_required_pressure(30, 'psi')
     self.assertFalse(self.nozzle0.is_complete())
示例#2
0
 def test_end_node_energy(self):
     node = EndNode()
     node.set_elevation(10, 'm')
     self.assertEqual(node.get_energy('mH2O'), 10)
     self.assertAlmostEqual(node.get_energy('psi'), 14.219702)
 def test_fails_when_output_node_is_end_node(self):
     out_node = EndNode()
     with self.assertRaises(TypeError):
         self.eductor0.output_node = out_node
 def test_fails_when_input_node_is_end_node(self):
     in_node = EndNode()
     with self.assertRaises(TypeError):
         self.eductor0.input_node = in_node
示例#5
0
 def test_repeated_output(self):
     other_node = EndNode()
     self.nozzle0.output_node = self.out_node
     with self.assertRaises(ValueError):
         self.nozzle0.output_node = other_node
示例#6
0
 def setUp(self):
     self.nozzle0 = Nozzle()
     self.in_node = ConnectionNode()
     self.out_node = EndNode()
示例#7
0
class NozzleTests(unittest.TestCase):
    def setUp(self):
        self.nozzle0 = Nozzle()
        self.in_node = ConnectionNode()
        self.out_node = EndNode()

    def test_creation(self):
        self.assertTrue(isinstance(self.nozzle0, Nozzle))
        self.assertTrue(isinstance(self.nozzle0, Edge))

    def test_name(self):
        self.nozzle0.name = 3
        self.assertEqual(self.nozzle0.name, '3')

    def test_input_node(self):
        other_node = ConnectionNode()
        self.nozzle0.input_node = self.in_node
        self.assertEqual(self.nozzle0.input_node, self.in_node)
        with self.assertRaises(IndexError):
            self.nozzle0.input_node = other_node

    def test_false_input(self):
        false_input = 'false node'
        with self.assertRaises(ValueError):
            self.nozzle0.input_node = false_input

    def test_output(self):
        self.nozzle0.output_node = self.out_node
        self.assertEqual(self.nozzle0.output_node, self.out_node)

    def test_end_output(self):
        with self.assertRaises(ValueError):
            self.nozzle0.output_node = self.in_node

    def test_repeated_output(self):
        other_node = EndNode()
        self.nozzle0.output_node = self.out_node
        with self.assertRaises(ValueError):
            self.nozzle0.output_node = other_node

    def test_k_factor(self):
        self.nozzle0.set_factor(1.2, 'gpm/psi^0.5')
        k_lpm = self.nozzle0.get_factor('lpm/bar^0.5')
        self.assertAlmostEqual(k_lpm, 17.29954989, 5)
        self.nozzle0.set_factor(17.29954989, 'lpm/bar^0.5')
        self.assertAlmostEqual(self.nozzle0.get_factor('gpm/psi^0.5'), 1.2)

    def test_gpm_flow(self):
        self.nozzle0.set_factor(2, 'gpm/psi^0.5')
        self.in_node.set_elevation(5, 'm')
        self.in_node.set_pressure(36, 'psi')
        self.out_node.set_elevation(5, 'm')
        self.nozzle0.input_node = self.in_node
        self.nozzle0.output_node = self.out_node
        nozzle_flow = self.nozzle0.calculate_gpm_flow()
        self.assertAlmostEqual(nozzle_flow, 12)

    def test_required_pressure(self):
        self.nozzle0.set_required_pressure(30, 'psi')
        self.assertEqual(self.nozzle0.get_required_pressure('psi'), 30)

    def test_complete_nozzle(self):
        self.nozzle0.input_node = self.in_node
        self.nozzle0.output_node = self.out_node
        self.nozzle0.set_required_pressure(30, 'psi')
        self.nozzle0.set_factor(1.2, 'gpm/psi^0.5')
        self.assertTrue(self.nozzle0.is_complete())

    def test_k_complete(self):
        in_node = ConnectionNode()
        out_node = EndNode()
        self.nozzle0.input_node = in_node
        self.nozzle0.output_node = out_node
        self.nozzle0.set_required_pressure(30, 'psi')
        self.assertFalse(self.nozzle0.is_complete())
示例#8
0
 def test_when_set_end_node_as_input_node_fails(self):
     end_node = EndNode()
     with self.assertRaises(ValueError):
         self.pump.input_node = end_node