Optimized the vehicles/ordnance report test.

master
Pacman Ghost 6 years ago
parent 13c5aec065
commit d8444cd03f
  1. 1
      setup.py
  2. 7
      vasl_templates/webapp/static/snippets.js
  3. 6
      vasl_templates/webapp/tests/fixtures/vo-reports/vehicles/russian/1940.txt
  4. 6
      vasl_templates/webapp/tests/fixtures/vo-reports/vehicles/russian/1941.txt
  5. 6
      vasl_templates/webapp/tests/fixtures/vo-reports/vehicles/russian/1942.txt
  6. 6
      vasl_templates/webapp/tests/fixtures/vo-reports/vehicles/russian/1943.txt
  7. 6
      vasl_templates/webapp/tests/fixtures/vo-reports/vehicles/russian/1944.txt
  8. 6
      vasl_templates/webapp/tests/fixtures/vo-reports/vehicles/russian/1945.txt
  9. 37
      vasl_templates/webapp/tests/test_vo_reports.py

@ -24,6 +24,7 @@ setup(
"pytest==3.6.0",
"tabulate==0.8.2",
"selenium==3.12.0",
"lxml==4.2.4",
"pylint==1.9.2",
"pytest-pylint==0.9.0",
"cx-Freeze==5.1.1",

@ -335,8 +335,11 @@ function make_raw_capability( name, capability )
{
// generate the raw capability string
var buf = [ name ] ;
for ( var i=0 ; i < capability.length ; ++i )
buf.push( escapeHTML(capability[i][0]), "<sup>"+escapeHTML(capability[i][1])+"</sup>" ) ;
for ( var i=0 ; i < capability.length ; ++i ) {
buf.push( escapeHTML( capability[i][0] ) ) ;
if ( capability[i][1] )
buf.push( "<sup>", escapeHTML( capability[i][1] ), "</sup>" ) ;
}
return buf.join( "" ) ;
}

@ -1,7 +1,7 @@
=== vehicles/russian/1940 ===
Name Radio Crew survival Capabilities (effective) # Notes
----------------- ------- ------------------------------------ ------------------------------------------ ------------- ----- ---------------------
----------------- ------- ------------------------------------ -------------------------------------- ------------- ----- ---------------------
T-37 ® CS 2 n/a n/a 1 H† M
T-27 ® CS 2 n/a n/a 1.1† M Q
T-40 ® CS 2 n/a n/a 2† H†
@ -78,12 +78,12 @@ NKL-26 n/a CS 2 n/a
RF-8-GAZ-98 n/a CS 3 n/a n/a 47.3† S†<sup>1</sup>
Stuart III(a) n/a CS 4 C6 C6 48 N O LL
Lee(a) n/a CS 7 C4† s8† C4† s8† 49† B†<sup>1</sup> N O LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]†[] s8 s8 50† N O R†<sup>1</sup> LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]† s8 s8 50† N O R†<sup>1</sup> LL
Sherman III(L)(a) n/a CS 6 <small><i>(brew up)</i></small> WP7 s5 sM8 WP7 s5 sM8 50.1 N O R† LL
Matilda II(b) n/a CS 5 sD6 sD6 51† M†<sup>1</sup> N LL
Valentine V(b) n/a CS 4 sM8 sM8 52.1 N LL
Valentine VIII(b) n/a CS 4 HE7 sD6 HE7 sD6 52.2 N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]†[] HE7[F3]8[4+]†[] sD6[4+] sM8† sM8† 53† N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]† HE7[F3]8[4+]† sD6[4+] sM8† sM8† 53† N LL
M3A1 Scout Car(a) n/a CS 4 n/a n/a 54† N LL
Jeep GPA(a) n/a cs 2 n/a n/a 59 H† L†<sup>1</sup>
DUKW(a) n/a cs 7 n/a n/a 60† n/a

