def test_handles_args_in_either_order(self): """ It shouldn't matter whether we pass the "higher" string as the first or second param. """ low = "aaaaa" high = "zzzzz" mid1 = _mid_string(low, high) mid2 = _mid_string(low, high) self.assertEqual(mid1, mid2) self.assertTrue(low < mid1 < high)
def test_handles_args_in_either_order(self): """It shouldn't matter whether we pass the "higher" string as the first or second param.""" low = "aaaaa" high = "zzzzz" mid1 = _mid_string(low, high) mid2 = _mid_string(low, high) self.assertEqual(mid1, mid2) self.assertTrue(low < mid1 < high)
def test_handles_strings_of_different_lengths(self): """ Strings of different lengths should return another of a length mid way between """ start = "aaa" end = "zzzzzzzzzzzzz" mid = _mid_string(start, end) self.assertTrue(start < mid < end)
def test_slightly_less_basic_behaviour(self): start = "aaaaaaaaaaaa" end = "z" mid_low_apprx = "l" mid_high_apprx = "n" result = _mid_string(start, end) self.assertTrue(mid_low_apprx < result < mid_high_apprx)
def test_does_not_return_string_starting_with_double_underscore(self): """ A string that starts with a double underscore is not a valid Datastore key and so should not be returned. """ # The true mid point between this start and end combination is a double underscore start = "^^" end = "``" result = _mid_string(start, end) self.assertNotEqual(result, "__")
def test_handles_unicode(self): """ It should be able to do comparisions on non-ascii strings. """ start = u"aaa£¢$›😇" end = u"zzz🤡" mid = _mid_string(start, end) self.assertTrue(start < mid < end)
def test_basic_behaviour(self): """ Test finding the midpoint between two string in an obvious case. """ start = "a" end = "c" self.assertEqual(_mid_string(start, end), "b")