fuel-qa/fuelweb_test/testrail/datetime_util.py
Andrey Lavrentyev 21584924af Add update testrail fields functionality for testrail reporter
and small refactoring of description parsing

Add update_case() method to testrail client
Pull parsing custom cases fields into _get_custom_cases_fields() method
Add _get_fields_to_update() method to test cases uploader
Change log message for up-to-date cases
Add new file: datetime_util.py
Add method that converts duration to testrail estimate format
Register new file in the doc/testrail.rst
Change duration regexp and pull it into compiled instance
Pull tests discovering and test plan creation into
  _create_test_plan_from_registry() function
Pull various case checks into _is_case_processable() function
Pull test case name getter actions into _get_test_case_name() function
Pull case 'not included' verification into _is_not_included() function
Pull case 'excluded' verification into _is_excluded() function
Pull docstring getter actions into _get_docstring() function
Pull docstring parsing actions into _parse_docstring() function
Add support for multiline title and test case steps

Change-Id: I2245b939e91bab9d4f48b072e89d86163a0dd6b0
Closes-Bug: #1558008
(cherry picked from commit 4ac47dad9b)
2016-04-27 13:47:19 +00:00

37 lines
1.2 KiB
Python

# Copyright 2016 Mirantis, Inc.
#
# 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.
from __future__ import division
MINUTE = 60
HOUR = MINUTE ** 2
DAY = HOUR * 8
WEEK = DAY * 5
def duration_to_testrail_estimate(duration):
"""Converts duration in minutes to testrail estimate format
"""
seconds = duration * MINUTE
week = seconds // WEEK
days = seconds % WEEK // DAY
hours = seconds % DAY // HOUR
minutes = seconds % HOUR // MINUTE
estimate = ''
for val, char in ((week, 'w'), (days, 'd'), (hours, 'h'), (minutes, 'm')):
if val:
estimate = ' '.join([estimate, '{0}{1}'.format(val, char)])
return estimate.lstrip()