コード例 #1
0
def test_from_auth_file_in_dhishome(auth_file_in_dhishome):
    home = os.path.join(os.path.expanduser(os.path.join("~")))
    dhis_home = os.path.join(home, "tomcat-dhis-test-524")
    kwargs = {"DHIS_HOME": dhis_home}
    with override_environ(**kwargs):
        api = Api.from_auth_file()
        assert api.base_url == "https://play.dhis2.org/demo"
        assert api.username == "admin"
コード例 #2
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_from_auth_file_in_dhishome(auth_file_in_dhishome):
    home = os.path.join(os.path.expanduser(os.path.join('~')))
    dhis_home = os.path.join(home, 'tomcat-dhis-test-524')
    kwargs = {'DHIS_HOME': dhis_home}
    with override_environ(**kwargs):
        api = Api.from_auth_file()
        assert api.base_url == 'https://play.dhis2.org/demo'
        assert api.username == 'admin'
コード例 #3
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_user_agent():
    api = Api('https://play.dhis2.org/demo',
              'admin',
              'district',
              30,
              user_agent='customLib/0.0.1')
    assert 'user-agent' in api.session.headers and api.session.headers[
        'user-agent'] == 'customLib/0.0.1'
コード例 #4
0
def test_user_agent():
    api = Api(
        "https://play.dhis2.org/demo",
        "admin",
        "district",
        30,
        user_agent="customLib/0.0.1",
    )
    assert (
        "user-agent" in api.session.headers
        and api.session.headers["user-agent"] == "customLib/0.0.1"
    )
コード例 #5
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_from_auth_file_not_found():
    kwargs = {}
    with override_environ(**kwargs) and pytest.raises(
            exceptions.ClientException):
        Api.from_auth_file('not_here.json')
コード例 #6
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_str():
    api = Api('https://play.dhis2.org/demo', 'admin', 'district')
    assert str(api).startswith('DHIS2')
コード例 #7
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def api_with_api_version():
    return Api(BASEURL, 'admin', 'district', api_version=30)
コード例 #8
0
def test_from_auth_file_named(auth_file):
    tmp = tempfile.gettempdir()
    filename = os.path.join(tmp, "auth_test.json")
    api = Api.from_auth_file(location=filename)
    assert api.base_url == "https://play.dhis2.org/demo"
    assert api.username == "admin"
コード例 #9
0
ファイル: test_api.py プロジェクト: davidhuser/dhis2.py
def api():
    return Api(BASEURL, "admin", "district")
コード例 #10
0
def test_session():
    api = Api("https://play.dhis2.org/demo", "admin", "district")
    assert isinstance(api.session, requests.Session)
コード例 #11
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_base_url_api_version_below_25():
    with pytest.raises(exceptions.ClientException):
        Api('https://play.dhis2.org/demo', 'admin', 'district', 24)
コード例 #12
0
def test_api_url(entered, expected):
    api = Api(entered, "admin", "district")
    assert api.base_url == expected
    assert api.username == "admin"
    assert "{}/api".format(api.base_url) == "{}/api".format(expected)
コード例 #13
0
def test_base_url_api_version_below_25():
    with pytest.raises(exceptions.ClientException):
        Api("https://play.dhis2.org/demo", "admin", "district", 24)
コード例 #14
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_base_url_api_version():
    api = Api('https://play.dhis2.org/demo', 'admin', 'district', 30)
    assert api.api_url == 'https://play.dhis2.org/demo/api/30'
    assert api.username == 'admin'
コード例 #15
0
def test_base_url_api_version_non_integer():
    with pytest.raises(exceptions.ClientException):
        Api("https://play.dhis2.org/demo", "admin", "district", "123notanumber")
コード例 #16
0
def test_base_url_api_version():
    api = Api("https://play.dhis2.org/demo", "admin", "district", 30)
    assert api.api_url == "https://play.dhis2.org/demo/api/30"
    assert api.username == "admin"
コード例 #17
0
def test_base_url_with_api():
    with pytest.raises(exceptions.ClientException):
        Api("https://play.dhis2.org/demo/api", "admin", "district")
コード例 #18
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_api_url(entered, expected):
    api = Api(entered, 'admin', 'district')
    assert api.base_url == expected
    assert api.username == 'admin'
    assert '{}/api'.format(api.base_url) == '{}/api'.format(expected)
コード例 #19
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_user_agent_not_set():
    api = Api('https://play.dhis2.org/demo', 'admin', 'district', 30)
    assert 'user-agent' in api.session.headers and api.session.headers[
        'user-agent']
コード例 #20
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_base_url_with_api():
    with pytest.raises(exceptions.ClientException):
        Api('https://play.dhis2.org/demo/api', 'admin', 'district')
コード例 #21
0
def test_str():
    api = Api("https://play.dhis2.org/demo", "admin", "district")
    assert str(api).startswith("DHIS2")
コード例 #22
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_base_url_api_version_non_integer():
    with pytest.raises(exceptions.ClientException):
        Api('https://play.dhis2.org/demo', 'admin', 'district',
            '123notanumber')
コード例 #23
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_from_auth_file_not_named(auth_file):
    tmp = tempfile.gettempdir()
    filename = os.path.join(tmp, 'auth_test.json')
    api = Api.from_auth_file(filename)
    assert api.base_url == 'https://play.dhis2.org/demo'
    assert api.username == 'admin'
コード例 #24
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def api():
    return Api(BASEURL, 'admin', 'district')
コード例 #25
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_from_auth_file_not_valid(auth_file_invalid):
    with pytest.raises(exceptions.ClientException):
        tmp = tempfile.gettempdir()
        filename = os.path.join(tmp, 'auth_test_invalid.json')
        Api.from_auth_file(location=filename)
コード例 #26
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_session():
    api = Api('https://play.dhis2.org/demo', 'admin', 'district')
    assert isinstance(api.session, requests.Session)
コード例 #27
0
ファイル: test_dhis.py プロジェクト: gkumar08021/dhis2.py
def test_from_auth_file_in_home(auth_file_home):
    api = Api.from_auth_file()
    assert api.base_url == 'https://play.dhis2.org/demo'
    assert api.username == 'admin'
コード例 #28
0
ファイル: test_api.py プロジェクト: davidhuser/dhis2.py
def api_with_api_version():
    return Api(BASEURL, "admin", "district", api_version=30)
コード例 #29
0
def test_user_agent_not_set():
    api = Api("https://play.dhis2.org/demo", "admin", "district", 30)
    assert "user-agent" in api.session.headers and api.session.headers["user-agent"]