def test_list_empty(self):
     ex_url = reverse("position-update",
                      urlconf="shastra_compedium.urls",
                      args=[self.detail.pk])
     self.detail.delete()
     login_as(self.user, self)
     response = self.client.get(self.url)
     self.assertNotContains(response, ex_url)
     self.assertNotContains(response, "'action':")
Exemple #2
0
 def test_list_categories_w_search_critieria(self):
     category = CategoryFactory()
     category2 = CategoryFactory()
     login_as(self.user, self)
     response = self.client.get("%s?q=%s" % (
         reverse('category-autocomplete'),
         category.name))
     self.assertContains(response, category.name)
     self.assertContains(response, category.pk)
     self.assertNotContains(response, category2.name)
Exemple #3
0
 def test_list_positions_w_search_critieria(self):
     position = PositionFactory()
     position2 = PositionFactory()
     login_as(self.user, self)
     response = self.client.get("%s?q=%s" % (
         reverse('position-autocomplete'),
         position.name))
     self.assertContains(response, position.name)
     self.assertContains(response, position.pk)
     self.assertNotContains(response, position2.name)
 def setUp(self):
     self.client = Client()
     self.object = CategoryFactory()
     self.create_url = reverse(self.add_name,
                               urlconf='shastra_compedium.urls')
     self.edit_url = reverse(self.update_name,
                             args=[self.object.pk],
                             urlconf='shastra_compedium.urls')
     user = UserFactory()
     login_as(user, self)
 def test_list_empty(self):
     from shastra_compedium.site_text import user_messages
     ex_url = reverse("position-update",
                      urlconf="shastra_compedium.urls",
                      args=[self.detail.pk])
     self.detail.delete()
     login_as(self.user, self)
     response = self.client.get(self.url)
     self.assertContains(response,
                         user_messages['SourceList']['description'])
     self.assertNotContains(response, ex_url)
     self.assertContains(response, "'action':")
    def test_list_categories_changed_ids(self):
        another_detail = PositionDetailFactory(usage="Posture Description")
        another_detail.sources.add(self.source)

        chapter = CategoryDetailFactory(category=self.detail.position.category)
        chapter.sources.add(self.source)
        another_shastra = ShastraFactory()

        login_as(self.user, self)
        response = self.client.get("%s?changed_ids=%s&obj_type=Source" %
                                   (self.url, str([self.source.pk])))
        self.assertContains(response, "[%d].includes(row.id)" % self.source.pk)
 def test_list_categories_all_the_things(self):
     another_detail = PositionDetailFactory(position=self.detail.position,
                                            usage="Posture Description")
     another_source_detail = PositionDetailFactory(
         position=self.detail.position, usage="Posture Description")
     another_detail.sources.add(self.source)
     another_source = SourceFactory()
     another_source_detail.sources.add(another_source)
     login_as(self.user, self)
     response = self.client.get(self.url)
     self.assertContains(response, "'id': %d" % self.detail.position.pk)
     self.assertContains(response,
                         "'position': '%s'" % self.detail.position.name)
     self.assertContains(
         response,
         ('<th data-field="%d_Posture Description" data-sortable="false">' +
          '%s<br>%s<br>Description</th>') %
         (self.source.pk, self.source.title, self.source.translator))
     self.assertContains(
         response, ('<th data-field="%d_Meaning" data-sortable="false">' +
                    '%s<br>%s<br>Meaning</th>') %
         (self.source.pk, self.source.title, self.source.translator))
     self.assertContains(
         response,
         ('<th data-field="%d_Posture Description" data-sortable="false">' +
          '%s<br>%s<br>Description</th>') %
         (another_source.pk, another_source.title,
          another_source.translator))
     self.assertContains(
         response,
         ('%s&nbsp;&nbsp;<a class="lakshmi-detail" href="%s?next=%s" ' +
          'title="Edit"><i class="fas fa-edit"></i></a>') %
         (self.detail.position.category,
          reverse("category-update",
                  urlconf="shastra_compedium.urls",
                  args=[self.detail.position.category.pk]), self.url))
     self.assertContains(
         response, ('<a class="lakshmi-detail" href="%s" title="Edit"><i ' +
                    'class="fas fa-edit"></i></a>') %
         (reverse("position-update",
                  urlconf="shastra_compedium.urls",
                  args=[self.detail.position.pk])))
     self.assertContains(
         response, "'%s_%s': '%s'" %
         (self.source.pk, self.detail.usage, self.detail.contents))
     self.assertContains(
         response, "'%s_%s': '%s'" %
         (self.source.pk, another_detail.usage, another_detail.contents))
     self.assertContains(
         response,
         "'%s_%s': '%s'" % (another_source.pk, another_source_detail.usage,
                            another_source_detail.contents))
 def test_list_positions_basic(self):
     login_as(self.user, self)
     response = self.client.get(self.url)
     self.assertContains(response, self.detail.position.name)
     self.assertContains(
         response,
         reverse("position-update",
                 urlconf="shastra_compedium.urls",
                 args=[self.detail.position.pk]))
     self.assertContains(
         response,
         '<a href="%s" class="nav-link active">Position List</a>' %
         (self.url),
         html=True)
 def test_list_sources_no_cat_detail(self):
     from shastra_compedium.site_text import user_messages
     login_as(self.user, self)
     response = self.client.get(self.url)
     self.assertContains(response,
                         user_messages['SourceList']['description'])
     self.assertContains(response, self.source.title)
     self.assertContains(
         response,
         reverse("source-update",
                 urlconf="shastra_compedium.urls",
                 args=[self.source.pk]))
     self.assertContains(
         response,
         '<a href="%s" class="nav-link active">Source List</a>' %
         (self.url),
         html=True)
 def test_list_sources_basic(self):
     from shastra_compedium.site_text import user_messages
     chapter = CategoryDetailFactory(category=self.detail.position.category)
     chapter.sources.add(self.source)
     login_as(self.user, self)
     response = self.client.get(self.url)
     self.assertContains(response,
                         user_messages['SourceList']['description'])
     self.assertContains(response, self.source.title)
     self.assertContains(
         response,
         reverse("source-update",
                 urlconf="shastra_compedium.urls",
                 args=[self.source.pk]))
     self.assertContains(
         response,
         '<a href="%s" class="nav-link active">Source List</a>' %
         (self.url),
         html=True)
    def test_list_categories_changed_categorydetail(self):
        another_detail = PositionDetailFactory(usage="Posture Description")
        another_detail.sources.add(self.source)

        chapter = CategoryDetailFactory(category=self.detail.position.category,
                                        chapter=10,
                                        verse_start=1,
                                        verse_end=100)
        chapter.sources.add(self.source)
        another_shastra = ShastraFactory()

        login_as(self.user, self)
        response = self.client.get(
            "%s?changed_ids=%s&obj_type=CategoryDetail" %
            (self.url, str([chapter.pk])))
        self.assertContains(
            response,
            ('<td class="lakshmi-table-success">10:1-100<a class="lakshmi-' +
             'detail" href="%s" title="Edit Chapter"><i class="fas fa-edit">' +
             '</i></a></td>') % reverse("categorydetail-update",
                                        urlconf="shastra_compedium.urls",
                                        args=[chapter.pk]))
    def test_list_category_detail_variations(self):
        chapter = CategoryDetailFactory(category=self.detail.position.category,
                                        chapter=10,
                                        verse_start=1,
                                        verse_end=100)
        chapter.sources.add(self.source)
        chapter2 = CategoryDetailFactory(verse_end=50)
        chapter2.sources.add(self.source)
        chapter_more = CategoryDetailFactory(
            category=self.detail.position.category,
            chapter=10,
            verse_start=101,
            verse_end=200)
        chapter_more.sources.add(self.source)

        login_as(self.user, self)
        response = self.client.get(self.url)
        self.assertContains(
            response,
            ('<a class="lakshmi-detail" href="%s" title="Edit Chapter"><i ' +
             'class="fas fa-edit"></i></a>') %
            reverse("categorydetail-update",
                    urlconf="shastra_compedium.urls",
                    args=[chapter.pk]))
        self.assertContains(
            response,
            ('<a class="lakshmi-detail" href="%s" title="Edit Chapter"><i ' +
             'class="fas fa-edit"></i></a>') %
            reverse("categorydetail-update",
                    urlconf="shastra_compedium.urls",
                    args=[chapter2.pk]))
        self.assertContains(
            response,
            ('<a class="lakshmi-detail" href="%s" title="Edit Chapter"><i ' +
             'class="fas fa-edit"></i></a>') %
            reverse("categorydetail-update",
                    urlconf="shastra_compedium.urls",
                    args=[chapter_more.pk]))
