Example #1
0
    def test_custom_str2price_convert(self):
        class CustomStr(str): pass

        assert convertPrice(CustomStr('3.04 €')) == 304
        assert convertPrice(CustomStr('3.04€')) == 304
        assert convertPrice(CustomStr('3.04')) == 304
        assert convertPrice(CustomStr('13.04 €')) == 1304
Example #2
0
    def test_custom_float2price_convert(self):
        class CustomFloat(float): pass

        assert convertPrice(CustomFloat(3.00)) == 300
        assert convertPrice(CustomFloat(3.65)) == 365
        assert convertPrice(CustomFloat(3.61234)) == 361
        assert convertPrice(CustomFloat(13.25534)) == 1326
Example #3
0
    def test_custom_int2price_convert(self):
        class CustomInt(int): pass

        assert convertPrice(CustomInt(3)) == 3
        assert convertPrice(CustomInt(365)) == 365
        assert convertPrice(CustomInt(361)) == 361
        assert convertPrice(CustomInt(1326)) == 1326
Example #4
0
    def test_custom_float2price_convert(self):
        class CustomFloat(float):
            pass

        assert convertPrice(CustomFloat(3.00)) == 300
        assert convertPrice(CustomFloat(3.65)) == 365
        assert convertPrice(CustomFloat(3.61234)) == 361
        assert convertPrice(CustomFloat(13.25534)) == 1326
Example #5
0
    def test_custom_int2price_convert(self):
        class CustomInt(int):
            pass

        assert convertPrice(CustomInt(3)) == 3
        assert convertPrice(CustomInt(365)) == 365
        assert convertPrice(CustomInt(361)) == 361
        assert convertPrice(CustomInt(1326)) == 1326
Example #6
0
    def test_custom_str2price_convert(self):
        class CustomStr(str):
            pass

        assert convertPrice(CustomStr('3.04 €')) == 304
        assert convertPrice(CustomStr('3.04€')) == 304
        assert convertPrice(CustomStr('3.04')) == 304
        assert convertPrice(CustomStr('13.04 €')) == 1304
Example #7
0
 def test_single_cent_converting(self):
     assert convertPrice('as 3,4 € hans') == 340
     with pytest.raises(ValueError):
         convertPrice('3,4 ')
Example #8
0
 def test_str_only_euro(self):
     assert convertPrice('3 €') == 300
     assert convertPrice('4€') == 400
Example #9
0
 def test_str2price_with_garbage(self):
     assert convertPrice('as 3,04 hans') == 304
     assert convertPrice('14,3 2 12,4,4 13.04') == 1304
Example #10
0
 def test_str_comma2price_convert(self):
     assert convertPrice('3,04 €') == 304
     assert convertPrice('3,04€') == 304
     assert convertPrice('3,04') == 304
     assert convertPrice('13,04 €') == 1304
Example #11
0
 def test_str_comma2price_convert(self):
     assert convertPrice('3,04 €') == 304
     assert convertPrice('3,04€') == 304
     assert convertPrice('3,04') == 304
     assert convertPrice('13,04 €') == 1304
Example #12
0
 def test_garbage_strings(self):
     with pytest.raises(ValueError):
         convertPrice('34,3,3 €')
Example #13
0
 def test_none_detected(self):
     assert convertPrice('-') is None
     assert convertPrice(' -   ') is None
Example #14
0
 def test_int2price_convert(self):
     assert convertPrice(304) == 304
     assert convertPrice(20) == 20
Example #15
0
 def test_custom_none_detected(self):
     convertPrice('Keine Ahnung',
                  none_regex=re.compile(r'[Kk]eine.*')) is None
     convertPrice('Keine Idee',
                  none_regex=re.compile(r'[Kk]eine.*')) is None
Example #16
0
 def test_deactived_none_detected(self):
     with pytest.raises(ValueError):
         convertPrice('-', none_regex=None)
     with pytest.raises(ValueError):
         convertPrice(' -   ', none_regex=None)
Example #17
0
 def test_none_detected(self):
     assert convertPrice('-') is None
     assert convertPrice(' -   ') is None
Example #18
0
 def test_float2price_convert(self):
     assert convertPrice(3.00) == 300
     assert convertPrice(3.65) == 365
     assert convertPrice(3.61234) == 361
     assert convertPrice(13.25534) == 1326
Example #19
0
 def test_garbage_strings(self):
     with pytest.raises(ValueError):
         convertPrice('34,3,3 €')
Example #20
0
 def test_custom_none_detected(self):
     convertPrice('Keine Ahnung', none_regex=re.compile(r'[Kk]eine.*')) is None
     convertPrice('Keine Idee', none_regex=re.compile(r'[Kk]eine.*')) is None
Example #21
0
 def test_float2price_convert(self):
     assert convertPrice(3.00) == 300
     assert convertPrice(3.65) == 365
     assert convertPrice(3.61234) == 361
     assert convertPrice(13.25534) == 1326
Example #22
0
 def test_str_only_euro(self):
     assert convertPrice('3 €') == 300
     assert convertPrice('4€') == 400
Example #23
0
 def test_deactived_none_detected(self):
     with pytest.raises(ValueError):
         convertPrice('-', none_regex=None)
     with pytest.raises(ValueError):
         convertPrice(' -   ', none_regex=None)
Example #24
0
 def test_single_cent_converting(self):
     assert convertPrice('as 3,4 € hans') == 340
     with pytest.raises(ValueError):
         convertPrice('3,4 ')
Example #25
0
 def test_wrong_types(self):
     with pytest.raises(TypeError):
         convertPrice(True)
     with pytest.raises(TypeError):
         convertPrice(None)
Example #26
0
 def test_str2price_with_garbage(self):
     assert convertPrice('as 3,04 hans') == 304
     assert convertPrice('14,3 2 12,4,4 13.04') == 1304
Example #27
0
 def test_wrong_types(self):
     with pytest.raises(TypeError):
         convertPrice(True)
     with pytest.raises(TypeError):
         convertPrice(None)
Example #28
0
 def test_str_dot2price_convert(self):
     assert convertPrice('3.04 €') == 304
     assert convertPrice('3.04€') == 304
     assert convertPrice('3.04') == 304
     assert convertPrice('13.04 €') == 1304
Example #29
0
 def test_int2price_convert(self):
     assert convertPrice(304) == 304
     assert convertPrice(20) == 20
Example #30
0
 def test_str_dot2price_convert(self):
     assert convertPrice('3.04 €') == 304
     assert convertPrice('3.04€') == 304
     assert convertPrice('3.04') == 304
     assert convertPrice('13.04 €') == 1304