Skip to content

Commit

Permalink
Fix tests & add proper req
Browse files Browse the repository at this point in the history
  • Loading branch information
ericholscher committed Dec 16, 2015
1 parent 4c8bef9 commit 36db0d0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
3 changes: 2 additions & 1 deletion readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ class UpdateDocsTask(Task):
default_retry_delay = (7 * 60)
name = 'update_docs'

def __init__(self, build_env=None, force=False, search=True, localmedia=True,
def __init__(self, build_env=None, python_env=None, force=False, search=True, localmedia=True,
build=None, project=None, version=None):
self.build_env = build_env
self.python_env = python_env
self.build_force = force
self.build_search = search
self.build_localmedia = localmedia
Expand Down
34 changes: 21 additions & 13 deletions readthedocs/rtd_tests/tests/test_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from readthedocs.projects.models import Project
from readthedocs.doc_builder.environments import LocalEnvironment
from readthedocs.doc_builder.python_environments import Virtualenv
from readthedocs.doc_builder.loader import get_builder_class
from readthedocs.projects.tasks import UpdateDocsTask

Expand Down Expand Up @@ -39,9 +40,10 @@ def test_build(self):
self.mocks.patches['html_build'].stop()

build_env = LocalEnvironment(project=project, version=version, build={})
task = UpdateDocsTask(build_env=build_env, version=version,
python_env = Virtualenv(project=project, version=version, build_env=build_env)
task = UpdateDocsTask(build_env=build_env, python_env=python_env, version=version,
project=project, search=False, localmedia=False)
built_docs = task.build_docs()
task.build_docs()

# Get command and check first part of command list is a call to sphinx
self.assertEqual(self.mocks.popen.call_count, 1)
Expand All @@ -61,9 +63,10 @@ def test_build_respects_pdf_flag(self):
version = project.versions.all()[0]

build_env = LocalEnvironment(project=project, version=version, build={})
task = UpdateDocsTask(build_env=build_env, version=version,
python_env = Virtualenv(project=project, version=version, build_env=build_env)
task = UpdateDocsTask(build_env=build_env, python_env=python_env, version=version,
project=project, search=False, localmedia=False)
built_docs = task.build_docs()
task.build_docs()

# The HTML and the Epub format were built.
self.mocks.html_build.assert_called_once_with()
Expand All @@ -83,9 +86,10 @@ def test_build_respects_epub_flag(self):
version = project.versions.all()[0]

build_env = LocalEnvironment(project=project, version=version, build={})
task = UpdateDocsTask(build_env=build_env, project=project,
version=version, search=False, localmedia=False)
built_docs = task.build_docs()
python_env = Virtualenv(project=project, version=version, build_env=build_env)
task = UpdateDocsTask(build_env=build_env, python_env=python_env, version=version,
project=project, search=False, localmedia=False)
task.build_docs()

# The HTML and the Epub format were built.
self.mocks.html_build.assert_called_once_with()
Expand All @@ -101,8 +105,9 @@ def test_builder_comments(self):
versions=[fixture()])
version = project.versions.all()[0]
build_env = LocalEnvironment(version=version, project=project, build={})
python_env = Virtualenv(project=project, version=version, build_env=build_env)
builder_class = get_builder_class(project.documentation_type)
builder = builder_class(build_env)
builder = builder_class(build_env, python_env)
self.assertEqual(builder.sphinx_builder, 'readthedocs-comments')

def test_builder_no_comments(self):
Expand All @@ -113,8 +118,9 @@ def test_builder_no_comments(self):
versions=[fixture()])
version = project.versions.all()[0]
build_env = LocalEnvironment(version=version, project=project, build={})
python_env = Virtualenv(project=project, version=version, build_env=build_env)
builder_class = get_builder_class(project.documentation_type)
builder = builder_class(build_env)
builder = builder_class(build_env, python_env)
self.assertEqual(builder.sphinx_builder, 'readthedocs')

def test_build_pdf_latex_failures(self):
Expand All @@ -133,7 +139,8 @@ def test_build_pdf_latex_failures(self):
assert project.conf_dir() == '/tmp/rtd'

build_env = LocalEnvironment(project=project, version=version, build={})
task = UpdateDocsTask(build_env=build_env, project=project,
python_env = Virtualenv(project=project, version=version, build_env=build_env)
task = UpdateDocsTask(build_env=build_env, project=project, python_env=python_env,
version=version, search=False, localmedia=False)

# Mock out the separate calls to Popen using an iterable side_effect
Expand All @@ -152,7 +159,7 @@ def test_build_pdf_latex_failures(self):
self.mocks.popen.return_value = mock_obj

with build_env:
built_docs = task.build_docs()
task.build_docs()
self.assertEqual(self.mocks.popen.call_count, 5)
self.assertTrue(build_env.failed)

Expand All @@ -172,7 +179,8 @@ def test_build_pdf_latex_not_failure(self):
assert project.conf_dir() == '/tmp/rtd'

build_env = LocalEnvironment(project=project, version=version, build={})
task = UpdateDocsTask(build_env=build_env, project=project,
python_env = Virtualenv(project=project, version=version, build_env=build_env)
task = UpdateDocsTask(build_env=build_env, project=project, python_env=python_env,
version=version, search=False, localmedia=False)

# Mock out the separate calls to Popen using an iterable side_effect
Expand All @@ -191,6 +199,6 @@ def test_build_pdf_latex_not_failure(self):
self.mocks.popen.return_value = mock_obj

with build_env:
built_docs = task.build_docs()
task.build_docs()
self.assertEqual(self.mocks.popen.call_count, 5)
self.assertTrue(build_env.successful)
1 change: 1 addition & 0 deletions requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ nilsimsa==0.3.7
git+https://github.com/alex/django-filter.git#egg=django-filter
git+https://github.com/ericflo/django-pagination.git@e5f669036c#egg=django_pagination-dev
git+https://github.com/alex/django-taggit.git#egg=django_taggit-dev
git+https://github.com/rtfd/readthedocs-build.git@e0f578eb3ad#egg=readthedocs_build

0 comments on commit 36db0d0

Please sign in to comment.