# Path: tests/base.py
# class BreadTestCase(TestCase):
#     url_namespace = ""
#     extra_bread_attributes = {}
# 
#     def setUp(self):
#         self.username = "joe"
#         self.password = "random"
#         User = get_user_model()
#         self.user = User.objects.create_user(username=self.username)
#         self.user.set_password(self.password)
#         self.user.save()
#         assert self.client.login(username=self.username, password=self.password)
#         self.model = BreadTestModel
#         self.model_name = self.model._meta.model_name
#         self.model_factory = BreadTestModelFactory
#         self.request_factory = RequestFactory()
# 
#         class ReadClass(ReadView):
#             columns = [
#                 ("Name", "name"),
#                 ("Text", "other__text"),
#                 (
#                     "Model1",
#                     "model1",
#                 ),
#             ]
# 
#         class BrowseClass(BrowseView):
#             columns = [
#                 ("Name", "name"),
#                 ("Text", "other__text"),
#                 (
#                     "Model1",
#                     "model1",
#                 ),
#             ]
# 
#         class BreadTestClass(Bread):
#             model = self.model
#             base_template = "bread/empty.html"
#             browse_view = BrowseClass
#             namespace = self.url_namespace
#             plural_name = "testmodels"
# 
#             def get_additional_context_data(self):
#                 context = super(BreadTestClass, self).get_additional_context_data()
#                 context["bread_test_class"] = True
#                 return context
# 
#         for k, v in self.extra_bread_attributes.items():
#             setattr(BreadTestClass, k, v)
# 
#         self.BreadTestClass = BreadTestClass
#         self.bread = BreadTestClass()
# 
#     def tearDown(self):
#         global urlpatterns
#         urlpatterns = None
# 
#     def set_urls(self, bread):
#         # Given a bread instance, set its URLs on the test urlconf
#         global urlpatterns
#         urlpatterns = bread.get_urls()
# 
#     def get_permission(self, short_name):
#         """Return a Permission object for the test model.
#         short_name should be browse, read, edit, add, or delete.
#         """
#         return Permission.objects.get_or_create(
#             content_type=ContentType.objects.get_for_model(self.model),
#             codename="%s_%s" % (short_name, self.model_name),
#         )[0]
# 
#     def give_permission(self, short_name):
#         self.user.user_permissions.add(self.get_permission(short_name))


from .base import BreadTestCase
        self.assertEqual("%s/<int:pk>/edit/" % bread.plural_name, str(edit_pattern))

    def test_view_subset(self):
        # We can do bread with a subset of the BREAD views
        self.bread.views = "B"
        url_names = [x.name for x in self.bread.get_urls()]
        self.assertIn("browse_%s" % self.bread.plural_name, url_names)
        self.assertNotIn("read_%s" % self.model_name, url_names)
        self.assertNotIn("edit_%s" % self.model_name, url_names)
        self.assertNotIn("add_%s" % self.model_name, url_names)
        self.assertNotIn("delete_%s" % self.model_name, url_names)

        self.bread.views = "RE"
        url_names = [x.name for x in self.bread.get_urls()]
        self.assertNotIn("browse_%s" % self.bread.plural_name, url_names)
        self.assertIn("read_%s" % self.model_name, url_names)
        self.assertIn("edit_%s" % self.model_name, url_names)
        self.assertNotIn("add_%s" % self.model_name, url_names)
        self.assertNotIn("delete_%s" % self.model_name, url_names)

    def test_url_names(self):
        # The xxxx_url_name methods return what we expect
        bread = self.bread
        self.assertEqual("browse_%s" % self.bread.plural_name, bread.browse_url_name())
        self.assertEqual("read_%s" % self.model_name, bread.read_url_name())
        self.assertEqual("edit_%s" % self.model_name, bread.edit_url_name())
        self.assertEqual("add_%s" % self.model_name, bread.add_url_name())
        self.assertEqual("delete_%s" % self.model_name, bread.delete_url_name())

    def test_omit_prefix(self):

