Ejemplo n.º 1
0
 def test_port_write_bad_port2(self):
     good_path = os.path.dirname(os.path.realpath(__file__))
     port = OutputPort(port_type='string', value=good_path)
     try:
         port.write('test.txt', 'Hello World')
     except ValueError as e:
         self.assertIn('Only Directory ports', e.message)
Ejemplo n.º 2
0
    def test_port_write_good_path_abs(self):
        """
        Test write to a port, with an absolute filename
        """
        good_path = os.path.dirname(os.path.realpath(__file__))
        file_name = os.path.join(good_path, 'test.txt')

        port = OutputPort(value=good_path)

        # Write to abs path
        try:
            port.write(file_name, 'Hello World')
        except ValueError as e:
            self.assertIn('File name must be relative', e.message)
Ejemplo n.º 3
0
    def test_port_write_good_path(self):
        """
        Test write to a port, relative to the port
        """
        good_path = os.path.dirname(os.path.realpath(__file__))
        port = OutputPort(value=good_path)

        # Write to file relative to port path.
        port.write('test.txt', 'Hello World')

        file_name = os.path.join(good_path, 'test.txt')

        with open(file_name, 'r') as f:
            self.assertEqual('Hello World', f.read())
Ejemplo n.º 4
0
 def test_port_string(self):
     port = OutputPort(port_type='string')
     port.name = 'test_port'
     port.value = 10
     self.assertEquals(port.json['name'], 'test_port')
     self.assertEquals(port.json['type'], 'string')
Ejemplo n.º 5
0
 def test_port_write_remote_path(self):
     good_path = os.path.dirname(os.path.realpath(__file__))
     port = OutputPort(value=good_path)
     port.name = 'test_port'
     self.assertEquals(port.path, '/mnt/work/output/test_port')