Beispiel #1
0
 def setUp(self):
     """
     Sets up some resources with which to test.
     """
     test_utils.setup_test_storage()
     # set up different test resources
     self.non_downloadable_resource = _import_resource('testfixture.xml')
     self.downloadable_resource_1 = \
         _import_resource('downloadable_1_license.xml')
     self.ms_commons_resource = \
         _import_resource('downloadable_ms_commons_license.xml')
     # set up test users with/without staff permissions and with/without
     # META-SHARE full membership
     staffuser = create_user('staffuser', '*****@*****.**', 'secret')
     staffuser.is_staff = True
     staffuser.save()
     create_user('normaluser', '*****@*****.**', 'secret')
     profile_ct = ContentType.objects.get_for_model(UserProfile)
     ms_member = create_user('fullmember', '*****@*****.**', 'secret')
     ms_member.user_permissions.add(Permission.objects.get(
                 content_type=profile_ct, codename='ms_full_member'))
     ms_member.save()
     ms_member = create_user('associatemember', '*****@*****.**', 'secret')
     ms_member.user_permissions.add(Permission.objects.get(
                 content_type=profile_ct, codename='ms_associate_member'))
     ms_member.save()
Beispiel #2
0
    def setUpClass(cls):
        """
        Import a resource to test the workflow changes for
        """
        LOGGER.info("running '{}' tests...".format(cls.__name__))
        test_utils.set_index_active(False)
        test_utils.setup_test_storage()
        _test_editor_group = \
            EditorGroup.objects.create(name='test_editor_group')
        _test_manager_group = \
            EditorGroupManagers.objects.create(name='test_manager_group',
                                               managed_group=_test_editor_group)
        owner = test_utils.create_manager_user(
            'manageruser', '*****@*****.**', 'secret',
            (_test_editor_group, _test_manager_group))

        # load first resource
        _fixture = '{0}/repository/fixtures/testfixture.xml'.format(ROOT_PATH)
        _result = test_utils.import_xml(_fixture)
        _result.editor_groups.add(_test_editor_group)
        _result.owners.add(owner)
        # load second resource
        _fixture = '{0}/repository/test_fixtures/ingested-corpus-AudioVideo-French.xml'.format(
            ROOT_PATH)
        _result = test_utils.import_xml(_fixture)
        _result.editor_groups.add(_test_editor_group)
        _result.owners.add(owner)

        # create a normal user
        test_utils.create_user('user', '*****@*****.**', 'mypasswd')
Beispiel #3
0
 def setUpClass(cls):
     """
     Import a resource to test the workflow changes for
     """
     LOGGER.info("running '{}' tests...".format(cls.__name__))
     test_utils.set_index_active(False)        
     test_utils.setup_test_storage()
     _test_editor_group = \
         EditorGroup.objects.create(name='test_editor_group')
     _test_manager_group = \
         EditorGroupManagers.objects.create(name='test_manager_group',
                                            managed_group=_test_editor_group)            
     owner = test_utils.create_manager_user(
         'manageruser', '*****@*****.**', 'secret',
         (_test_editor_group, _test_manager_group))       
     
     # load first resource
     _fixture = '{0}/repository/fixtures/testfixture.xml'.format(ROOT_PATH)
     _result = test_utils.import_xml(_fixture)
     _result.editor_groups.add(_test_editor_group)
     _result.owners.add(owner)
     # load second resource
     _fixture = '{0}/repository/test_fixtures/ingested-corpus-AudioVideo-French.xml'.format(ROOT_PATH)
     _result = test_utils.import_xml(_fixture)
     _result.editor_groups.add(_test_editor_group)
     _result.owners.add(owner)
     
     # create a normal user
     test_utils.create_user('user', '*****@*****.**', 'mypasswd')
Beispiel #4
0
    def setUp(self):
        """
        Set up the view
        """
        test_utils.setup_test_storage()

        staffuser = create_user("staffuser", "*****@*****.**", "secret")
        staffuser.is_staff = True
        staffuser.save()
        normaluser = create_user("normaluser", "*****@*****.**", "secret")
        normaluser.save()
