def test_flagged_downgrade(self): # If we can't satisfy the flag request we'll ignore it: m = EndpointMap() normal_view = object() m.add_view('1.0', None, normal_view) self.assertEqual(normal_view, m.get_view('1.0', 'flag'))
def test_simple_match(self): # Test an exact match without flags m = EndpointMap() view = object() m.add_view('1.0', None, view) self.assertEqual(view, m.get_view('1.0'))
def test_does_not_version_upgrade(self): # if we can't satisfy the version request we won't upgrade to # an older version m = EndpointMap() view = object() m.add_view('1.2', None, view) self.assertEqual(None, m.get_view('1.1'))
def test_version_downgrade(self): # If we can't satisfy the version requirement we'll return an # older view. m = EndpointMap() view = object() m.add_view('1.2', None, view) self.assertEqual(view, m.get_view('1.3'))
def test_get_view_type_checking(self): # get view doesn't accept the view parameter, so trim it from the # argument list: args = self.args[:-1] m = EndpointMap() self.assertRaisesRegex(self.exception, self.expected_error, methodcaller('get_view', *args), m)
def test_add_view_type_checking(self): m = EndpointMap() self.assertRaisesRegex( self.exception, self.expected_error, methodcaller('add_view', *self.args), m )
def test_flagged_view(self): # Test an exact match with flags: m = EndpointMap() normal_view = object() flagged_view = object() m.add_view('1.0', None, normal_view) m.add_view('1.0', 'flag', flagged_view) self.assertEqual(normal_view, m.get_view('1.0')) self.assertEqual(flagged_view, m.get_view('1.0', 'flag'))
def test_version_downgrade_is_smallest_increment(self): # If we can't satisfy the exact version requested, give the # client the smallest decrement in version possible. m = EndpointMap() view11 = object() view12 = object() view13 = object() m.add_view('1.1', None, view11) m.add_view('1.2', None, view12) m.add_view('1.3', None, view13) self.assertEqual(view13, m.get_view('1.4'))