예제 #1
0
    def test_schema_methods_get_patched(self):
        original_methods = self._get_current_methods()

        with Namespace():
            patched_methods = self._get_current_methods()

        unpatched_methods = self._get_current_methods()

        for original_method, patched_method, unpatched_method in \
                zip(original_methods, patched_methods, unpatched_methods):
            self.assertEqual(original_method, unpatched_method)
            self.assertNotEqual(original_method, patched_method)
예제 #2
0
    def test_customer_operations_outside_of_namespace(self):
        with self.assertRaises(braintree.exceptions.NotFoundError):
            braintree.Customer.find('nonexistent')

        _ensure_user_exists({
            'id': 'nonnamespaced',
        })

        with Namespace():
            pass

        try:
            braintree.Customer.find('nonnamespaced')
        except braintree.exceptions.NotFoundError:
            self.fail()
예제 #3
0
    def test_advanced_search_gets_patched(self):
        original_nodes = self._get_current_search_nodes()

        with Namespace():
            patched_nodes = self._get_current_search_nodes()

        unpatched_nodes = self._get_current_search_nodes()

        # NamespaceError is raised on __getattribute__ for patched nodes.
        for orig_node, unpatched_node in zip(original_nodes, unpatched_nodes):
            self.assertIs(orig_node, unpatched_node)
            self.assertIsNone(getattr(orig_node, 'foo', None))  # should not raise NamespaceError

        for node in patched_nodes:
            with self.assertRaises(NamespaceError):
                node.foo
예제 #4
0
 def test_omit_options_gets_empty(self):
     namespace = Namespace()
     self.assertEqual(namespace.options, {})
예제 #5
0
 def setUp(self):
     self.namespace = Namespace()
     self.namespace.__enter__()
     self.addCleanup(self.namespace.__exit__)
예제 #6
0
class NamespaceTest(TestCase):
    def setUp(self):
        self.namespace = Namespace()
        self.namespace.__enter__()
        self.addCleanup(self.namespace.__exit__)