Skip to content

Commit

Permalink
increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketmaurya committed Sep 26, 2024
1 parent ec3bc5a commit 0924e54
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/test_docker_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest

import litserve as ls
from litserve import docker_builder

Expand Down Expand Up @@ -42,14 +44,19 @@ def test_color():
def test_build(tmp_path, monkeypatch):
with open(tmp_path / "app.py", "w") as f:
f.write("print('hello')")
with open(tmp_path / "requirements.txt", "w") as f:
f.write("lightning")

# Temporarily change the current working directory to tmp_path
monkeypatch.chdir(tmp_path)

docker_builder.build("app.py", 8000)
with pytest.warns(UserWarning, match="Make sure to install the required packages in the Dockerfile."):
docker_builder.build("app.py", 8000)

with open(tmp_path / "requirements.txt", "w") as f:
f.write("lightning")
docker_builder.build("app.py", 8000)
with open("Dockerfile") as f:
content = f.read()
assert content == EXPECTED_CONENT

with pytest.raises(FileNotFoundError, match="must be in the current directory"):
docker_builder.build("random_file_name.py", 8000)

0 comments on commit 0924e54

Please sign in to comment.