Skip to content

Commit 0918a53

Browse files
authored
vdk-notebook: remove rest_api from tests (#2336)
What: modified the jobs used in vdk-notebook tests so they do not use rest api anymore Why: The build on main is failing: https://gitlab.com/vmware-analytics/versatile-data-kit/-/jobs/4555592828. It is failing to make a request to the url https://jsonplaceholder.typicode.com/todos/1 with a 403 error Signed-off-by: Duygu Hasan [[email protected]](mailto:[email protected])
1 parent c3fa77e commit 0918a53

File tree

18 files changed

+50
-105
lines changed

18 files changed

+50
-105
lines changed

Diff for: projects/vdk-plugins/vdk-notebook/tests/jobs/rest-api-job-code-error/steps.ipynb renamed to projects/vdk-plugins/vdk-notebook/tests/jobs/ingest-job-code-error/steps.ipynb

+10-30
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
{
22
"cells": [
3-
{
4-
"cell_type": "code",
5-
"execution_count": null,
6-
"id": "c635d290-99d5-4354-b95c-a3210e4cf6e1",
7-
"metadata": {
8-
"tags": [
9-
"vdk"
10-
]
11-
},
12-
"outputs": [],
13-
"source": [
14-
"import requests"
15-
]
16-
},
173
{
184
"cell_type": "code",
195
"execution_count": null,
@@ -49,11 +35,19 @@
4935
"metadata": {
5036
"tags": [
5137
"vdk"
52-
]
38+
],
39+
"pycharm": {
40+
"name": "#%%\n"
41+
}
5342
},
5443
"outputs": [],
5544
"source": [
56-
"response = requests.get(\"https://jsonplaceholder.typicode.com/todos/1\")"
45+
"payload = {\n",
46+
" \"userId\": 1,\n",
47+
" \"id\": 1,\n",
48+
" \"title\": \"delectus aut autem\",\n",
49+
" \"completed\": False\n",
50+
" }"
5751
]
5852
},
5953
{
@@ -71,20 +65,6 @@
7165
"hello1 = hello + 1"
7266
]
7367
},
74-
{
75-
"cell_type": "code",
76-
"execution_count": null,
77-
"id": "f04c82ad-b8df-484e-9903-e064d61ca5c5",
78-
"metadata": {
79-
"tags": [
80-
"vdk"
81-
]
82-
},
83-
"outputs": [],
84-
"source": [
85-
"payload = response.json()"
86-
]
87-
},
8868
{
8969
"cell_type": "code",
9070
"execution_count": null,

Diff for: projects/vdk-plugins/vdk-notebook/tests/jobs/rest-api-job-fail-syntax-error/steps.ipynb renamed to projects/vdk-plugins/vdk-notebook/tests/jobs/ingest-job-fail-syntax-error/steps.ipynb

+10-16
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,22 @@
4949
"metadata": {
5050
"tags": [
5151
"vdk"
52-
]
52+
],
53+
"pycharm": {
54+
"name": "#%%\n"
55+
}
5356
},
5457
"outputs": [],
5558
"source": [
56-
"response = requests.get(\"https://jsonplaceholder.typicode.com/todos/1\")\n",
59+
"payload = {\n",
60+
" \"userId\": 1,\n",
61+
" \"id\": 1,\n",
62+
" \"title\": \"delectus aut autem\",\n",
63+
" \"completed\": False\n",
64+
" }\n",
5765
"ss"
5866
]
5967
},
60-
{
61-
"cell_type": "code",
62-
"execution_count": null,
63-
"id": "211b1800-6699-49c0-83bc-fe6d9878adcf",
64-
"metadata": {
65-
"tags": [
66-
"vdk"
67-
]
68-
},
69-
"outputs": [],
70-
"source": [
71-
"payload = response.json()"
72-
]
73-
},
7468
{
7569
"cell_type": "code",
7670
"execution_count": null,

Diff for: projects/vdk-plugins/vdk-notebook/tests/jobs/rest-api-job-sql-error/steps.ipynb renamed to projects/vdk-plugins/vdk-notebook/tests/jobs/ingest-job-sql-error/steps.ipynb

+14-34
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
{
22
"cells": [
3-
{
4-
"cell_type": "code",
5-
"execution_count": null,
6-
"id": "c635d290-99d5-4354-b95c-a3210e4cf6e1",
7-
"metadata": {
8-
"pycharm": {
9-
"name": "#%%\n"
10-
},
11-
"tags": [
12-
"vdk"
13-
]
14-
},
15-
"outputs": [],
16-
"source": [
17-
"import requests"
18-
]
19-
},
203
{
214
"cell_type": "code",
225
"execution_count": null,
@@ -58,25 +41,19 @@
5841
"metadata": {
5942
"tags": [
6043
"vdk"
61-
]
62-
},
63-
"outputs": [],
64-
"source": [
65-
"response = requests.get(\"https://jsonplaceholder.typicode.com/todos/1\")"
66-
]
67-
},
68-
{
69-
"cell_type": "code",
70-
"execution_count": null,
71-
"id": "654db028-2d0e-4f95-a377-e1fac1255f08",
72-
"metadata": {
73-
"tags": [
74-
"vdk"
75-
]
44+
],
45+
"pycharm": {
46+
"name": "#%%\n"
47+
}
7648
},
7749
"outputs": [],
7850
"source": [
79-
"payload = response.json()"
51+
"payload = {\n",
52+
" \"userId\": 1,\n",
53+
" \"id\": 1,\n",
54+
" \"title\": \"delectus aut autem\",\n",
55+
" \"completed\": False\n",
56+
" }"
8057
]
8158
},
8259
{
@@ -86,7 +63,10 @@
8663
"metadata": {
8764
"tags": [
8865
"vdk"
89-
]
66+
],
67+
"pycharm": {
68+
"name": "#%%\n"
69+
}
9070
},
9171
"outputs": [],
9272
"source": [

Diff for: projects/vdk-plugins/vdk-notebook/tests/jobs/rest-api-job/steps.ipynb renamed to projects/vdk-plugins/vdk-notebook/tests/jobs/ingest-job/steps.ipynb

+10-16
Original file line numberDiff line numberDiff line change
@@ -51,32 +51,26 @@
5151
"job_input.execute_query(\"CREATE TABLE rest_target_table (userId, id, title, completed);\")"
5252
]
5353
},
54-
{
55-
"cell_type": "code",
56-
"execution_count": null,
57-
"id": "40c5181f-7a29-4842-b3f4-d1258522c83c",
58-
"metadata": {
59-
"tags": [
60-
"vdk"
61-
]
62-
},
63-
"outputs": [],
64-
"source": [
65-
"response = requests.get(\"https://jsonplaceholder.typicode.com/todos/1\")"
66-
]
67-
},
6854
{
6955
"cell_type": "code",
7056
"execution_count": null,
7157
"id": "654db028-2d0e-4f95-a377-e1fac1255f08",
7258
"metadata": {
7359
"tags": [
7460
"vdk"
75-
]
61+
],
62+
"pycharm": {
63+
"name": "#%%\n"
64+
}
7665
},
7766
"outputs": [],
7867
"source": [
79-
"payload = response.json()"
68+
"payload = {\n",
69+
" \"userId\": 1,\n",
70+
" \"id\": 1,\n",
71+
" \"title\": \"delectus aut autem\",\n",
72+
" \"completed\": False\n",
73+
" }"
8074
]
8175
},
8276
{

Diff for: projects/vdk-plugins/vdk-notebook/tests/jobs/mixed-rest-api/30_rest_ingest.py renamed to projects/vdk-plugins/vdk-notebook/tests/jobs/mixed-job/30_ingest.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
# Copyright 2021-2023 VMware, Inc.
22
# SPDX-License-Identifier: Apache-2.0
3-
import requests
43

54

65
def run(job_input):
7-
response = requests.get("https://jsonplaceholder.typicode.com/todos/1")
8-
response.raise_for_status()
9-
payload = response.json()
6+
payload = {"userId": 1, "id": 1, "title": "delectus aut autem", "completed": False}
107

118
job_input.send_object_for_ingestion(
129
payload=payload, destination_table="rest_target_table"

Diff for: projects/vdk-plugins/vdk-notebook/tests/test_plugin.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def setUp(self) -> None:
2525

2626
def test_successful_job(self) -> None:
2727
result: Result = self.__runner.invoke(
28-
["run", jobs_path_from_caller_directory("rest-api-job")]
28+
["run", jobs_path_from_caller_directory("ingest-job")]
2929
)
3030
cli_assert_equal(0, result)
3131
actual_rs: Result = self.__runner.invoke(
@@ -39,25 +39,25 @@ def test_successful_job(self) -> None:
3939

4040
def test_failing_job_with_syntax_error(self) -> None:
4141
result: Result = self.__runner.invoke(
42-
["run", jobs_path_from_caller_directory("rest-api-job-fail-syntax-error")]
42+
["run", jobs_path_from_caller_directory("ingest-job-fail-syntax-error")]
4343
)
4444
cli_assert_equal(1, result)
4545

4646
def test_failing_job_with_code_error(self) -> None:
4747
result: Result = self.__runner.invoke(
48-
["run", jobs_path_from_caller_directory("rest-api-job-fail-code-error")]
48+
["run", jobs_path_from_caller_directory("ingest-job-fail-code-error")]
4949
)
5050
cli_assert_equal(2, result)
5151

5252
def test_failing_job_with_sql_error(self) -> None:
5353
result: Result = self.__runner.invoke(
54-
["run", jobs_path_from_caller_directory("rest-api-job-sql-error")]
54+
["run", jobs_path_from_caller_directory("ingest-job-sql-error")]
5555
)
5656
cli_assert_equal(1, result)
5757

5858
def test_mixed_job_with_py_and_sql(self) -> None:
5959
result: Result = self.__runner.invoke(
60-
["run", jobs_path_from_caller_directory("mixed-rest-api")]
60+
["run", jobs_path_from_caller_directory("mixed-job")]
6161
)
6262
cli_assert_equal(0, result)
6363
actual_rs: Result = self.__runner.invoke(

0 commit comments

Comments
 (0)