Beispiel #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'
Beispiel #2
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"
Beispiel #3
0
def test_from_auth_file_not_found():
    kwargs = {}
    with override_environ(**kwargs) and pytest.raises(
            exceptions.ClientException):
        Api.from_auth_file('not_here.json')
Beispiel #4
0
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'
Beispiel #5
0
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)
Beispiel #6
0
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'
Beispiel #7
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"