class TestFolderOptionNoDefault(unittest.TestCase, OptionTest): """Tests FolderOption without a default value.""" valid_success = [ '/tmp', ] valid_failure = [ '/tmp/1', ] encode_success = zip(valid_success, valid_success) decode_success = zip(valid_success, valid_success) decode_failure = valid_failure def setUp(self): self.option = FolderOption() def test_presentation(self): path = tempfile.mkdtemp() shutil.rmtree(path) presentation_value = self.option.presentation(path) self.assertEqual(presentation_value, path) self.assertFalse(os.path.exists(presentation_value)) def test_schema(self): """Tests StringOption schema method.""" self.assertRaises(ValidationError, validate, 1, self.option.schema()) self.assertIsNone(validate('/tmp2', self.option.schema())) self.assertDictEqual(self.option.schema(), {'type': 'string'})
class TestFolderOptionWithDefault(TestFolderOptionNoDefault): """Tests FolderOption with a default value.""" def setUp(self): self.option = FolderOption('/tmp') def test_default(self): """Tests that the default was set correctly.""" self.assertEqual(self.option.default, '/tmp') def test_schema(self): """Tests StringOption schema method.""" self.assertRaises(ValidationError, validate, 1, self.option.schema()) self.assertIsNone(validate('/tmp2', self.option.schema())) self.assertDictEqual(self.option.schema(), {'default': '/tmp', 'type': 'string'})
class TestFolderOptionNoDefault(unittest.TestCase, OptionTest): """Tests FolderOption without a default value.""" valid_success = [ '/tmp', ] valid_failure = [ '/tmp/1', ] encode_success = zip(valid_success, valid_success) decode_success = zip(valid_success, valid_success) decode_failure = valid_failure def setUp(self): self.option = FolderOption() def test_presentation(self): path = tempfile.mkdtemp() shutil.rmtree(path) presentation_value = self.option.presentation(path) self.assertEqual(presentation_value, path) self.assertFalse(os.path.exists(presentation_value))
class TestFolderOptionAutoCreate(TestFolderOptionNoDefault): """Tests FolderOption without a default value, and with auto_create turned on.""" valid_failure = [] decode_failure = [] def setUp(self): self.option = FolderOption(auto_create=True) def test_presentation(self): path = tempfile.mkdtemp() shutil.rmtree(path) presentation_value = self.option.presentation(path) self.assertEqual(presentation_value, path) self.assertTrue(os.path.exists(presentation_value)) shutil.rmtree(path)
def setUp(self): self.option = FolderOption('/tmp')
def setUp(self): self.option = FolderOption(auto_create=True)