示例#1
0
        def test_token_right_create_dataset_rights(self):
            BASE_URL = os.getenv("BASE_URL")
            api_su = NativeApi(BASE_URL, os.getenv("API_TOKEN_SUPERUSER"))
            api_nru = NativeApi(BASE_URL,
                                os.getenv("API_TOKEN_TEST_NO_RIGHTS"))

            resp = api_su.get_info_version()
            assert resp.json()["data"]["version"] == "4.15.1"
            assert resp.json()["data"]["build"] == "1377-701b56b"
            resp = api_nru.get_info_version()
            assert resp.json()["data"]["version"] == "4.15.1"
            assert resp.json()["data"]["build"] == "1377-701b56b"

            ds = Dataset()
            ds.from_json(
                read_file(
                    os.path.join(
                        BASE_DIR,
                        "tests/data/dataset_upload_min_default.json")))
            resp = api_su.create_dataset(":root", ds.json())
            pid = resp.json()["data"]["persistentId"]
            assert resp.json()["status"] == "OK"

            with pytest.raises(ApiAuthorizationError):
                resp = api_nru.get_dataset(pid)

            resp = api_su.delete_dataset(pid)
            assert resp.json()["status"] == "OK"
示例#2
0
        def test_token_empty_string(self):
            BASE_URL = os.getenv("BASE_URL")
            api = NativeApi(BASE_URL, "")
            resp = api.get_info_version()
            assert resp.json()["data"]["version"] == "4.18.1"
            assert resp.json()["data"]["build"] == "267-a91d370"

            with pytest.raises(ApiAuthorizationError):
                ds = Dataset()
                ds.from_json(
                    read_file(
                        os.path.join(
                            BASE_DIR,
                            "tests/data/dataset_upload_min_default.json")))
                api.create_dataset(":root", ds.json())
示例#3
0
        def test_token_no_rights(self):
            BASE_URL = os.getenv("BASE_URL")
            API_TOKEN = os.getenv("API_TOKEN_NO_RIGHTS")
            api = NativeApi(BASE_URL, API_TOKEN)
            resp = api.get_info_version()
            assert resp.json()["data"]["version"] == "4.15.1"
            assert resp.json()["data"]["build"] == "1377-701b56b"

            with pytest.raises(ApiAuthorizationError):
                ds = Dataset()
                ds.from_json(
                    read_file(
                        os.path.join(
                            BASE_DIR,
                            "tests/data/dataset_upload_min_default.json")))
                api.create_dataset(":root", ds.json())