コード例 #1
0
ファイル: test_lib.py プロジェクト: simhnna/openlp
    def test_str_to_bool_with_true_string_value(self):
        """
        Test the str_to_bool function with a string set to "True"
        """
        # GIVEN: A string set to "True"
        true_string = 'True'

        # WHEN: we convert it to a bool
        true_result = str_to_bool(true_string)

        # THEN: we should get back a true
        assert true_result is True, 'The result should be True'
コード例 #2
0
ファイル: test_lib.py プロジェクト: simhnna/openlp
    def test_str_to_bool_with_yes_string_value(self):
        """
        Test the str_to_bool function with a string set to "yes"
        """
        # GIVEN: An string set to "yes"
        yes_string = 'yes'

        # WHEN: we convert it to a bool
        str_result = str_to_bool(yes_string)

        # THEN: we should get back a true
        assert str_result is True, 'The result should be True'
コード例 #3
0
ファイル: test_lib.py プロジェクト: simhnna/openlp
    def test_str_to_bool_with_string_no(self):
        """
        Test the str_to_bool function with a string saying "NO"
        """
        # GIVEN: An string set to "NO"
        no_string = 'NO'

        # WHEN: we convert it to a bool
        str_result = str_to_bool(no_string)

        # THEN: we should get back a false
        assert str_result is False, 'The result should be False'
コード例 #4
0
ファイル: test_lib.py プロジェクト: simhnna/openlp
    def test_str_to_bool_with_string_false(self):
        """
        Test the str_to_bool function with a string saying "false"
        """
        # GIVEN: A string set to "false"
        false_string = 'false'

        # WHEN: we convert it to a bool
        false_result = str_to_bool(false_string)

        # THEN: we should get back a false
        assert false_result is False, 'The result should be False'
コード例 #5
0
ファイル: test_lib.py プロジェクト: marmyshev/bug_1117098
    def str_to_bool_with_invalid_test(self):
        """
        Test the str_to_bool function with a set of invalid inputs
        """
        # GIVEN: An integer value
        int_string = 1

        # WHEN: we convert it to a bool
        int_result = str_to_bool(int_string)

        # THEN: we should get back a false
        assert int_result is False, 'The result should be False'

        # GIVEN: An string value with completely invalid input
        invalid_string = 'my feet are wet'

        # WHEN: we convert it to a bool
        str_result = str_to_bool(invalid_string)

        # THEN: we should get back a false
        assert str_result is False, 'The result should be False'
コード例 #6
0
ファイル: test_lib.py プロジェクト: imkernel/openlp
    def test_str_to_bool_with_true_string_value(self):
        """
        Test the str_to_bool function with a string set to "True"
        """
        # GIVEN: A string set to "True"
        true_string = 'True'

        # WHEN: we convert it to a bool
        true_result = str_to_bool(true_string)

        # THEN: we should get back a true
        self.assertTrue(true_result, 'The result should be True')
コード例 #7
0
ファイル: test_lib.py プロジェクト: imkernel/openlp
    def test_str_to_bool_with_yes_string_value(self):
        """
        Test the str_to_bool function with a string set to "yes"
        """
        # GIVEN: An string set to "yes"
        yes_string = 'yes'

        # WHEN: we convert it to a bool
        str_result = str_to_bool(yes_string)

        # THEN: we should get back a true
        self.assertTrue(str_result, 'The result should be True')
コード例 #8
0
ファイル: test_lib.py プロジェクト: imkernel/openlp
    def test_str_to_bool_with_invalid_string(self):
        """
        Test the str_to_bool function with an invalid string
        """
        # GIVEN: An string value with completely invalid input
        invalid_string = 'my feet are wet'

        # WHEN: we convert it to a bool
        str_result = str_to_bool(invalid_string)

        # THEN: we should get back a false
        self.assertFalse(str_result, 'The result should be False')
コード例 #9
0
ファイル: test_lib.py プロジェクト: imkernel/openlp
    def test_str_to_bool_with_string_no(self):
        """
        Test the str_to_bool function with a string saying "NO"
        """
        # GIVEN: An string set to "NO"
        no_string = 'NO'

        # WHEN: we convert it to a bool
        str_result = str_to_bool(no_string)

        # THEN: we should get back a false
        self.assertFalse(str_result, 'The result should be False')
