Skip to content

Commit

Permalink
Add first test for run command
Browse files Browse the repository at this point in the history
  • Loading branch information
sultaniman committed Mar 18, 2024
1 parent e48bfba commit 4ac727c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/cli/test_run_command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import io
import os
import contextlib
import pytest
import logging
from subprocess import CalledProcessError

import dlt
from dlt.common.runners.venv import Venv
from dlt.common.storages.file_storage import FileStorage

from dlt.cli import echo, run_command

from tests.utils import TESTS_ROOT

DEPLOY_PIPELINE = TESTS_ROOT / "cli/cases/deploy_pipeline"
DUMMY_PIPELINE = DEPLOY_PIPELINE / "dummy_pipeline.py"


def test_run_command_requires_working_directory_same_as_pipeline_working_directory(tmp_path):
with io.StringIO() as buf, contextlib.redirect_stdout(buf):
run_command.run_pipeline_command(
str(DUMMY_PIPELINE),
"p",
"example_resource",
None,
["write_disposition=merge", "loader_file_format=jsonl"],
)

output = buf.getvalue()
assert "WARNING: Current working directory is different from the pipeline script" in output
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import dataclasses
import logging
from pathlib import Path
from typing import List

# patch which providers to enable
Expand Down
2 changes: 2 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import multiprocessing
import os
from pathlib import Path
import platform
import sys
from os import environ
Expand Down Expand Up @@ -29,6 +30,7 @@
from dlt.common.pipeline import PipelineContext, SupportsPipeline

TEST_STORAGE_ROOT = "_storage"
TESTS_ROOT = Path(__file__).parent.absolute()


# destination constants
Expand Down

0 comments on commit 4ac727c

Please sign in to comment.