# Path: tests/base.py
# class BreadTestCase(TestCase):
#     url_namespace = ""
#     extra_bread_attributes = {}
# 
#     def setUp(self):
#         self.username = "joe"
#         self.password = "random"
#         User = get_user_model()
#         self.user = User.objects.create_user(username=self.username)
#         self.user.set_password(self.password)
#         self.user.save()
#         assert self.client.login(username=self.username, password=self.password)
#         self.model = BreadTestModel
#         self.model_name = self.model._meta.model_name
#         self.model_factory = BreadTestModelFactory
#         self.request_factory = RequestFactory()
# 
#         class ReadClass(ReadView):
#             columns = [
#                 ("Name", "name"),
#                 ("Text", "other__text"),
#                 (
#                     "Model1",
#                     "model1",
#                 ),
#             ]
# 
#         class BrowseClass(BrowseView):
#             columns = [
#                 ("Name", "name"),
#                 ("Text", "other__text"),
#                 (
#                     "Model1",
#                     "model1",
#                 ),
#             ]
# 
#         class BreadTestClass(Bread):
#             model = self.model
#             base_template = "bread/empty.html"
#             browse_view = BrowseClass
#             namespace = self.url_namespace
#             plural_name = "testmodels"
# 
#             def get_additional_context_data(self):
#                 context = super(BreadTestClass, self).get_additional_context_data()
#                 context["bread_test_class"] = True
#                 return context
# 
#         for k, v in self.extra_bread_attributes.items():
#             setattr(BreadTestClass, k, v)
# 
#         self.BreadTestClass = BreadTestClass
#         self.bread = BreadTestClass()
# 
#     def tearDown(self):
#         global urlpatterns
#         urlpatterns = None
# 
#     def set_urls(self, bread):
#         # Given a bread instance, set its URLs on the test urlconf
#         global urlpatterns
#         urlpatterns = bread.get_urls()
# 
#     def get_permission(self, short_name):
#         """Return a Permission object for the test model.
#         short_name should be browse, read, edit, add, or delete.
#         """
#         return Permission.objects.get_or_create(
#             content_type=ContentType.objects.get_for_model(self.model),
#             codename="%s_%s" % (short_name, self.model_name),
#         )[0]
# 
#     def give_permission(self, short_name):
#         self.user.user_permissions.add(self.get_permission(short_name))


# Path: tests/test_urls.py
from .base import BreadTestCase

        self.assertEqual("%s/<int:pk>/edit/" % bread.plural_name, str(edit_pattern))

    def test_view_subset(self):
        # We can do bread with a subset of the BREAD views
        self.bread.views = "B"
        url_names = [x.name for x in self.bread.get_urls()]
        self.assertIn("browse_%s" % self.bread.plural_name, url_names)
        self.assertNotIn("read_%s" % self.model_name, url_names)
        self.assertNotIn("edit_%s" % self.model_name, url_names)
        self.assertNotIn("add_%s" % self.model_name, url_names)
        self.assertNotIn("delete_%s" % self.model_name, url_names)

        self.bread.views = "RE"
        url_names = [x.name for x in self.bread.get_urls()]
        self.assertNotIn("browse_%s" % self.bread.plural_name, url_names)
        self.assertIn("read_%s" % self.model_name, url_names)
        self.assertIn("edit_%s" % self.model_name, url_names)
        self.assertNotIn("add_%s" % self.model_name, url_names)
        self.assertNotIn("delete_%s" % self.model_name, url_names)

    def test_url_names(self):
        # The xxxx_url_name methods return what we expect
        bread = self.bread
        self.assertEqual("browse_%s" % self.bread.plural_name, bread.browse_url_name())
        self.assertEqual("read_%s" % self.model_name, bread.read_url_name())
        self.assertEqual("edit_%s" % self.model_name, bread.edit_url_name())
        self.assertEqual("add_%s" % self.model_name, bread.add_url_name())
        self.assertEqual("delete_%s" % self.model_name, bread.delete_url_name())

    def test_omit_prefix(self):

        bread = self.bread