How to use check_readable method in avocado

Best Python code snippet using avocado_python Github


Full Screen

1''' sanity checks to perform before starting server3Copyright4---------5Copyright (c) 2021-2022 by the California Institute of Technology. This code6is open-source software released under a 3-clause BSD license. Please see the7file "LICENSE" for more information.8'''9from commonpy.file_utils import writable, readable10from commonpy.string_utils import print_boxed11from os.path import dirname12from sidetrack import log13# In order for this to work, it needs to avoid importing anything that might14# in turn cause data_models to be imported. So, keep DIBS imports to a15# minimum and watch the dependencies in the code.16from .settings import config, resolved_path17def preflight_check(database = None):18 '''Verify certain critical things are set up & complain if they're not.'''19 successes = [20 verified('LSP_TYPE'),21 verified('IIIF_BASE_URL'),22 verified('DATABASE_FILE', check_parent_writable = True),23 verified('MANIFEST_DIR', check_readable = True),24 verified('PROCESS_DIR', check_readable = True, check_writable = True),25 verified('THUMBNAILS_DIR', check_readable = True, check_writable = True),26 ]27 if all(successes):28 log('preflight tests succeeded')29 return True30 else:31 log('preflight tests failed')32 return False33def verified(variable, check_readable = False, check_writable = False,34 check_parent_writable = False):35 '''Verify the given configuration 'variable' in various ways.'''36 if not config(variable, default = None):37 print_boxed(f'Variable {variable} is not set.\n'38 ' DIBS cannot function properly.',39 title = 'DIBS Fatal Error')40 return False41 dir = resolved_path(config(variable)) # noqa A00142 success = True43 if check_readable and not readable(dir):44 print_boxed(f'Cannot read the directory indicated by the configuration\n'45 f'variable {variable}. The directory located at\n\n'46 f'{dir}\n\nis not readable. DIBS cannot function properly.',47 title = 'DIBS configuration error')48 success = False49 if check_writable and not writable(dir):50 print_boxed(f'Cannot write the directory indicated by the configuration\n'51 f'variable {variable}. The directory located at\n\n'52 f'{dir}\n\nis not writable. DIBS cannot function properly.',53 title = 'DIBS configuration error')54 success = False55 if check_parent_writable and not writable(dirname(dir)):56 parent = dirname(dir)57 print_boxed(f'Cannot write in the parent directory of the value indicated by\n'58 f'the configuraton variable {variable}. The directory located at\n\n'59 f'{parent}\n\nis not writable. DIBS cannot function properly.',60 title = 'DIBS configuration error')61 success = False...

Full Screen

Full Screen Github


Full Screen

...3from six import text_type4from fs.mode import check_readable, check_writable, Mode5class TestMode(unittest.TestCase):6 def test_checks(self):7 self.assertTrue(check_readable("r"))8 self.assertTrue(check_readable("r+"))9 self.assertTrue(check_readable("rt"))10 self.assertTrue(check_readable("rb"))11 self.assertFalse(check_readable("w"))12 self.assertTrue(check_readable("w+"))13 self.assertFalse(check_readable("wt"))14 self.assertFalse(check_readable("wb"))15 self.assertFalse(check_readable("a"))16 self.assertTrue(check_writable("w"))17 self.assertTrue(check_writable("w+"))18 self.assertTrue(check_writable("r+"))19 self.assertFalse(check_writable("r"))20 self.assertTrue(check_writable("a"))21 def test_mode_object(self):22 with self.assertRaises(ValueError):23 Mode("")24 with self.assertRaises(ValueError):25 Mode("J")26 with self.assertRaises(ValueError):27 Mode("b")28 with self.assertRaises(ValueError):29 Mode("rtb")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?