File: test_api.py

package info (click to toggle)
python-arrow 1.3.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 932 kB
  • sloc: python: 14,371; makefile: 67
file content (27 lines) | stat: -rw-r--r-- 770 bytes parent folder | download | duplicates (2)
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
26
27
import arrow


class TestModule:
    def test_get(self, mocker):
        mocker.patch("arrow.api._factory.get", return_value="result")

        assert arrow.api.get() == "result"

    def test_utcnow(self, mocker):
        mocker.patch("arrow.api._factory.utcnow", return_value="utcnow")

        assert arrow.api.utcnow() == "utcnow"

    def test_now(self, mocker):
        mocker.patch("arrow.api._factory.now", tz="tz", return_value="now")

        assert arrow.api.now("tz") == "now"

    def test_factory(self):
        class MockCustomArrowClass(arrow.Arrow):
            pass

        result = arrow.api.factory(MockCustomArrowClass)

        assert isinstance(result, arrow.factory.ArrowFactory)
        assert isinstance(result.utcnow(), MockCustomArrowClass)