Beispiel #5
0
 def setUp(self):
     """
     Set up the view
     """
     test_utils.setup_test_storage()                        
  
     staffuser = create_user('staffuser', '*****@*****.**', 'secret')
     staffuser.is_staff = True
     staffuser.save()
     normaluser =  create_user('normaluser', '*****@*****.**', 'secret')
     normaluser.save()
Beispiel #6
0
 def setUp(self):
     """
     Import test fixtures and add resource pairs to TogetherManager
     """
     test_utils.setup_test_storage()
     test_utils.clean_stats()
     self.res_1 = _import_downloadable_resource('elra112.xml')
     self.res_2 = _import_downloadable_resource('elra135.xml')
     self.res_3 = _import_downloadable_resource('elra260.xml')
     self.res_4 = _import_downloadable_resource('elra295.xml')
     create_user('normaluser', '*****@*****.**', 'secret')
     create_user('normaluser2', '*****@*****.**', 'secret')
Beispiel #7
0
 def setUp(self):
     """
     Import test fixtures and add resource pairs to TogetherManager
     """
     test_utils.setup_test_storage()
     test_utils.clean_stats()
     self.res_1 = _import_downloadable_resource('elra112.xml')
     self.res_2 = _import_downloadable_resource('elra135.xml')
     self.res_3 = _import_downloadable_resource('elra260.xml')
     self.res_4 = _import_downloadable_resource('elra295.xml')
     create_user('normaluser', '*****@*****.**', 'secret')
     create_user('normaluser2', '*****@*****.**', 'secret')
Beispiel #8
0
 def setUpClass(cls):
     """
     Set up the view
     """
     test_utils.setup_test_storage()                        
  
     staffuser = create_user('staffuser', '*****@*****.**', 'secret')
     staffuser.is_staff = True
     staffuser.save()
     create_user('normaluser', '*****@*****.**', 'secret')
     # Make sure the index does not contain any stale entries:
     call_command('rebuild_index', interactive=False, using=settings.TEST_MODE_NAME)
     cls.importPublishedFixtures()
Beispiel #9
0
 def setUp(self):
     """
     Sets up some resources with which to test.
     """
     test_utils.setup_test_storage()
     # set up different test resources
     self.non_downloadable_resource = _import_resource('ILSP10.xml')
     self.downloadable_resource_1 = \
         _import_resource('downloadable_1_license.xml')
     self.downloadable_resource_3 = \
         _import_resource('downloadable_3_licenses.xml')
     self.ms_commons_resource = \
         _import_resource('downloadable_ms_commons_license.xml')
     self.local_download_resource = \
         _import_resource('local_download.xml')
     # assign and copy downloadable resource
     self.local_download_resource.storage_object.checksum = \
         '3930f5022aff02c7fa27ffabf2eaaba0'
     self.local_download_resource.storage_object.save()
     self.local_download_resource.storage_object.update_storage()
     shutil.copyfile(
         '{0}/repository/fixtures/archive.zip'.format(settings.ROOT_PATH),
         '{0}/{1}/archive.zip'.format(
             settings.STORAGE_PATH,
             self.local_download_resource.storage_object.identifier))
     # set up test users with/without staff permissions and with/without
     # META-SHARE full membership
     staffuser = create_user('staffuser', '*****@*****.**', 'secret')
     staffuser.is_staff = True
     staffuser.save()
     create_user('normaluser', '*****@*****.**', 'secret')
     profile_ct = ContentType.objects.get_for_model(UserProfile)
     ms_full_member_perm = Permission.objects.get(content_type=profile_ct,
                                                  codename='ms_full_member')
     ms_member = create_user('fullmember', '*****@*****.**', 'secret')
     ms_member.user_permissions.add(ms_full_member_perm)
     ms_member.save()
     ms_member = create_user('associatemember', '*****@*****.**', 'secret')
     ms_member.user_permissions.add(
         Permission.objects.get(content_type=profile_ct,
                                codename='ms_associate_member'))
     ms_member.save()
     # create a test organization with META-SHARE full membership
     test_organization_ms = Organization.objects.create(
         name='test_organization_ms')
     test_organization_ms.permissions.add(ms_full_member_perm)
     test_organization_ms.save()
     test_utils.create_organization_member('organization_member_ms',
                                           '*****@*****.**', 'secret',
                                           (test_organization_ms, ))
