Exemplo n.º 1
0
    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'))
Exemplo n.º 2
0
    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'))
Exemplo n.º 3
0
    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'))
Exemplo n.º 4
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'))
Exemplo n.º 5
0
    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'))
Exemplo n.º 6
0
    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'))