Exemple #1
0
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'})
Exemple #2
0
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'})
Exemple #3
0
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))
Exemple #4
0
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))
Exemple #5
0
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)
Exemple #6
0
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)
Exemple #7
0
 def setUp(self):
     self.option = FolderOption('/tmp')
Exemple #8
0
 def setUp(self):
     self.option = FolderOption(auto_create=True)
Exemple #9
0
 def setUp(self):
     self.option = FolderOption('/tmp')
Exemple #10
0
 def setUp(self):
     self.option = FolderOption(auto_create=True)