Beispiel #10
0
 def setUp(self):
     """
     Set up the detail view
     """
     test_utils.setup_test_storage()
     self.resource = _import_resource('testfixture.xml')
     # set up test users with and without staff permissions.
     # These will live in the test database only, so will not
     # pollute the "normal" development db or the production db.
     # As a consequence, they need no valuable password.
     staffuser = create_user('staffuser', '*****@*****.**', 'secret')
     staffuser.is_staff = True
     staffuser.save()
     create_user('normaluser', '*****@*****.**', 'secret')
Beispiel #11
0
class DownloadViewTest(TestCase):
    """
    Tests for the license selection, license agreement and download views.
    """
    
    @classmethod
    def setUpClass(cls):
        LOGGER.info("running '{}' tests...".format(cls.__name__))
        test_utils.set_index_active(False)
    
    @classmethod
    def tearDownClass(cls):
        test_utils.set_index_active(True)
        LOGGER.info("finished '{}' tests".format(cls.__name__))
        
    def setUp(self):
        """
        Sets up some resources with which to test.
        """
        test_utils.setup_test_storage()
        # set up different test resources
        self.non_downloadable_resource = _import_resource('ILSP10.xml')
        self.downloadable_resource_1 = \
            _import_resource('downloadable_1_license.xml')
        self.downloadable_resource_3 = \
            _import_resource('downloadable_3_licenses.xml')
        self.cc_by_nc_resource = \
            _import_resource('downloadable_cc_by_nc_license.xml')
        self.local_download_resource = \
            _import_resource('local_download.xml')
        # assign and copy downloadable resource
        self.local_download_resource.storage_object.checksum = \
            '3930f5022aff02c7fa27ffabf2eaaba0'
        self.local_download_resource.storage_object.save()
        self.local_download_resource.storage_object.update_storage()
        shutil.copyfile(
          '{0}/repository/fixtures/archive.zip'.format(settings.ROOT_PATH),
          '{0}/{1}/archive.zip'.format(
            settings.STORAGE_PATH, self.local_download_resource.storage_object.identifier))
        # set up test users with/without staff permissions and with/without
        # META-SHARE full membership
        staffuser = create_user('staffuser', '*****@*****.**', 'secret')
        staffuser.is_staff = True
        staffuser.save()
        create_user('normaluser', '*****@*****.**', 'secret')
        profile_ct = ContentType.objects.get_for_model(UserProfile)
        ms_full_member_perm = Permission.objects.get(content_type=profile_ct,
                                                     codename='ms_full_member')
Beispiel #12
0
 def setUp(self):
     """
     Set up the view
     """
     test_utils.setup_test_storage()                        
     normaluser =  create_user('normaluser', '*****@*****.**', 'secret')
     normaluser.save()
Beispiel #13
0
 def setUp(self):
     """
     Set up the detail view
     """
     test_utils.setup_test_storage()
     create_user('normaluser', '*****@*****.**', 'secret')
     _test_editor_group = EditorGroup.objects.create(
                                                 name='test_editor_group')
     self.resource = _import_resource('testfixture.xml',
                                      _test_editor_group)
     ViewTest.test_editor = test_utils.create_editor_user('editoruser',
         '*****@*****.**', 'secret', (_test_editor_group,))          
     test_utils.create_manager_user('manageruser', '*****@*****.**',
         'secret', (EditorGroupManagers.objects.create(
                         name='test_editor_group_manager',
                         managed_group=_test_editor_group),))
Beispiel #14
0
 def setUp(self):
     """
     Set up the detail view
     """
     test_utils.setup_test_storage()
     create_user('normaluser', '*****@*****.**', 'secret')
     _test_editor_group = EditorGroup.objects.create(
                                                 name='test_editor_group')
     self.resource = _import_resource('testfixture.xml',
                                      _test_editor_group)
     ViewTest.test_editor = test_utils.create_editor_user('editoruser',
         '*****@*****.**', 'secret', (_test_editor_group,))          
     test_utils.create_manager_user('manageruser', '*****@*****.**',
         'secret', (EditorGroupManagers.objects.create(
                         name='test_editor_group_manager',
                         managed_group=_test_editor_group),))