@ -1,7 +1,7 @@
=== vehicles/russian/1941 ===
Name Radio Crew survival Capabilities (effective) # Notes
----------------- ------- ------------------------------------ ------------------------------------------ ------------- ----- ---------------------
----------------- ------- ------------------------------------ -------------------------------------- ------------- ----- ---------------------
T-37 ® CS 2 n/a n/a 1 H† M
T-27 ® CS 2 n/a n/a 1.1† M Q
T-40 ® CS 2 n/a n/a 2† H†
@ -78,12 +78,12 @@ NKL-26 n/a CS 2 n/a
RF-8-GAZ-98 n/a CS 3 n/a n/a 47.3† S†<sup>1</sup>
Stuart III(a) n/a CS 4 C6 C6 48 N O LL
Lee(a) n/a CS 7 C4† s8† C4† s8† 49† B†<sup>1</sup> N O LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]†[] s8 s8 50† N O R†<sup>1</sup> LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]† s8 s8 50† N O R†<sup>1</sup> LL
Sherman III(L)(a) n/a CS 6 <small><i>(brew up)</i></small> WP7 s5 sM8 WP7 s5 sM8 50.1 N O R† LL
Matilda II(b) n/a CS 5 sD6 sD6 51† M†<sup>1</sup> N LL
Valentine V(b) n/a CS 4 sM8 sM8 52.1 N LL
Valentine VIII(b) n/a CS 4 HE7 sD6 HE7 sD6 52.2 N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]†[] HE7[F3]8[4+]†[] sD6[4+] sM8† sM8† 53† N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]† HE7[F3]8[4+]† sD6[4+] sM8† sM8† 53† N LL
M3A1 Scout Car(a) n/a CS 4 n/a n/a 54† N LL
Jeep GPA(a) n/a cs 2 n/a n/a 59 H† L†<sup>1</sup>
DUKW(a) n/a cs 7 n/a n/a 60† n/a

@ -1,7 +1,7 @@
=== vehicles/russian/1942 ===
Name Radio Crew survival Capabilities (effective) # Notes
----------------- ------- ------------------------------------ ------------------------------------------ ------------- ----- ---------------------
----------------- ------- ------------------------------------ -------------------------------------- ------------- ----- ---------------------
T-37 ® CS 2 n/a n/a 1 H† M
T-27 ® CS 2 n/a n/a 1.1† M Q
T-40 ® CS 2 n/a n/a 2† H†
@ -78,12 +78,12 @@ NKL-26 n/a CS 2 n/a
RF-8-GAZ-98 n/a CS 3 n/a n/a 47.3† S†<sup>1</sup>
Stuart III(a) n/a CS 4 C6 C6 48 N O LL
Lee(a) n/a CS 7 C4† s8† C4† s8† 49† B†<sup>1</sup> N O LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]†[] s8 s8 50† N O R†<sup>1</sup> LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]† s8 s8 50† N O R†<sup>1</sup> LL
Sherman III(L)(a) n/a CS 6 <small><i>(brew up)</i></small> WP7 s5 sM8 WP7 s5 sM8 50.1 N O R† LL
Matilda II(b) n/a CS 5 sD6 sD6 51† M†<sup>1</sup> N LL
Valentine V(b) n/a CS 4 sM8 sM8 52.1 N LL
Valentine VIII(b) n/a CS 4 HE7 sD6 HE7 sD6 52.2 N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]†[] HE7[F3]8[4+]†[] sD6[4+] sM8† sM8† 53† N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]† HE7[F3]8[4+]† sD6[4+] sM8† sM8† 53† N LL
M3A1 Scout Car(a) n/a CS 4 n/a n/a 54† N LL
Jeep GPA(a) n/a cs 2 n/a n/a 59 H† L†<sup>1</sup>
DUKW(a) n/a cs 7 n/a n/a 60† n/a

