def test_get_positiondetail(self):
     obj = PositionDetailFactory()
     obj.sources.add(SourceFactory())
     response = self.client.get('/admin/shastra_compedium/positiondetail/',
                                follow=True)
     self.assertContains(response, obj.position.name)
     self.assertContains(response, '<td class="field-source_count">1</td>')
 def test_get_source(self):
     obj = SourceFactory(shastra__author="Author")
     response = self.client.get('/admin/shastra_compedium/source/',
                                follow=True)
     self.assertContains(response, obj.shastra.title)
     self.assertContains(response, obj.shastra.author)
     self.assertContains(response, obj.shastra.min_age)
     self.assertContains(response, obj.shastra.max_age)
 def setUp(self):
     self.client = Client()
     self.user = UserFactory()
     self.source = SourceFactory()
     self.detail = PositionDetailFactory(usage="Meaning")
     self.detail.sources.add(self.source)
     self.detail.save()
     self.url = reverse(self.view_name, urlconf="shastra_compedium.urls")
 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))
Exemplo n.º 5
0
 def chapter_data(self):
     self.category = CategoryFactory()
     self.source = SourceFactory()
     return {'sources': [self.source.pk],
             'category': self.category.pk,
             'usage': "test",
             'chapter': 1,
             'contents': "Contents",
             'position_text': "Position text",
             'verse_start': 10,
             'verse_end': 20,
             'step': 0,
             'next': True}
Exemplo n.º 6
0
 def position_data(self):
     self.source = SourceFactory()
     self.position = PositionFactory()
     return {'0-sources': [self.source.pk],
             '0-usage': "Meaning",
             '0-position': self.position.pk,
             '0-chapter': 1,
             '0-verse_start': 10,
             '0-verse_end': 20,
             '0-posture': "Posture text",
             '0-contents': "Meaning text",
             'step': 1,
             'num_rows': 1,
             'finish': True}
 def test_get_shastra(self):
     obj = SourceFactory()
     response = self.client.get('/admin/shastra_compedium/shastra/',
                                follow=True)
     self.assertContains(response, obj.shastra.title)
     self.assertContains(response, '<td class="field-source_count">1</td>')