Skip to content

Commit

Permalink
vdk-notebook: remove rest_api from tests (#2336)
Browse files Browse the repository at this point in the history
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 [hduygu@vmware.com](mailto:hduygu@vmware.com)
  • Loading branch information
duyguHsnHsn committed Jun 28, 2023
1 parent c3fa77e commit 0918a53
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 105 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "c635d290-99d5-4354-b95c-a3210e4cf6e1",
"metadata": {
"tags": [
"vdk"
]
},
"outputs": [],
"source": [
"import requests"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -49,11 +35,19 @@
"metadata": {
"tags": [
"vdk"
]
],
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"response = requests.get(\"https://jsonplaceholder.typicode.com/todos/1\")"
"payload = {\n",
" \"userId\": 1,\n",
" \"id\": 1,\n",
" \"title\": \"delectus aut autem\",\n",
" \"completed\": False\n",
" }"
]
},
{
Expand All @@ -71,20 +65,6 @@
"hello1 = hello + 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f04c82ad-b8df-484e-9903-e064d61ca5c5",
"metadata": {
"tags": [
"vdk"
]
},
"outputs": [],
"source": [
"payload = response.json()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,22 @@
"metadata": {
"tags": [
"vdk"
]
],
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"response = requests.get(\"https://jsonplaceholder.typicode.com/todos/1\")\n",
"payload = {\n",
" \"userId\": 1,\n",
" \"id\": 1,\n",
" \"title\": \"delectus aut autem\",\n",
" \"completed\": False\n",
" }\n",
"ss"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "211b1800-6699-49c0-83bc-fe6d9878adcf",
"metadata": {
"tags": [
"vdk"
]
},
"outputs": [],
"source": [
"payload = response.json()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "c635d290-99d5-4354-b95c-a3210e4cf6e1",
"metadata": {
"pycharm": {
"name": "#%%\n"
},
"tags": [
"vdk"
]
},
"outputs": [],
"source": [
"import requests"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -58,25 +41,19 @@
"metadata": {
"tags": [
"vdk"
]
},
"outputs": [],
"source": [
"response = requests.get(\"https://jsonplaceholder.typicode.com/todos/1\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "654db028-2d0e-4f95-a377-e1fac1255f08",
"metadata": {
"tags": [
"vdk"
]
],
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"payload = response.json()"
"payload = {\n",
" \"userId\": 1,\n",
" \"id\": 1,\n",
" \"title\": \"delectus aut autem\",\n",
" \"completed\": False\n",
" }"
]
},
{
Expand All @@ -86,7 +63,10 @@
"metadata": {
"tags": [
"vdk"
]
],
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,26 @@
"job_input.execute_query(\"CREATE TABLE rest_target_table (userId, id, title, completed);\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "40c5181f-7a29-4842-b3f4-d1258522c83c",
"metadata": {
"tags": [
"vdk"
]
},
"outputs": [],
"source": [
"response = requests.get(\"https://jsonplaceholder.typicode.com/todos/1\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "654db028-2d0e-4f95-a377-e1fac1255f08",
"metadata": {
"tags": [
"vdk"
]
],
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"payload = response.json()"
"payload = {\n",
" \"userId\": 1,\n",
" \"id\": 1,\n",
" \"title\": \"delectus aut autem\",\n",
" \"completed\": False\n",
" }"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# Copyright 2021-2023 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0
import requests


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

job_input.send_object_for_ingestion(
payload=payload, destination_table="rest_target_table"
Expand Down
10 changes: 5 additions & 5 deletions projects/vdk-plugins/vdk-notebook/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setUp(self) -> None:

def test_successful_job(self) -> None:
result: Result = self.__runner.invoke(
["run", jobs_path_from_caller_directory("rest-api-job")]
["run", jobs_path_from_caller_directory("ingest-job")]
)
cli_assert_equal(0, result)
actual_rs: Result = self.__runner.invoke(
Expand All @@ -39,25 +39,25 @@ def test_successful_job(self) -> None:

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

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

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

def test_mixed_job_with_py_and_sql(self) -> None:
result: Result = self.__runner.invoke(
["run", jobs_path_from_caller_directory("mixed-rest-api")]
["run", jobs_path_from_caller_directory("mixed-job")]
)
cli_assert_equal(0, result)
actual_rs: Result = self.__runner.invoke(
Expand Down

0 comments on commit 0918a53

Please sign in to comment.