Beispiel #15
0
 def setUp(self):
     """
     Sets up some resources with which to test.
     """
     test_utils.setup_test_storage()
     # set up different test resources
     self.non_downloadable_resource = _import_resource('ILSP10.xml')
     self.downloadable_resource_1 = \
         _import_resource('downloadable_1_license.xml')
     self.downloadable_resource_3 = \
         _import_resource('downloadable_3_licenses.xml')
     self.ms_commons_resource = \
         _import_resource('downloadable_ms_commons_license.xml')
     self.local_download_resource = \
         _import_resource('local_download.xml')
     # assign and copy downloadable resource
     self.local_download_resource.storage_object.checksum = \
         '3930f5022aff02c7fa27ffabf2eaaba0'
     self.local_download_resource.storage_object.save()
     self.local_download_resource.storage_object.update_storage()
     shutil.copyfile(
       '{0}/repository/fixtures/archive.zip'.format(settings.ROOT_PATH),
       '{0}/{1}/archive.zip'.format(
         settings.STORAGE_PATH, self.local_download_resource.storage_object.identifier))
     # set up test users with/without staff permissions and with/without
     # META-SHARE full membership
     staffuser = create_user('staffuser', '*****@*****.**', 'secret')
     staffuser.is_staff = True
     staffuser.save()
     create_user('normaluser', '*****@*****.**', 'secret')
     profile_ct = ContentType.objects.get_for_model(UserProfile)
     ms_full_member_perm = Permission.objects.get(content_type=profile_ct,
                                                  codename='ms_full_member')
     ms_member = create_user('fullmember', '*****@*****.**', 'secret')
     ms_member.user_permissions.add(ms_full_member_perm)
     ms_member.save()
     ms_member = create_user('associatemember', '*****@*****.**', 'secret')
     ms_member.user_permissions.add(Permission.objects.get(
                 content_type=profile_ct, codename='ms_associate_member'))
     ms_member.save()
     # create a test organization with META-SHARE full membership
     test_organization_ms = Organization.objects.create(
                                                 name='test_organization_ms')
     test_organization_ms.permissions.add(ms_full_member_perm)
     test_organization_ms.save()
     test_utils.create_organization_member('organization_member_ms',
         '*****@*****.**', 'secret', (test_organization_ms,))
Beispiel #16
0
    def setUp(self):
        """
        Set up the view
        """
        test_utils.setup_test_storage()
        clear_index.Command().handle(interactive=False,
                                     using=[
                                         settings.TEST_MODE_NAME,
                                     ])
        normaluser = create_user('normaluser', '*****@*****.**', 'secret')
        normaluser.save()

        # create an groups used to get the proper results
        Group.objects.create(name='ecmembers')
        Group.objects.create(name='elrcReviewers')
Beispiel #17
0
        self.local_download_resource.storage_object.save()
        self.local_download_resource.storage_object.update_storage()
        shutil.copyfile(
          '{0}/repository/fixtures/archive.zip'.format(settings.ROOT_PATH),
          '{0}/{1}/archive.zip'.format(
            settings.STORAGE_PATH, self.local_download_resource.storage_object.identifier))
        # set up test users with/without staff permissions and with/without
        # META-SHARE full membership
        staffuser = create_user('staffuser', '*****@*****.**', 'secret')
        staffuser.is_staff = True
        staffuser.save()
        create_user('normaluser', '*****@*****.**', 'secret')
        profile_ct = ContentType.objects.get_for_model(UserProfile)
        ms_full_member_perm = Permission.objects.get(content_type=profile_ct,
                                                     codename='ms_full_member')
        ms_member = create_user('fullmember', '*****@*****.**', 'secret')
        ms_member.user_permissions.add(ms_full_member_perm)
        ms_member.save()
        ms_member = create_user('associatemember', '*****@*****.**', 'secret')
        ms_member.user_permissions.add(Permission.objects.get(
                    content_type=profile_ct, codename='ms_associate_member'))
        ms_member.save()
        # create a test organization with META-SHARE full membership
        test_organization_ms = Organization.objects.create(
                                                    name='test_organization_ms')
        test_organization_ms.permissions.add(ms_full_member_perm)
        test_organization_ms.save()
        test_utils.create_organization_member('organization_member_ms',
            '*****@*****.**', 'secret', (test_organization_ms,))

    def tearDown(self):