flake8 clean checkpoint
This commit takes what was in tree so far and makes it pass the tox pep8 job.
This commit is contained in:
@@ -124,14 +124,14 @@ def get_all_test_runs():
|
|||||||
|
|
||||||
def get_test_by_id(id, session=None):
|
def get_test_by_id(id, session=None):
|
||||||
session = session or get_session()
|
session = session or get_session()
|
||||||
test = db.utils.models_query(models.Test, session).filter_by(
|
test = db_utils.models_query(models.Test, session).filter_by(
|
||||||
id=id).first()
|
id=id).first()
|
||||||
return test
|
return test
|
||||||
|
|
||||||
|
|
||||||
def get_test_by_test_id(test_id, session=None):
|
def get_test_by_test_id(test_id, session=None):
|
||||||
session = session or get_session()
|
session = session or get_session()
|
||||||
test = db.utils.models_query(models.Test, session).filter_by(
|
test = db_utils.models_query(models.Test, session).filter_by(
|
||||||
test_id=test_id).first()
|
test_id=test_id).first()
|
||||||
return test
|
return test
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,18 @@
|
|||||||
|
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
# implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
"""create runs table
|
"""create runs table
|
||||||
|
|
||||||
Revision ID: 1f92cfe8a6d3
|
Revision ID: 1f92cfe8a6d3
|
||||||
|
|||||||
@@ -1,3 +1,18 @@
|
|||||||
|
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
# implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
"""create test_runs table
|
"""create test_runs table
|
||||||
|
|
||||||
Revision ID: 3db7b49816d5
|
Revision ID: 3db7b49816d5
|
||||||
|
|||||||
@@ -1,3 +1,18 @@
|
|||||||
|
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
# implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
"""create tests tables
|
"""create tests tables
|
||||||
|
|
||||||
Revision ID: 5ef013efbc2
|
Revision ID: 5ef013efbc2
|
||||||
|
|||||||
@@ -48,11 +48,12 @@ def parse_args(argv, default_config_files=None):
|
|||||||
cfg.CONF(argv[1:], project='subunit2sql',
|
cfg.CONF(argv[1:], project='subunit2sql',
|
||||||
default_config_files=default_config_files)
|
default_config_files=default_config_files)
|
||||||
|
|
||||||
|
|
||||||
def process_results(results):
|
def process_results(results):
|
||||||
session = api.get_session()
|
session = api.get_session()
|
||||||
db_run = api.create_run()
|
db_run = api.create_run()
|
||||||
for test in results:
|
for test in results:
|
||||||
db_test = api.get_test_by_test_id(test, session)
|
db_test = api.get_test_by_test_id(test, session)
|
||||||
if not db_test:
|
if not db_test:
|
||||||
db_test = api.create_test(test)
|
db_test = api.create_test(test)
|
||||||
api.create_test_run(db_test.id, db_run.id, test['status'],
|
api.create_test_run(db_test.id, db_run.id, test['status'],
|
||||||
@@ -62,9 +63,9 @@ def process_results(results):
|
|||||||
def main():
|
def main():
|
||||||
parse_args(sys.argv)
|
parse_args(sys.argv)
|
||||||
if CONF.subunit_files:
|
if CONF.subunit_files:
|
||||||
streams = [ subunit.ReadSubunit(s) for s in CONF.subunit_files ]
|
streams = [subunit.ReadSubunit(s) for s in CONF.subunit_files]
|
||||||
else:
|
else:
|
||||||
steams = [ subunit.ReadSubunit(sys.stdin) ]
|
streams = [subunit.ReadSubunit(sys.stdin)]
|
||||||
for stream in streams:
|
for stream in streams:
|
||||||
process_results(stream.get_results())
|
process_results(stream.get_results())
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import functools
|
||||||
|
|
||||||
import subunit
|
import subunit
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
@@ -21,11 +23,12 @@ class ReadSubunit(object):
|
|||||||
def __init__(self, stream_file):
|
def __init__(self, stream_file):
|
||||||
self.stream = subunit.ByteStreamToStreamResult(stream_file)
|
self.stream = subunit.ByteStreamToStreamResult(stream_file)
|
||||||
summary = testtools.StreamSummary()
|
summary = testtools.StreamSummary()
|
||||||
outcomes = testtools.StreamToDict(functools.partial(parse_outcome))
|
outcomes = testtools.StreamToDict(functools.partial(
|
||||||
|
self.parse_outcome))
|
||||||
self.result = testtools.CopyStreamResult([outcomes, summary])
|
self.result = testtools.CopyStreamResult([outcomes, summary])
|
||||||
self.results = {}
|
self.results = {}
|
||||||
|
|
||||||
def get_results():
|
def get_results(self):
|
||||||
try:
|
try:
|
||||||
self.stream.run(self.result)
|
self.stream.run(self.result)
|
||||||
finally:
|
finally:
|
||||||
@@ -37,20 +40,16 @@ class ReadSubunit(object):
|
|||||||
# TODO(sdague): ask lifeless why on this?
|
# TODO(sdague): ask lifeless why on this?
|
||||||
if status == 'exists':
|
if status == 'exists':
|
||||||
return
|
return
|
||||||
|
name = self.cleanup_test_name(test['id'])
|
||||||
worker = find_worker(test)
|
|
||||||
name = cleanup_test_name(test['id'])
|
|
||||||
|
|
||||||
# don't count the end of the return code as a fail
|
# don't count the end of the return code as a fail
|
||||||
if name == 'process-returncode':
|
if name == 'process-returncode':
|
||||||
return
|
return
|
||||||
|
|
||||||
self.result[name] = {
|
self.result[name] = {
|
||||||
'status': status,
|
'status': status,
|
||||||
'start_time': test['timestamps'][0],
|
'start_time': test['timestamps'][0],
|
||||||
'end_time': test['timestamps'][1],
|
'end_time': test['timestamps'][1],
|
||||||
}
|
}
|
||||||
stream.flush()
|
self.stream.flush()
|
||||||
|
|
||||||
def cleanup_test_name(name, strip_tags=True, strip_scenarios=False):
|
def cleanup_test_name(name, strip_tags=True, strip_scenarios=False):
|
||||||
"""Clean up the test name for display.
|
"""Clean up the test name for display.
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
# Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user