Пример #1
0
 def test_metadata(self):
     metaTrad = SourceMetadata(name="Traductor")
     metaTrad.save()
     metaInfo = SourceInfos(metadata=metaTrad, value="Thomas Hobbes")
     metaInfo.save()
     self.odyssey.metadatas.add(metaInfo)
     self.assertEqual(self.odyssey.metadatas.count(), 1)
Пример #2
0
 def test_to_dict(self):
     homer = Author(surname="Homer", folder=self.folder)
     homer.save()
     metaTrad = SourceMetadata(name="Traductor")
     metaTrad.save()
     metaInfo = SourceInfos(metadata=metaTrad, value="Thomas Hobbes")
     metaInfo.save()
     self.odyssey.authors.add(homer)
     self.odyssey.metadatas.add(metaInfo)
     self.assertEqual(self.odyssey.to_dict(),
                      {'title': 'Odyssey', 'authors': [homer.pk],
                       'metadata': [{metaTrad.name: metaInfo.value}]})
Пример #3
0
 def test_not_colliding_metadatas(self):
     henryTest = Author(first_name="Henry", last_name="Test", surname="",
                        folder=self.folder)
     henryTest.save()
     metadata = SourceMetadata(name='Editeur')
     metadata.save()
     # Metadata entered with initial lowercase ("editeur")
     # should be recognized as the uppercase initial ("Editeur")
     self.client.login(username='******', password='******')
     response = self.client.post(reverse(addSource),
                                 {'title': 'A test source',
                                  'authors': henryTest.pk,
                                  'metadatas': '{"editeur":"Flammarion", "Collection":"collec"}'
                                  })
     self.assertEqual(response.status_code, 200)
     self.assertEqual(SourceMetadata.objects.filter(
         name__icontains="editeur"
     ).count(), 1)