Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
Remove offset from test messageset sequence mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
rudigiesler committed Sep 11, 2017
1 parent 1b297c7 commit 4b34c23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions mapper/sequence_mapper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from math import ceil
from math import floor


class NoMappingFound(Exception):
Expand All @@ -19,13 +19,13 @@ def map_test_messageset_1(self, sequence):
Maps from the first testing messageset to the second testing
messageset.
"""
return 'test.messageset.2', 9 + 2 * sequence
return 'test.messageset.2', max(0, 2 * sequence - 1)

def map_test_messageset_2(self, sequence):
"""
Maps from the second testing messageset back to the first.
"""
return 'test.messageset.1', max(0, int(ceil((sequence - 9) / 2.0)))
return 'test.messageset.1', int(floor(sequence / 2.0) + 1)

def map_forward(self, messageset, sequence):
"""
Expand Down
13 changes: 6 additions & 7 deletions mapper/tests/test_sequence_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ def test_default_mapping(self):

def test_map_test_messageset_1(self):
"""
test.messageset.1 should map forward to test.messageset.2 with an
offset and scale.
test.messageset.1 should map forward to test.messageset.2 with a scale.
"""
sequence_from = [1, 2, 3]
sequence_to = [11, 13, 15]
sequence_from = [0, 1, 2, 3]
sequence_to = [0, 1, 3, 5]
for seq_from, seq_to in zip(sequence_from, sequence_to):
ms, seq = map_forward('test.messageset.1', seq_from)
self.assertEqual(ms, 'test.messageset.2')
Expand All @@ -29,10 +28,10 @@ def test_map_test_messageset_1(self):
def test_map_test_messageset_2(self):
"""
test.messageset.2 should map backwards to test_messageset.1 with a
scale and offset.
scale.
"""
sequence_from = [0, 11, 12, 13, 14]
sequence_to = [0, 1, 2, 2, 3]
sequence_from = [1, 2, 3, 4, 5]
sequence_to = [1, 2, 2, 3, 3]
for seq_from, seq_to in zip(sequence_from, sequence_to):
ms, seq = map_backward('test.messageset.2', seq_from)
self.assertEqual(ms, 'test.messageset.1')
Expand Down

0 comments on commit 4b34c23

Please sign in to comment.