我试图在下面的虚拟方法中模拟一个链式Django模型对象,
# utils.py
def foo_something_exist():
if Foo.objects.get(a='something').exist():
return 'exist'
# test.py
import unittest.mock import patch
import utils
.
.
.
@patch('utils.Foo')
def test_foo_something_exist_returns_none(self, mock_foo):
mock_foo.objects.get.exists.return_value = False
self.assertIsNone(utils.foo_something_exist())
.
.
.
Run Code Online (Sandbox Code Playgroud)
test_foo_something_exist()没有通过测试.我发现Foo.objects.get(a='something').exist()在utils.py中是一个MagicMock对象(<MagicMock name='Member.objects.get().exists()' id='xxxxxx'>)而不是False,这导致了这个测试函数的失败.是的,我也尝试过mock_foo.objects.return_value.get.return_value.exists.return_value = False,在帖子中提到过.正确模拟模型对象(使用其链式方法)的指针/提示是值得赞赏的.
先感谢您.
似乎waterline-mysql不允许创建复合主键.
有没有办法解决它,因为我在现有数据库的顶部构建应用程序?
我正在使用fullpage.js创建全屏页面。如果滚动到下一部分,然后滚动回到第一部分(带有视频背景和覆盖文字),则文本会短暂“隐藏”在视频后面,然后再次显示。到目前为止,此问题仅在我的Chrome(版本49.0.2623.112)上发生。
HTML:
<div id="fullpage">
<div class="section">
<div class="text">1233123123</div>
<div class="video-background">
<video autoplay muted loop>
<source data-src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"/>
</video>
</div>
</div>
<div class="section">
<div class="slide" data-anchor="slide1">
<img src="" data-src="https://raw.githubusercontent.com/alvarotrigo/fullPage.js/master/examples/imgs/iphone-blue.png" />
</div>
<div class="slide" data-anchor="slide2">Two 2</div>
</div>
<div class="section">
<img src="" data-src="https://raw.githubusercontent.com/alvarotrigo/fullPage.js/master/examples/imgs/intro.png" />
</div>
<div class="section">Four</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.section {
text-align:center;
font-size: 3em;
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.text {
font-size: 123px;
z-index: 2;
position: absolute;
margin: 0 auto;
background-color: red;
}
div.video-background {
position: absolute;
top: 0;
left: …Run Code Online (Sandbox Code Playgroud) javascript ×2
css ×1
django ×1
fullpage.js ×1
jquery ×1
mysql ×1
python ×1
python-3.5 ×1
python-3.x ×1
sails.js ×1
unit-testing ×1
waterline ×1