Skip to content

Commit 76ab170

Browse files
committed
Initial attempt to write a test case
1 parent be8b5d7 commit 76ab170

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

readthedocs/projects/tests/test_build_tasks.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import pathlib
33
import textwrap
4+
import uuid
45
from unittest import mock
56

67
import django_dynamic_fixture as fixture
@@ -261,7 +262,8 @@ def test_build_respects_formats_mkdocs(self, build_docs_class, load_yaml_config)
261262
build_docs_class.assert_called_once_with("mkdocs") # HTML builder
262263

263264
@mock.patch("readthedocs.doc_builder.director.load_yaml_config")
264-
def test_build_updates_documentation_type(self, load_yaml_config):
265+
@mock.patch("readthedocs.projects.tasks.builds.shutil")
266+
def test_build_updates_documentation_type(self, load_yaml_config, shutilmock):
265267
assert self.version.documentation_type == "sphinx"
266268
load_yaml_config.return_value = get_build_config(
267269
{
@@ -282,7 +284,9 @@ def test_build_updates_documentation_type(self, load_yaml_config):
282284
pathlib.Path(
283285
os.path.join(
284286
self.project.artifact_path(version=self.version.slug, type_=f),
285-
f"{self.project.slug}.{f}",
287+
# Use a random name for the offline format.
288+
# We will automatically rename this file to filename El Proxito expects.
289+
f"{uuid.uuid4()}.{f}",
286290
)
287291
).touch()
288292

@@ -296,6 +300,8 @@ def test_build_updates_documentation_type(self, load_yaml_config):
296300

297301
self._trigger_update_docs_task()
298302

303+
shutilmock.move.assert_called_once_with("", "TEST")
304+
299305
# Update version state
300306
assert self.requests_mock.request_history[8]._request.method == "PATCH"
301307
assert self.requests_mock.request_history[8].path == "/api/v2/version/1/"

0 commit comments

Comments
 (0)