Beispiel #1
0
    def setUp(self):
        self.site = LearningSiteFactory()
        self.collection = ArchivalCollectionFactory()
        self.collection.learning_sites.add(self.site)

        self.url = reverse('collection-edit-view',
                           kwargs={
                               'parent': self.site.id,
                               'pk': self.collection.id
                           })
Beispiel #2
0
 def setUp(self):
     self.site = LearningSiteFactory()
     self.collection = ArchivalCollectionFactory()
     self.link_url = reverse('collection-link-view',
                             kwargs={'parent': self.site.id})
     self.unlink_url = reverse('collection-unlink-view',
                               kwargs={
                                   'parent': self.site.id,
                                   'pk': self.collection.id
                               })
Beispiel #3
0
    def test_convert2(self):
        coll = ArchivalCollectionFactory()

        s = ArchivalCollectionSuggestionFactory(
            collection_title=coll.collection_title,
            repository_title=coll.repository.title,
            latlng=coll.repository.place.latlng,
            title=coll.repository.place.title)

        self.assertEquals(coll, s.convert_to_archival_collection())

        s.refresh_from_db()
        self.assertEquals(s.archival_collection, coll)
Beispiel #4
0
 def test_archival_collection_detail(self):
     collection = ArchivalCollectionFactory()
     url = reverse('collection-detail-view', kwargs={'pk': collection.id})
     response = self.client.get(url)
     self.assertEquals(response.status_code, 200)
Beispiel #5
0
 def setUp(self):
     self.user = UserFactory(username='******')
     self.coll1 = ArchivalCollectionFactory(collection_title='alpha')
     self.coll2 = ArchivalCollectionFactory(collection_title='beta')
Beispiel #6
0
class TestArchivalCollectionUpdateView(TestCase):
    def setUp(self):
        self.site = LearningSiteFactory()
        self.collection = ArchivalCollectionFactory()
        self.collection.learning_sites.add(self.site)

        self.url = reverse('collection-edit-view',
                           kwargs={
                               'parent': self.site.id,
                               'pk': self.collection.id
                           })

    def test_anonymous(self):
        response = self.client.get(self.url)
        self.assertEquals(response.status_code, 302)

        user = UserFactory()
        self.client.login(username=user.username, password='******')
        response = self.client.post(self.url)
        self.assertEquals(response.status_code, 302)

    def test_update(self):
        editor = UserFactory()
        editor.groups.add(GroupFactory(name='Editor'))
        self.client.login(username=editor.username, password='******')

        response = self.client.get(self.url)
        self.assertEquals(response.status_code, 200)

        data = {
            'repository': self.collection.repository.id,
            'repository_title': 'foobarbaz',
            'title': 'Bar',
            'latlng': 'SRID=4326;POINT(1 1)',
            'collection_title': 'Updated',
            'description': '',
            'finding_aid_url': '',
            'linear_feet': '',
            'inclusive-start-millenium1': '2',
            'inclusive-start-century1': '0',
            'inclusive-start-decade1': '0',
            'inclusive-start-year1': '0',
            'inclusive-end-millenium1': '2',
            'inclusive-end-century1': '0',
            'inclusive-end-decade1': '0',
            'inclusive-end-year1': '1',
        }
        response = self.client.post(self.url, data)
        self.assertEquals(response.status_code, 302)

        self.collection.refresh_from_db()
        self.assertEquals(self.collection.collection_title, 'Updated')
        self.assertEquals(self.collection.inclusive_start.edtf_format, '2000')
        self.assertEquals(self.collection.inclusive_end.edtf_format, '2001')

        self.collection.repository.refresh_from_db()
        self.assertEquals(self.collection.repository.title, 'foobarbaz')
        self.collection.repository.place.refresh_from_db()
        self.assertEquals(self.collection.repository.place.title, 'Bar')
        self.assertEquals(self.collection.repository.place.latitude(), 1.0)
        self.assertEquals(self.collection.repository.place.longitude(), 1.0)