This repository has been archived by the owner on May 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds test_float file and moves option schema tests.
- Loading branch information
1 parent
fa33a7c
commit 1f46220
Showing
7 changed files
with
148 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
# freeseer - vga/presentation capture software | ||
# | ||
# Copyright (C) 2011, 2013 Free and Open Source Software Learning Centre | ||
# http://fosslc.org | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
# For support, questions, suggestions or any other inquiries, visit: | ||
# http://wiki.github.com/Freeseer/freeseer/ | ||
|
||
import unittest | ||
from jsonschema import validate, ValidationError | ||
|
||
from freeseer.framework.config.options import FloatOption | ||
from freeseer.tests.framework.config.options import OptionTest | ||
|
||
|
||
class TestFloatOptionNoDefault(unittest.TestCase, OptionTest): | ||
"""Tests FloatOption without a default value.""" | ||
|
||
valid_success = map(lambda x: x / 10.0, range(-100, 100)) | ||
|
||
encode_success = zip(valid_success, map(str, valid_success)) | ||
|
||
decode_success = zip(map(str, valid_success), valid_success) | ||
decode_failure = [ | ||
'hello', | ||
'1world', | ||
'test2', | ||
] | ||
|
||
def setUp(self): | ||
self.option = FloatOption() | ||
|
||
def test_float_schema(self): | ||
"""Tests FloatOption schema method.""" | ||
self.assertRaises(ValidationError, validate, 'error', self.option.schema()) | ||
self.assertIsNone(validate(5.0, self.option.schema())) | ||
self.assertDictEqual({'type': 'number'}, self.option.schema()) | ||
|
||
|
||
class TestFloatOptionWithDefault(TestFloatOptionNoDefault): | ||
"""Tests FloatOption with a default value.""" | ||
|
||
def setUp(self): | ||
self.option = FloatOption(1234.0) | ||
|
||
def test_default(self): | ||
"""Tests that the default was set correctly.""" | ||
self.assertEqual(self.option.default, 1234.0) | ||
|
||
def test_float_schema(self): | ||
"""Tests FloatOption schema method.""" | ||
self.assertRaises(ValidationError, validate, 'error', self.option.schema()) | ||
self.assertIsNone(validate(5.0, self.option.schema())) | ||
self.assertDictEqual({'default': 1234.0, 'type': 'number'}, self.option.schema()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters