Skip to content

Commit

Permalink
Merge pull request #35 from 2gis/duration-options
Browse files Browse the repository at this point in the history
set duration from options if exist
  • Loading branch information
Vadim committed Feb 12, 2016
2 parents 7d5a24a + fc908b7 commit bfa2820
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cdws_api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,8 @@ def test_upload_file_to_launch(self):

def test_additional_information(self):
data = \
'{"env": {"BRANCH": "master"}, "options": {"started_by": "user"}}'
'{"env": {"BRANCH": "master"}, "options": {"started_by": "user",' \
'"duration": "120.20"}}'
project = Project.objects.create(name='DummyTestProject')
testplan = TestPlan.objects.create(name='DummyTestPlan',
project=project)
Expand All @@ -1356,6 +1357,7 @@ def test_additional_information(self):
self.assertFalse(launch['build']['version'])
self.assertFalse(launch['build']['hash'])
self.assertFalse(launch['build']['branch'])
self.assertEqual(120.2, launch['duration'])

def test_empty_started_by(self):
data = '{"env": {"BRANCH": "master"}}'
Expand Down
5 changes: 4 additions & 1 deletion cdws_api/xml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def get_text(self, nodelist):

def update_duration(self, launch):
log.info('Updating total duration for launch {}'.format(launch.id))
launch.duration = self.total_duration
if launch.duration is None:
launch.duration = self.total_duration
launch.save()


Expand Down Expand Up @@ -163,6 +164,8 @@ def xml_parser_func(format, testplan_id, file_content, launch_id, params):
params_json = json.loads(params)
if 'options' in params_json \
and params_json['options']['started_by'] != '':
if params_json['options'].get('duration') is not None:
launch.duration = float(params_json['options']['duration'])
launch.started_by = params_json['options']['started_by']
build = Build(launch=launch,
version=params_json['options'].get('version'),
Expand Down

0 comments on commit bfa2820

Please sign in to comment.