File: test_utils.py

package info (click to toggle)
python-dogpile.cache 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 772 kB
  • sloc: python: 5,462; makefile: 155; sh: 104
file content (25 lines) | stat: -rw-r--r-- 819 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from dogpile import util
from dogpile.testing import eq_


class UtilsTest:

    """Test the relevant utils functionality."""

    def test_coerce_string_conf(self):
        settings = {"expiration_time": "-1"}
        coerced = util.coerce_string_conf(settings)
        eq_(coerced["expiration_time"], -1)

        settings = {"expiration_time": "+1"}
        coerced = util.coerce_string_conf(settings)
        eq_(coerced["expiration_time"], 1)
        eq_(type(coerced["expiration_time"]), int)

        settings = {"arguments.lock_sleep": "0.1"}
        coerced = util.coerce_string_conf(settings)
        eq_(coerced["arguments.lock_sleep"], 0.1)

        settings = {"arguments.lock_sleep": "-3.14e-10"}
        coerced = util.coerce_string_conf(settings)
        eq_(coerced["arguments.lock_sleep"], -3.14e-10)