コード例 #10
0
ファイル: test_lib.py プロジェクト: marmyshev/bug_1117098
    def str_to_bool_with_false_values_test(self):
        """
        Test the str_to_bool function with a set of false inputs
        """
        # GIVEN: A string set to "false"
        false_string = 'false'

        # WHEN: we convert it to a bool
        false_result = str_to_bool(false_string)

        # THEN: we should get back a false
        assert false_result is False, 'The result should be False'

        # GIVEN: An string set to "NO"
        no_string = 'NO'

        # WHEN: we convert it to a bool
        str_result = str_to_bool(no_string)

        # THEN: we should get back a false
        assert str_result is False, 'The result should be False'
コード例 #11
0
ファイル: test_lib.py プロジェクト: marmyshev/bug_1117098
    def str_to_bool_with_true_values_test(self):
        """
        Test the str_to_bool function with a set of true inputs
        """
        # GIVEN: A string set to "True"
        true_string = 'True'

        # WHEN: we convert it to a bool
        true_result = str_to_bool(true_string)

        # THEN: we should get back a true
        assert true_result is True, 'The result should be True'

        # GIVEN: An string set to "yes"
        yes_string = 'yes'

        # WHEN: we convert it to a bool
        str_result = str_to_bool(yes_string)

        # THEN: we should get back a true
        assert str_result is True, 'The result should be True'
コード例 #12
0
ファイル: test_lib.py プロジェクト: imkernel/openlp
    def test_str_to_bool_with_string_false(self):
        """
        Test the str_to_bool function with a string saying "false"
        """
        # GIVEN: A string set to "false"
        false_string = 'false'

        # WHEN: we convert it to a bool
        false_result = str_to_bool(false_string)

        # THEN: we should get back a false
        self.assertFalse(false_result, 'The result should be False')
コード例 #13
0
ファイル: test_lib.py プロジェクト: imkernel/openlp
    def test_str_to_bool_with_integer(self):
        """
        Test the str_to_bool function with an integer input
        """
        # GIVEN: An integer value
        int_string = 1

        # WHEN: we convert it to a bool
        int_result = str_to_bool(int_string)

        # THEN: we should get back a false
        self.assertFalse(int_result, 'The result should be False')
コード例 #14
0
ファイル: test_lib.py プロジェクト: simhnna/openlp
    def test_str_to_bool_with_invalid_string(self):
        """
        Test the str_to_bool function with an invalid string
        """
        # GIVEN: An string value with completely invalid input
        invalid_string = 'my feet are wet'

        # WHEN: we convert it to a bool
        str_result = str_to_bool(invalid_string)

        # THEN: we should get back a false
        assert str_result is False, 'The result should be False'
コード例 #15
0
ファイル: test_lib.py プロジェクト: simhnna/openlp
    def test_str_to_bool_with_integer(self):
        """
        Test the str_to_bool function with an integer input
        """
        # GIVEN: An integer value
        int_string = 1

        # WHEN: we convert it to a bool
        int_result = str_to_bool(int_string)

        # THEN: we should get back a false
        assert int_result is False, 'The result should be False'
コード例 #16
0
ファイル: test_lib.py プロジェクト: imkernel/openlp
    def test_str_to_bool_with_bool_false(self):
        """
        Test the str_to_bool function with boolean input of False
        """
        # GIVEN: A boolean value set to false
        false_boolean = False

        # WHEN: We "convert" it to a bool
        false_result = str_to_bool(false_boolean)

        # THEN: We should get back a True bool
        self.assertIsInstance(false_result, bool, 'The result should be a boolean')
        self.assertFalse(false_result, 'The result should be True')
コード例 #17
0
ファイル: test_lib.py プロジェクト: jkunle/paul
    def str_to_bool_with_bool_false_test(self):
        """
        Test the str_to_bool function with boolean input of False
        """
        # GIVEN: A boolean value set to false
        false_boolean = False

        # WHEN: We "convert" it to a bool
        false_result = str_to_bool(false_boolean)

        # THEN: We should get back a True bool
        self.assertIsInstance(false_result, bool, 'The result should be a boolean')
        self.assertFalse(false_result, 'The result should be True')
