def test_port_write_bad_port(self): good_path = os.path.dirname(os.path.realpath(__file__)) port = InputPort(value=good_path) try: port.write('test.txt', 'Hello World') except ValueError as e: self.assertIn('Only Output ports', e.message)
def test_port_list_files_bad_path(self): bad_path = 'not/good/path' port = InputPort(value=bad_path) try: port.list_files() except ValueError as e: self.assertIn('Port %s' % bad_path, e.message)
def test_port_list_files_good_remote_path(self): good_path = os.path.dirname(os.path.realpath(__file__)) bad_path = 'not/good/path' port = InputPort(value=bad_path) port.name = 'test' port.remote_path = good_path all_files = port.list_files(extensions=".py") self.assertEqual(len(all_files), 5)
def test_port_list_files(self): path = os.path.dirname(os.path.realpath(__file__)) port = InputPort(value=path) all_files = port.list_files() self.assertIn(__file__, all_files) for f in all_files: self.assertTrue(os.path.isfile(f)) py_files = port.list_files(extensions=".py") self.assertIn(__file__, py_files) pyc_files = port.list_files(extensions=".pyc") self.assertNotIn(__file__, pyc_files) self.assertGreater(len(all_files), len(py_files)) self.assertGreater(len(all_files), len(pyc_files))