blob: 947a83235593db1f60c3a9a83cc224684d071afc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function
from contextlib import contextmanager
import os
import shutil
import tempfile
import unittest
from context import nikola
@contextmanager
def cd(path):
old_dir = os.getcwd()
os.chdir(path)
yield
os.chdir(old_dir)
class IntegrationTest(unittest.TestCase):
"""Basic integration testcase."""
def setUp(self):
"""Setup a demo site."""
self.tmpdir = tempfile.mkdtemp()
self.target_dir = os.path.join(self.tmpdir, "target")
self.build_command = nikola.plugins.command_build.CommandBuild()
self.init_command = nikola.plugins.command_init.CommandInit()
self.init_command.copy_sample_site(self.target_dir)
self.init_command.create_configuration(self.target_dir)
self.patch_site()
self.build()
def patch_site(self):
"""Make any modifications you need to the site."""
pass
def build(self):
"""Build the site."""
with cd(self.target_dir):
self.build_command.run()
def tearDown(self):
"""Reove the demo site."""
shutil.rmtree(self.tmpdir)
class EmptytBuild(IntegrationTest):
"""Basic integration testcase."""
def setUp(self):
"""Setup a demo site."""
self.tmpdir = tempfile.mkdtemp()
self.target_dir = os.path.join(self.tmpdir, "target")
self.build_command = nikola.plugins.command_build.CommandBuild()
self.init_command = nikola.plugins.command_init.CommandInit()
self.init_command.create_empty_site(self.target_dir)
self.init_command.create_configuration(self.target_dir)
self.patch_site()
self.build()
def test_deleted_dodo(self):
"""Test that a default build of --demo works."""
# Ensure the temprary dodo file is deleted (Issue #302)
self.assertFalse(os.path.isfile(self.build_command.dodo.name))
class DefaultBuild(IntegrationTest):
"""Test that a default build of --demo works."""
def test_deleted_dodo(self):
"""Test that a default build of --demo works."""
# Ensure the temprary dodo file is deleted (Issue #302)
self.assertFalse(os.path.isfile(self.build_command.dodo.name))
|