Skip to content

Commit be65517

Browse files
author
Bill Prin
committed
Fix only show 10 books test
The ordering of the output is unreliable in datstore and cloudsql. Also add one direction nox sessions to simplify local testing
1 parent df0ba0b commit be65517

File tree

8 files changed

+42
-25
lines changed

8 files changed

+42
-25
lines changed

2-structured-data/tests/test_crud.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import re
16+
1517
from conftest import flaky_filter
1618
from flaky import flaky
1719
import pytest
@@ -38,9 +40,8 @@ def test_list(self, app, model):
3840

3941
body = rv.data.decode('utf-8')
4042
assert 'Book 1' in body, "Should show books"
41-
# Ordering is lexical, so 9 will be on page two and 10 and 11 will
42-
# be after 1.
43-
assert 'Book 9' not in body, "Should not show more than 10 books"
43+
assert (len(re.findall('<h4>Book', body)) == 10,
44+
"Should not show more than 10 books")
4445
assert 'More' in body, "Should have more than one page"
4546

4647
def test_add(self, app):

3-binary-data/tests/test_crud.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import re
16+
1517
from conftest import flaky_filter
1618
from flaky import flaky
1719
import pytest
@@ -38,9 +40,8 @@ def test_list(self, app, model):
3840

3941
body = rv.data.decode('utf-8')
4042
assert 'Book 1' in body, "Should show books"
41-
# Ordering is lexical, so 9 will be on page two and 10 and 11 will
42-
# be after 1.
43-
assert 'Book 9' not in body, "Should not show more than 10 books"
43+
assert (len(re.findall('<h4>Book', body)) == 10,
44+
"Should not show more than 10 books")
4445
assert 'More' in body, "Should have more than one page"
4546

4647
def test_add(self, app):

4-auth/tests/test_crud.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import re
16+
1517
from conftest import flaky_filter
1618
from flaky import flaky
1719
import pytest
@@ -38,9 +40,8 @@ def test_list(self, app, model):
3840

3941
body = rv.data.decode('utf-8')
4042
assert 'Book 1' in body, "Should show books"
41-
# Ordering is lexical, so 9 will be on page two and 10 and 11 will
42-
# be after 1.
43-
assert 'Book 9' not in body, "Should not show more than 10 books"
43+
assert (len(re.findall('<h4>Book', body)) == 10,
44+
"Should not show more than 10 books")
4445
assert 'More' in body, "Should have more than one page"
4546

4647
def test_add(self, app):

5-logging/tests/test_crud.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import re
16+
1517
from conftest import flaky_filter
1618
from flaky import flaky
1719
import pytest
@@ -38,9 +40,8 @@ def test_list(self, app, model):
3840

3941
body = rv.data.decode('utf-8')
4042
assert 'Book 1' in body, "Should show books"
41-
# Ordering is lexical, so 9 will be on page two and 10 and 11 will
42-
# be after 1.
43-
assert 'Book 9' not in body, "Should not show more than 10 books"
43+
assert (len(re.findall('<h4>Book', body)) == 10,
44+
"Should not show more than 10 books")
4445
assert 'More' in body, "Should have more than one page"
4546

4647
def test_add(self, app):

6-pubsub/tests/test_crud.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import re
16+
1517
from conftest import flaky_filter
1618
from flaky import flaky
1719
import pytest
@@ -38,9 +40,8 @@ def test_list(self, app, model):
3840

3941
body = rv.data.decode('utf-8')
4042
assert 'Book 1' in body, "Should show books"
41-
# Ordering is lexical, so 9 will be on page two and 10 and 11 will
42-
# be after 1.
43-
assert 'Book 9' not in body, "Should not show more than 10 books"
43+
assert (len(re.findall('<h4>Book', body)) == 10,
44+
"Should not show more than 10 books")
4445
assert 'More' in body, "Should have more than one page"
4546

4647
def test_add(self, app):

7-gce/tests/test_crud.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import re
16+
1517
from conftest import flaky_filter
1618
from flaky import flaky
1719
import pytest
@@ -38,9 +40,8 @@ def test_list(self, app, model):
3840

3941
body = rv.data.decode('utf-8')
4042
assert 'Book 1' in body, "Should show books"
41-
# Ordering is lexical, so 9 will be on page two and 10 and 11 will
42-
# be after 1.
43-
assert 'Book 9' not in body, "Should not show more than 10 books"
43+
assert (len(re.findall('<h4>Book', body)) == 10,
44+
"Should not show more than 10 books")
4445
assert 'More' in body, "Should have more than one page"
4546

4647
def test_add(self, app):

nox.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import nox
55

6-
REPO_TOOLS_REQ =\
6+
REPO_TOOLS_REQ = \
77
'git+https://github.com/GoogleCloudPlatform/python-repo-tools.git'
88

99
DIRS = [
@@ -35,14 +35,24 @@ def session_lint(session):
3535
'--import-order-style=google', '.')
3636

3737

38-
@nox.parametrize('dir', DIRS)
39-
def session_run_tests(session, dir=None, toxargs=None):
40-
"""Run all tests for all directories (slow!)"""
38+
def run_test(session, dir, toxargs):
4139
shutil.copy('config.py', dir)
4240
session.chdir(dir)
4341
session.run('tox', *(toxargs or []))
4442

4543

44+
@nox.parametrize('dir', DIRS)
45+
def session_run_tests(session, dir=None, toxargs=None):
46+
"""Run all tests for all directories (slow!)"""
47+
run_test(session, dir, toxargs)
48+
49+
50+
def session_run_one_test(session):
51+
dir = session.posargs[0]
52+
toxargs = session.posargs[1:]
53+
run_test(session, dir, toxargs)
54+
55+
4656
@nox.parametrize('dir', DIRS)
4757
def session_travis(session, dir=None):
4858
"""On travis, only run the py3.4 and cloudsql tests."""

optional-container-engine/tests/test_crud.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import re
16+
1517
from conftest import flaky_filter
1618
from flaky import flaky
1719
import pytest
@@ -38,9 +40,8 @@ def test_list(self, app, model):
3840

3941
body = rv.data.decode('utf-8')
4042
assert 'Book 1' in body, "Should show books"
41-
# Ordering is lexical, so 9 will be on page two and 10 and 11 will
42-
# be after 1.
43-
assert 'Book 9' not in body, "Should not show more than 10 books"
43+
assert (len(re.findall('<h4>Book', body)) == 10,
44+
"Should not show more than 10 books")
4445
assert 'More' in body, "Should have more than one page"
4546

4647
def test_add(self, app):

0 commit comments

Comments
 (0)