Exemple #13
0
 def test_list_categories(self):
     category = CategoryFactory()
     login_as(self.user, self)
     response = self.client.get(reverse('category-autocomplete'))
     self.assertContains(response, category.name)
     self.assertContains(response, category.pk)
Exemple #14
0
 def test_list_positions(self):
     position = PositionFactory()
     login_as(self.user, self)
     response = self.client.get(reverse('position-autocomplete'))
     self.assertContains(response, position.name)
     self.assertContains(response, position.pk)
Exemple #15
0
 def setUp(self):
     self.client = Client()
     self.create_url = reverse(self.add_name,
                               urlconf='shastra_compedium.urls')
     user = UserFactory()
     login_as(user, self)
    def test_list_categories_all_the_things(self):
        another_detail = PositionDetailFactory(usage="Posture Description")
        another_detail.sources.add(self.source)

        chapter = CategoryDetailFactory(category=self.detail.position.category)
        chapter.sources.add(self.source)
        another_shastra = ShastraFactory()

        login_as(self.user, self)
        response = self.client.get(self.url)
        self.assertContains(response, "'id': %d" % self.source.pk)
        self.assertContains(response, "'shastra_id': %d" % another_shastra.pk)
        self.assertContains(response,
                            "'shastra_id': %d" % self.source.shastra.pk)
        self.assertContains(
            response,
            ("'title': '%s&nbsp;&nbsp;<a class=\"lakshmi-detail\" " +
             "href=\"%s\" title=\"Edit\"><i class=\"fas fa-edit\"></i></a>'") %
            (another_shastra.title,
             reverse("shastra-update",
                     urlconf="shastra_compedium.urls",
                     args=[another_shastra.pk])))
        self.assertContains(
            response,
            ("'title': '%s&nbsp;&nbsp;<a class=\"lakshmi-detail\" " +
             "href=\"%s\" title=\"Edit\"><i class=\"fas fa-edit\"></i></a>'") %
            (self.source.shastra.title,
             reverse("shastra-update",
                     urlconf="shastra_compedium.urls",
                     args=[self.source.shastra.pk])))

        self.assertContains(response,
                            "'publication': '%s'" % self.source.title)
        self.assertContains(response, "'publication': 'No Source Available'")
        self.assertContains(
            response, ('<a class="lakshmi-detail" href="%s" title="Edit"><i ' +
                       'class="fas fa-edit"></i></a>') %
            (reverse("source-update",
                     urlconf="shastra_compedium.urls",
                     args=[self.source.pk])))
        self.assertContains(
            response,
            ('%s&nbsp;&nbsp;<a class="lakshmi-detail" href="%s?next=%s" ' +
             'title="Edit"><i class="fas fa-edit"></i></a>') %
            (another_detail.position.category.name,
             reverse("category-update",
                     urlconf="shastra_compedium.urls",
                     args=[another_detail.position.category.pk]), self.url))
        self.assertContains(
            response,
            ('%s&nbsp;&nbsp;<a class="lakshmi-detail" href="%s?next=%s" ' +
             'title="Edit"><i class="fas fa-edit"></i></a>') %
            (self.detail.position.category.name,
             reverse("category-update",
                     urlconf="shastra_compedium.urls",
                     args=[self.detail.position.category.pk]), self.url))
        self.assertContains(
            response,
            ('<a class="lakshmi-detail" href="%s" title="Edit Chapter"><i ' +
             'class="fas fa-edit"></i></a>') %
            reverse("categorydetail-update",
                    urlconf="shastra_compedium.urls",
                    args=[chapter.pk]))