@ -1,7 +1,7 @@
=== vehicles/russian/1943 ===
Name Radio Crew survival Capabilities (effective) # Notes
----------------- ------- ------------------------------------ ------------------------------------------ ------------- ----- ---------------------
----------------- ------- ------------------------------------ -------------------------------------- ------------- ----- ---------------------
T-37 ® CS 2 n/a n/a 1 H† M
T-27 ® CS 2 n/a n/a 1.1† M Q
T-40 ® CS 2 n/a n/a 2† H†
@ -78,12 +78,12 @@ NKL-26 n/a CS 2 n/a
RF-8-GAZ-98 n/a CS 3 n/a n/a 47.3† S†<sup>1</sup>
Stuart III(a) n/a CS 4 C6 C6 48 N O LL
Lee(a) n/a CS 7 C4† s8† C4† s8† 49† B†<sup>1</sup> N O LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]†[] s8 s8 50† N O R†<sup>1</sup> LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]† s8 s8 50† N O R†<sup>1</sup> LL
Sherman III(L)(a) n/a CS 6 <small><i>(brew up)</i></small> WP7 s5 sM8 WP7 s5 sM8 50.1 N O R† LL
Matilda II(b) n/a CS 5 sD6 sD6 51† M†<sup>1</sup> N LL
Valentine V(b) n/a CS 4 sM8 sM8 52.1 N LL
Valentine VIII(b) n/a CS 4 HE7 sD6 HE7 sD6 52.2 N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]†[] HE7[F3]8[4+]†[] sD6[4+] sM8† sM8† 53† N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]† HE7[F3]8[4+]† sD6[4+] sM8† sM8† 53† N LL
M3A1 Scout Car(a) n/a CS 4 n/a n/a 54† N LL
Jeep GPA(a) n/a cs 2 n/a n/a 59 H† L†<sup>1</sup>
DUKW(a) n/a cs 7 n/a n/a 60† n/a

@ -1,7 +1,7 @@
=== vehicles/russian/1944 ===
Name Radio Crew survival Capabilities (effective) # Notes
----------------- ------- ------------------------------------ ------------------------------------------ ------------- ----- ---------------------
----------------- ------- ------------------------------------ -------------------------------------- ------------- ----- ---------------------
T-37 ® CS 2 n/a n/a 1 H† M
T-27 ® CS 2 n/a n/a 1.1† M Q
T-40 ® CS 2 n/a n/a 2† H†
@ -78,12 +78,12 @@ NKL-26 n/a CS 2 n/a
RF-8-GAZ-98 n/a CS 3 n/a n/a 47.3† S†<sup>1</sup>
Stuart III(a) n/a CS 4 C6 C6 48 N O LL
Lee(a) n/a CS 7 C4† s8† C4† s8† 49† B†<sup>1</sup> N O LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]†[] s8 s8 50† N O R†<sup>1</sup> LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]† s8 s8 50† N O R†<sup>1</sup> LL
Sherman III(L)(a) n/a CS 6 <small><i>(brew up)</i></small> WP7 s5 sM8 WP7 s5 sM8 50.1 N O R† LL
Matilda II(b) n/a CS 5 sD6 sD6 51† M†<sup>1</sup> N LL
Valentine V(b) n/a CS 4 sM8 sM8 52.1 N LL
Valentine VIII(b) n/a CS 4 HE7 sD6 HE7 sD6 52.2 N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]†[] HE7[F3]8[4+]†[] sD6[4+] sM8† HE8 sD6 sM8† 53† N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]† HE7[F3]8[4+]† sD6[4+] sM8† HE8 sD6 sM8† 53† N LL
M3A1 Scout Car(a) n/a CS 4 n/a n/a 54† N LL
Jeep GPA(a) n/a cs 2 n/a n/a 59 H† L†<sup>1</sup>
DUKW(a) n/a cs 7 n/a n/a 60† n/a

