File: test_bindings.py

package info (click to toggle)
metview-python 1.16.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,896 kB
  • sloc: python: 11,306; makefile: 84; ansic: 51; sh: 7
file content (61 lines) | stat: -rw-r--r-- 1,467 bytes parent folder | download | duplicates (3)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# (C) Copyright 2017- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

import os

from metview import bindings


PATH = os.path.dirname(__file__)
MAX_VALUE = 316.06060791015625
SEMI_EQUATOR = 20001600.0
MAX_SQRT_GPT = 16.867127793433
MAX_GPT = 284.5


def file_in_testdir(filename):
    return os.path.join(PATH, filename)


def test_push_number():
    bindings.lib.p_push_number(5)
    bindings.lib.p_push_number(4)


def test_dict_to_pushed_request():
    dict = {
        "param1": True,
        "param2": False,
        "param3": 10,
        "param4": 10.5,
        "param5": "metview",
        "param6": ["1", "2", "3"],
    }
    bindings.dict_to_pushed_args(dict)


def test_bind_functions():
    namespace = {}

    bindings.bind_functions(namespace, module_name="metview")
    result = namespace["dictionary"]

    assert "dictionary" in namespace
    assert result.__name__ == result.__qualname__ == "dictionary"
    assert result.__module__ == "metview"


def test_lists_as_input():
    my_list = [1, 5, 6]
    assert bindings.count(my_list) == 3


def test_tuples_as_input():
    my_tuple = [1, 0, 5, 6]
    assert bindings.count(my_tuple) == 4