def setUp(self): """ Import a resource to test the workflow changes for """ test_utils.set_index_active(False) test_utils.setup_test_storage() # create Groups trgroup = Group.objects.create(name="technicalReviewers") ecgroup = Group.objects.create(name='ecmembers') owner = User.objects.create_user('ecuser', '*****@*****.**', 'secret') owner.groups.add(ecgroup) owner.is_staff = True owner.save() # create a superuser su = User.objects.create_user('su', '*****@*****.**', 'supwd') su.is_superuser = True su.is_staff = True su.save() # load first resource _fixture = '{0}/repository/fixtures/testfixture.xml'.format(ROOT_PATH) _result = test_utils.import_xml(_fixture) _result.owners.add(su) # load second resource _fixture = '{0}/repository/test_fixtures/ingested-corpus-text-French.xml'.format( ROOT_PATH) _result = test_utils.import_xml(_fixture) _result.owners.add(su)
def setUpClass(cls): """ Set up the test """ LOGGER.info("running '{}' tests...".format(cls.__name__)) # disable indexing during import test_utils.set_index_active(False) # import resources test_utils.setup_test_storage() OBJECT_XML_CACHE.clear() test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "partial-corpus.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip( "{}/repository/fixtures/full-resources/" "full-lang-description.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip( "{}/repository/fixtures/full-resources/" "full-lex-conceptual.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-text.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-tool-service.xml".format(ROOT_PATH)) # enable indexing test_utils.set_index_active(True) # update index update_index.Command().handle(using=[ settings.TEST_MODE_NAME, ])
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')
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')
def tearDown(self): """ Clean up the test """ test_utils.clean_resources_db() test_utils.clean_storage() test_utils.clean_user_db() test_utils.set_index_active(True)
def tearDownClass(cls): """ Clean up the test """ test_utils.clean_resources_db() test_utils.clean_storage() test_utils.clean_user_db() test_utils.set_index_active(True) LOGGER.info("finished '{}' tests".format(cls.__name__))
def setUpClass(cls): """ set up test users with and without sync 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. """ LOGGER.info("running '{}' tests...".format(cls.__name__)) set_index_active(False) test_utils.setup_test_storage() syncuser = User.objects.create_user('syncuser', '*****@*****.**', 'secret') syncpermission = Permission.objects.get(codename='can_sync') syncuser.user_permissions.add(syncpermission) syncuser.save() User.objects.create_user('normaluser', '*****@*****.**', 'secret') editoruser = User.objects.create_user('editoruser', '*****@*****.**', 'secret') editoruser.is_staff = True globaleditors = Group.objects.get(name='globaleditors') editoruser.groups.add(globaleditors) editoruser.save() # login POST dicts MetadataSyncTest.syncuser_login = { LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } MetadataSyncTest.normal_login = { LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } MetadataSyncTest.editor_login = { LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } testres = cls.import_test_resource('testfixture.xml', INGESTED) testres.storage_object.digest_modified = datetime.date(2012, 6, 1) testres.storage_object.save() cls.import_test_resource('roundtrip.xml', INTERNAL) pubres = cls.import_test_resource('ILSP10.xml', PUBLISHED) pubres.storage_object.digest_modified = datetime.date(2012, 1, 1) pubres.storage_object.save()
def setUpClass(cls): """ set up test users with and without sync 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. """ set_index_active(False) syncuser = User.objects.create_user('syncuser', '*****@*****.**', 'secret') syncpermission = Permission.objects.get(codename='can_sync') syncuser.user_permissions.add(syncpermission) syncuser.save() User.objects.create_user('normaluser', '*****@*****.**', 'secret') editoruser = User.objects.create_user('editoruser', '*****@*****.**', 'secret') editoruser.is_staff = True globaleditors = Group.objects.get(name='globaleditors') editoruser.groups.add(globaleditors) editoruser.save() # login POST dicts MetadataSyncTest.syncuser_login = { LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } MetadataSyncTest.normal_login = { LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } MetadataSyncTest.editor_login = { LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } StorageObject.objects.all().delete() testres = cls.import_test_resource('testfixture.xml', INGESTED) testres.storage_object.digest_modified = datetime.date(2012, 6, 1) testres.storage_object.save() cls.import_test_resource('roundtrip.xml', INTERNAL) pubres = cls.import_test_resource('ILSP10.xml', PUBLISHED) pubres.storage_object.digest_modified = datetime.date(2012, 1, 1) pubres.storage_object.save()
def testSingleResourceView(self): """ Checks that each resource's single view is displayed correctly. """ # disable indexing; we don't need stat updates for this test test_utils.set_index_active(False) queryset = resourceInfoType_model.objects.all() check_resource_view(queryset, self) # enable indexing test_utils.set_index_active(True)
def setUpClass(cls): """ Set up the test """ LOGGER.info("running '{}' tests...".format(cls.__name__)) # disable indexing during import test_utils.set_index_active(False) # import resources test_utils.setup_test_storage() OBJECT_XML_CACHE.clear() test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "partial-corpus.xml".format(ROOT_PATH))
def tearDownClass(cls): """ Clean up the test """ LOGGER.info("finished '{}' tests".format(cls.__name__)) # disable indexing during import test_utils.set_index_active(False) test_utils.clean_resources_db() test_utils.clean_storage() OBJECT_XML_CACHE.clear() # enable indexing test_utils.set_index_active(True)
def tearDown(self): """ Clean up the test """ # disable indexing during import test_utils.set_index_active(False) test_utils.clean_resources_db() test_utils.clean_storage() OBJECT_XML_CACHE.clear() # enable indexing test_utils.set_index_active(True) # update index rebuild_index.Command().handle()
def setUp(self): """ Set up the test """ # disable indexing during import test_utils.set_index_active(False) # import resources test_utils.setup_test_storage() OBJECT_XML_CACHE.clear() test_utils.import_xml_or_zip(RESOURCES_ZIP_FILE) # enable indexing test_utils.set_index_active(True) # update index rebuild_index.Command().handle()
def tearDownClass(cls): """ Clean up the test """ LOGGER.info("finished '{}' tests".format(cls.__name__)) # disable indexing during import test_utils.set_index_active(False) test_utils.clean_resources_db() test_utils.clean_storage() OBJECT_XML_CACHE.clear() # enable indexing test_utils.set_index_active(True) # update index update_index.Command().handle(using=[settings.TEST_MODE_NAME,])
def setUpClass(cls): """ Set up the test """ LOGGER.info("running '{}' tests...".format(cls.__name__)) # disable indexing during import test_utils.set_index_active(False) # import resources test_utils.setup_test_storage() OBJECT_XML_CACHE.clear() test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "partial-corpus.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip( "{}/repository/fixtures/full-resources/" "full-lang-description.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip( "{}/repository/fixtures/full-resources/" "full-lex-conceptual.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-text.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-image.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-audio.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-video.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip( "{}/repository/fixtures/full-resources/" "full-corpus-textngram.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip( "{}/repository/fixtures/full-resources/" "full-corpus-textnumerical.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-tool-service.xml".format(ROOT_PATH)) # enable indexing test_utils.set_index_active(True) # update index from django.core.management import call_command call_command('rebuild_index', interactive=False, using=TEST_MODE_NAME)
def setUp(self): """ Import a resource to test the workflow changes for """ 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) test_utils.create_manager_user( 'manageruser', '*****@*****.**', 'secret', (_test_editor_group, _test_manager_group)) _fixture = '{0}/repository/fixtures/testfixture.xml'.format(ROOT_PATH) _result = test_utils.import_xml(_fixture) _result.editor_groups.add(_test_editor_group) StatusWorkflowTest.resource_id = _result.id
def deactivated_testSingleResourceViewAll(self): """ Checks that each resource's single view is displayed correctly. """ # disable indexing; we don't need stat updates for this test test_utils.set_index_active(False) count = 0 error_atts = [] for _res in resourceInfoType_model.objects.all(): parent_dict = {} _res.export_to_elementtree(pretty=True, parent_dict=parent_dict) count += 1 LOGGER.info("calling {}. resource at {}".format( count, _res.get_absolute_url())) # always create a new client to force a new session client = Client() response = client.get(_res.get_absolute_url(), follow = True) self.assertEquals(200, response.status_code) self.assertTemplateUsed(response, 'repository/lr_view.html') for _ele in parent_dict: if not _ele.text: continue text = smart_str(xml_utils.html_escape(_ele.text), response._charset) real_count = response.content.count(text) if real_count == 0: path = self.path_to_root(_ele, parent_dict) if "email" in path \ or "metaShareId" in path: continue LOGGER.error(u"missing {}: {}".format(path, _ele.text)) error_atts.append(path) # TODO activate when single resource view is complete #self.assertContains(response, xml_utils.html_escape(_ele.text)) if LOGGER.isEnabledFor(logging.WARN): LOGGER.warn("missing paths:") for path in sorted(set(error_atts)): LOGGER.warn(path) # enable indexing test_utils.set_index_active(True)
def tearDownClass(cls): """ Clean up the test """ LOGGER.info("finished '{}' tests".format(cls.__name__)) # disable indexing during import test_utils.set_index_active(False) test_utils.clean_resources_db() test_utils.clean_storage() OBJECT_XML_CACHE.clear() # enable indexing test_utils.set_index_active(True) # update index from django.core.management import call_command call_command('rebuild_index', interactive=False, using=TEST_MODE_NAME)
def setUpClass(cls): """ Set up the test """ LOGGER.info("running '{}' tests...".format(cls.__name__)) # disable indexing during import test_utils.set_index_active(False) # import resources test_utils.setup_test_storage() OBJECT_XML_CACHE.clear() test_utils.import_xml_or_zip(RESOURCES_ZIP_FILE) # enable indexing test_utils.set_index_active(True) # update index from django.core.management import call_command call_command('rebuild_index', interactive=False, using=TEST_MODE_NAME)
def testSingleResourceView(self): """ Checks that each resource's single view is displayed correctly. """ # disable indexing; we don't need stat updates for this test test_utils.set_index_active(False) count = 0 for _res in resourceInfoType_model.objects.all(): count += 1 LOGGER.info("calling {}. resource at {}".format(count, _res.get_absolute_url())) # always create a new client to force a new session client = Client() response = client.get(_res.get_absolute_url(), follow = True) self.assertEquals(200, response.status_code) self.assertTemplateUsed(response, 'repository/resource_view/lr_view.html') self.assertContains(response, xml_utils.html_escape(_res.real_unicode_())) # enable indexing test_utils.set_index_active(True)
def test_single_resource_view(self): """ Checks that each resource's single view is displayed correctly. """ # disable indexing; we don't need stat updates for this test test_utils.set_index_active(False) count = 0 for _res in resourceInfoType_model.objects.all(): count += 1 LOGGER.info("calling {}. resource at {}".format(count, _res.get_absolute_url())) # always create a new client to force a new session client = Client() response = client.get(_res.get_absolute_url(), follow = True) self.assertEquals(200, response.status_code) self.assertTemplateUsed(response, 'repository/resource_view/lr_view.html') self.assertContains(response, xml_utils.html_escape(_res.real_unicode_())) # enable indexing test_utils.set_index_active(True)
def setUpClass(cls): """ set up test users with and without sync 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. """ LOGGER.info("running '{}' tests...".format(cls.__name__)) set_index_active(False) test_utils.setup_test_storage() syncuser = User.objects.create_user("syncuser", "*****@*****.**", "secret") syncpermission = Permission.objects.get(codename="can_sync") syncuser.user_permissions.add(syncpermission) syncuser.save() User.objects.create_user("normaluser", "*****@*****.**", "secret") editoruser = User.objects.create_user("editoruser", "*****@*****.**", "secret") editoruser.is_staff = True globaleditors = Group.objects.get(name="globaleditors") editoruser.groups.add(globaleditors) editoruser.save() # login POST dicts MetadataSyncTest.syncuser_login = {LOGIN_FORM_KEY: 1, "username": "******", "password": "******"} MetadataSyncTest.normal_login = {LOGIN_FORM_KEY: 1, "username": "******", "password": "******"} MetadataSyncTest.editor_login = {LOGIN_FORM_KEY: 1, "username": "******", "password": "******"} testres = cls.import_test_resource("testfixture.xml", INGESTED) testres.storage_object.digest_modified = datetime.date(2012, 6, 1) testres.storage_object.save() cls.import_test_resource("roundtrip.xml", INTERNAL) pubres = cls.import_test_resource("ILSP10.xml", PUBLISHED) pubres.storage_object.digest_modified = datetime.date(2012, 1, 1) pubres.storage_object.save()
def setUpClass(cls): """ Set up the test """ LOGGER.info("running '{}' tests...".format(cls.__name__)) # disable indexing during import test_utils.set_index_active(False) # import resources test_utils.setup_test_storage() OBJECT_XML_CACHE.clear() test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "partial-corpus.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-lang-description.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-lex-conceptual.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-text.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-image.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-audio.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-video.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-textngram.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-textnumerical.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-tool-service.xml".format(ROOT_PATH)) # enable indexing test_utils.set_index_active(True) # update index from django.core.management import call_command call_command('rebuild_index', interactive=False, using=TEST_MODE_NAME)
def tearDownClass(cls): test_utils.set_index_active(True) LOGGER.info("finished '{}' tests".format(cls.__name__))
def tearDownClass(cls): test_utils.set_index_active(True)
def setUpClass(cls): LOGGER.info("running '{}' tests...".format(cls.__name__)) test_utils.set_index_active(False)
def setUpClass(cls): test_utils.set_index_active(False) test_utils.setup_test_storage()
def setUpClass(cls): test_utils.set_index_active(False)
def tearDownClass(cls): # delete content of storage folder test_utils.clean_storage() test_utils.set_index_active(True)
def setUpClass(cls): test_utils.set_index_active(False) test_utils.setup_test_storage() # copy fixtures to storage folder copy_fixtures()
# import resources test_utils.setup_test_storage() OBJECT_XML_CACHE.clear() test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "partial-corpus.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-lang-description.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-lex-conceptual.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-corpus-text.xml".format(ROOT_PATH)) test_utils.import_xml_or_zip("{}/repository/fixtures/full-resources/" "full-tool-service.xml".format(ROOT_PATH)) # enable indexing test_utils.set_index_active(True) # update index update_index.Command().handle(using=[settings.TEST_MODE_NAME,]) @classmethod def tearDownClass(cls): """ Clean up the test """ LOGGER.info("finished '{}' tests".format(cls.__name__)) # disable indexing during import test_utils.set_index_active(False)
def setUpClass(cls): LOGGER.info("running '{}' tests...".format(cls.__name__)) test_utils.set_index_active(False) test_utils.setup_test_storage() # copy fixtures to storage folder copy_fixtures()
def tearDownClass(cls): User.objects.all().delete() StorageObject.objects.all().delete() set_index_active(True)
def setUpClass(cls): set_index_active(False)
def tearDownClass(cls): User.objects.all().delete() test_utils.clean_db() test_utils.clean_storage() set_index_active(True)
def tearDownClass(cls): set_index_active(True)
def tearDownClass(cls): # delete content of storage folder test_utils.clean_storage() test_utils.set_index_active(True) LOGGER.info("finished '{}' tests".format(cls.__name__))