コード例 #18
0
ファイル: test_lib.py プロジェクト: simhnna/openlp
    def test_str_to_bool_with_bool_false(self):
        """
        Test the str_to_bool function with boolean input of False
        """
        # GIVEN: A boolean value set to false
        false_boolean = False

        # WHEN: We "convert" it to a bool
        false_result = str_to_bool(false_boolean)

        # THEN: We should get back a True bool
        assert isinstance(false_result, bool), 'The result should be a boolean'
        assert false_result is False, 'The result should be True'
コード例 #19
0
ファイル: test_lib.py プロジェクト: simhnna/openlp
    def test_str_to_bool_with_bool_true(self):
        """
        Test the str_to_bool function with boolean input of True
        """
        # GIVEN: A boolean value set to true
        true_boolean = True

        # WHEN: We "convert" it to a bool
        true_result = str_to_bool(true_boolean)

        # THEN: We should get back a True bool
        assert isinstance(true_result, bool), 'The result should be a boolean'
        assert true_result is True, 'The result should be True'
コード例 #20
0
ファイル: test_lib.py プロジェクト: crossroadchurch/paul
    def str_to_bool_with_bool_true_test(self):
        """
        Test the str_to_bool function with boolean input of True
        """
        # GIVEN: A boolean value set to true
        true_boolean = True

        # WHEN: We "convert" it to a bool
        true_result = str_to_bool(true_boolean)

        # THEN: We should get back a True bool
        self.assertIsInstance(true_result, bool, 'The result should be a boolean')
        self.assertTrue(true_result, 'The result should be True')
コード例 #21
0
ファイル: test_lib.py プロジェクト: marmyshev/bug_1117098
    def str_to_bool_with_bool_test(self):
        """
        Test the str_to_bool function with boolean input
        """
        # GIVEN: A boolean value set to true
        true_boolean = True

        # WHEN: We "convert" it to a bool
        true_result = str_to_bool(true_boolean)

        # THEN: We should get back a True bool
        assert isinstance(true_result, bool), 'The result should be a boolean'
        assert true_result is True, 'The result should be True'

        # GIVEN: A boolean value set to false
        false_boolean = False

        # WHEN: We "convert" it to a bool
        false_result = str_to_bool(false_boolean)

        # THEN: We should get back a True bool
        assert isinstance(false_result, bool), 'The result should be a boolean'
        assert false_result is False, 'The result should be True'
コード例 #22
0
ファイル: theme.py プロジェクト: crossroadchurch/paul
 def _create_attr(self, master, element, value):
     """
     Create the attributes with the correct data types and name format
     """
     reject, master, element, value = self._translate_tags(master, element, value)
     if reject:
         return
     field = de_hump(element)
     tag = master + '_' + field
     if field in BOOLEAN_LIST:
         setattr(self, tag, str_to_bool(value))
     elif field in INTEGER_LIST:
         setattr(self, tag, int(value))
     else:
         # make string value unicode
         if not isinstance(value, str):
             value = str(str(value), 'utf-8')
         # None means an empty string so lets have one.
         if value == 'None':
             value = ''
         setattr(self, tag, str(value).strip().lstrip())
コード例 #23
0
ファイル: theme.py プロジェクト: feitianyiren/openlp
 def _create_attr(self, master, element, value):
     """
     Create the attributes with the correct data types and name format
     """
     reject, master, element, value = self._translate_tags(master, element, value)
     if reject:
         return
     field = de_hump(element)
     tag = master + '_' + field
     if field in BOOLEAN_LIST:
         setattr(self, tag, str_to_bool(value))
     elif field in INTEGER_LIST:
         setattr(self, tag, int(value))
     else:
         # make string value unicode
         if not isinstance(value, str):
             value = str(str(value), 'utf-8')
         # None means an empty string so lets have one.
         if value == 'None':
             value = ''
         setattr(self, tag, str(value).strip().lstrip())