本文整理汇总了Python中staticgenerator.StaticGenerator.publish方法的典型用法代码示例。如果您正苦于以下问题:Python StaticGenerator.publish方法的具体用法?Python StaticGenerator.publish怎么用?Python StaticGenerator.publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类staticgenerator.StaticGenerator
的用法示例。
在下文中一共展示了StaticGenerator.publish方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_publish_loops_through_all_resources
# 需要导入模块: from staticgenerator import StaticGenerator [as 别名]
# 或者: from staticgenerator.StaticGenerator import publish [as 别名]
def test_publish_loops_through_all_resources(self):
instance = StaticGenerator('/some_path_1', '/some_path_2')
rename = Mock(wraps=os.rename)
with nested(patch('os.rename', rename),
patch.object(instance, 'get_content_from_path',
Mock(return_value='some_content'))):
instance.publish()
rename.assert_has_calls([
call(ANY, 'test_web_root/fresh/some_path_1'),
call(ANY, 'test_web_root/fresh/some_path_2')])
示例2: test_publish_loops_through_all_resources
# 需要导入模块: from staticgenerator import StaticGenerator [as 别名]
# 或者: from staticgenerator.StaticGenerator import publish [as 别名]
def test_publish_loops_through_all_resources():
mox = Mox()
http_request, model_base, manager, model, queryset = get_mocks(mox)
fs_mock = mox.CreateMockAnything()
f = mox.CreateMockAnything()
fs_mock.join('test_web_root', 'some_path_1/index.html').AndReturn('test_web_root/some_path_1')
fs_mock.dirname('test_web_root/some_path_1').AndReturn('test_web_root')
fs_mock.exists("test_web_root").AndReturn(True)
filename = "some_temp_file"
fs_mock.tempfile(directory="test_web_root").AndReturn([f, filename])
fs_mock.write(f, "some_content")
fs_mock.close(f)
fs_mock.chmod(filename, stat.S_IREAD | stat.S_IWRITE | stat.S_IWUSR | stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
fs_mock.rename('some_temp_file', 'test_web_root/some_path_1')
fs_mock.join('test_web_root', 'some_path_2/index.html').AndReturn('test_web_root/some_path_2')
fs_mock.dirname('test_web_root/some_path_2').AndReturn('test_web_root')
fs_mock.exists("test_web_root").AndReturn(True)
filename = "some_temp_file"
fs_mock.tempfile(directory="test_web_root").AndReturn([f, filename])
fs_mock.write(f, "some_content")
fs_mock.close(f)
fs_mock.chmod(filename, stat.S_IREAD | stat.S_IWRITE | stat.S_IWUSR | stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
fs_mock.rename('some_temp_file', 'test_web_root/some_path_2')
settings = CustomSettings(WEB_ROOT="test_web_root")
mox.ReplayAll()
try:
get_content_from_path = StaticGenerator.get_content_from_path
StaticGenerator.get_content_from_path = lambda self, path: "some_content"
instance = StaticGenerator("some_path_1", "some_path_2",
http_request=http_request,
model_base=model_base,
manager=manager,
model=model,
queryset=queryset,
settings=settings,
fs=fs_mock)
instance.publish()
mox.VerifyAll()
finally:
StaticGenerator.get_content_from_path = get_content_from_path