@ -1,7 +1,7 @@
=== vehicles/russian/1945 ===
Name Radio Crew survival Capabilities (effective) # Notes
----------------- ------- ------------------------------------ ------------------------------------------ --------------- ----- ---------------------
----------------- ------- ------------------------------------ -------------------------------------- --------------- ----- ---------------------
T-37 ® CS 2 n/a n/a 1 H† M
T-27 ® CS 2 n/a n/a 1.1† M Q
T-40 ® CS 2 n/a n/a 2† H†
@ -78,12 +78,12 @@ NKL-26 n/a CS 2 n/a
RF-8-GAZ-98 n/a CS 3 n/a n/a 47.3† S†<sup>1</sup>
Stuart III(a) n/a CS 4 C6 C6 48 N O LL
Lee(a) n/a CS 7 C4† s8† C4† s8† 49† B†<sup>1</sup> N O LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]†[] s8 WP6 s8 50† N O R†<sup>1</sup> LL
Sherman III(a) n/a CS 5 <small><i>(brew up)</i></small> WP6[J4+]† s8 WP6 s8 50† N O R†<sup>1</sup> LL
Sherman III(L)(a) n/a CS 6 <small><i>(brew up)</i></small> WP7 s5 sM8 WP7 s5 sM8 50.1 N O R† LL
Matilda II(b) n/a CS 5 sD6 sD6 51† M†<sup>1</sup> N LL
Valentine V(b) n/a CS 4 sM8 sM8 52.1 N LL
Valentine VIII(b) n/a CS 4 HE7 sD6 HE7 sD6 52.2 N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]†[] HE7[F3]8[4+]†[] sD6[4+] sM8† D7 HE8 sD6 sM8† 53† N LL
Churchill III(b) n/a CS 7 D6[J4]7[5]† HE7[F3]8[4+]† sD6[4+] sM8† D7 HE8 sD6 sM8† 53† N LL
M3A1 Scout Car(a) n/a CS 4 n/a n/a 54† N LL
Jeep GPA(a) n/a cs 2 n/a n/a 59 H† L†<sup>1</sup>
DUKW(a) n/a cs 7 n/a n/a 60† n/a

@ -5,19 +5,14 @@ import io
import shutil
import re
import lxml.html
import lxml.etree
import tabulate
import pytest
from vasl_templates.webapp.tests.utils import find_child, find_children, wait_for
from vasl_templates.webapp.tests.utils import find_child, wait_for
# ---------------------------------------------------------------------
# NOTE: Running these checks is fairly slow, and once done, don't provide a great deal of value
# in the day-to-day development process, so we make them optional.
@pytest.mark.skipif(
pytest.config.option.short_tests, #pylint: disable=no-member
reason = "--short-tests specified"
)
def test_vo_reports( webapp, webdriver ):
"""Check the vehicle/ordnance reports."""
@ -89,22 +84,26 @@ def get_vo_report( webapp, webdriver, nat, vo_type, year ):
webdriver.get(
webapp.url_for( "get_vo_report", nat=nat, vo_type=vo_type, year=year )
)
wait_for( 5, lambda: find_child("#results").is_displayed() )
wait_for( 2, lambda: find_child("#results").is_displayed() )
# unload the results
def getval( cell ):
"""Get a table cell's value (cleaned up)."""
val = cell.get_attribute( "innerHTML" )
def tidy( cell ):
"""Tidy up a cell value."""
val = lxml.etree.tostring( cell ).decode( "utf-8" ) #pylint: disable=c-extension-no-member
mo = re.search( r"^<(th|td).*?>(.*)</\1>$", val )
val = mo.group(2)
if val == "<small><em>n/a</em></small>":
return "n/a"
val = val.replace( '<span class="val">', "" ).replace( "</span>", "" )
val = val.replace( "&#8224;", "\u2020" ).replace( "&#174;", "\u00ae" )
return val
# unload the results
# NOTE: Getting each table cell via Selenium is insanely slow - we parse the HTML manually :-/
results = []
elem = find_child( "#results" )
for row in find_children( "tr", elem ):
if not results:
results.append( [ getval(c) for c in find_children("th",row) ] )
else:
results.append( [ getval(c) for c in find_children("td",row) ] )
doc = lxml.html.fromstring( webdriver.page_source )
for row in doc.xpath( "//div[@id='results']//table//tr" ):
tag = "td" if results else "th"
cells = row.xpath( ".//{}".format( tag ) )
results.append( list( tidy(c) for c in cells ) )
return results

Loading…
Cancel
Save