def setUp(self): self.test_user = test_utils.create_editor_user( UserProfileTest.test_login['username'], '*****@*****.**', UserProfileTest.test_login['password'], (UserProfileTest.test_editor_group_1,)) self.client = test_utils.get_client_with_user_logged_in( UserProfileTest.test_login)
def setUp(self): UserProfileTest.test_login = { REDIRECT_FIELD_NAME: '/{}'.format(DJANGO_BASE), LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } # create some test organizations UserProfileTest.test_organization_1 = \ Organization.objects.create(name='test_organization_1') UserProfileTest.test_organization_2 = \ Organization.objects.create(name='test_organization_2') # create some test editor groups UserProfileTest.test_editor_group_1 = \ EditorGroup.objects.create(name='test_editor_group_1') UserProfileTest.test_editor_group_2 = \ EditorGroup.objects.create(name='test_editor_group_2') # get the two META-SHARE membership permissions _profile_ct = ContentType.objects.get_for_model(UserProfile) UserProfileTest.ms_full_member_perm = Permission.objects.get( content_type=_profile_ct, codename='ms_full_member') UserProfileTest.ms_assoc_member_perm = Permission.objects.get( content_type=_profile_ct, codename='ms_associate_member') self.test_user = test_utils.create_editor_user( UserProfileTest.test_login['username'], '*****@*****.**', UserProfileTest.test_login['password'], (UserProfileTest.test_editor_group_1,)) self.client = test_utils.get_client_with_user_logged_in( UserProfileTest.test_login)
def setUp(self): UserProfileTest.test_login = { REDIRECT_FIELD_NAME: '/{}'.format(DJANGO_BASE), LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } # create some test organizations UserProfileTest.test_organization_1 = \ Organization.objects.create(name='test_organization_1') UserProfileTest.test_organization_2 = \ Organization.objects.create(name='test_organization_2') # create some test editor groups UserProfileTest.test_editor_group_1 = \ EditorGroup.objects.create(name='test_editor_group_1') UserProfileTest.test_editor_group_2 = \ EditorGroup.objects.create(name='test_editor_group_2') # get the two META-SHARE membership permissions _profile_ct = ContentType.objects.get_for_model(UserProfile) UserProfileTest.ms_full_member_perm = Permission.objects.get( content_type=_profile_ct, codename='ms_full_member') UserProfileTest.ms_assoc_member_perm = Permission.objects.get( content_type=_profile_ct, codename='ms_associate_member') self.test_user = test_utils.create_editor_user( UserProfileTest.test_login['username'], '*****@*****.**', UserProfileTest.test_login['password'], (UserProfileTest.test_editor_group_1, )) self.client = test_utils.get_client_with_user_logged_in( UserProfileTest.test_login)
def setUpClass(cls): """ Sets up this test case. """ LOGGER.info("running '{}' tests...".format(cls.__name__)) FrontpageTest.editor_user = test_utils.create_editor_user('editoruser', '*****@*****.**', FrontpageTest.editor_user_password, (EditorGroup.objects.create(name='test_editor_group'),))
def setUp(self): """ Set up logic for each test. """ FrontpageTest.editor_user = test_utils.create_editor_user('editoruser', '*****@*****.**', FrontpageTest.editor_user_password, (EditorGroup.objects.create(name='test_editor_group'),)) self.client = Client()
def setUpClass(cls): """ Sets up this test case. """ LOGGER.info("running '{}' tests...".format(cls.__name__)) FrontpageTest.editor_user = test_utils.create_editor_user( 'editoruser', '*****@*****.**', FrontpageTest.editor_user_password, (EditorGroup.objects.create(name='test_editor_group'), ))
def setUp(self): self.test_user = test_utils.create_editor_user( UserProfileTest.test_login['username'], '*****@*****.**', UserProfileTest.test_login['password']) #create the profile UserProfile.objects.create(user= self.test_user, \ affiliation = "AFF", \ country = "Greece", ) self.client = test_utils.get_client_with_user_logged_in( UserProfileTest.test_login)
def setUp(self): # create an editor group and a manager group for this group self.test_editor_group = EditorGroup.objects.create( name='test_editor_group') self.test_manager_group = EditorGroupManagers.objects.create( name='test_manager_group', managed_group=self.test_editor_group) # create an editor group managing user self.manager_user = test_utils.create_manager_user('manageruser', '*****@*****.**', 'secret', (self.test_editor_group, self.test_manager_group)) self.manager_user.get_profile().default_editor_groups \ .add(self.test_editor_group) # create an editor user test_utils.create_editor_user('editoruser', '*****@*****.**', 'secret', (self.test_editor_group,)) # make sure the index does not contain any stale entries call_command('rebuild_index', interactive=False, using=settings.TEST_MODE_NAME) super(EditorTest, self).setUp() self.base_url = 'http://{}:{}/{}' \ .format(self.testserver_host, self.testserver_port, DJANGO_BASE) self.verification_errors = []
def setUp(self): # create an editor group and a manager group for this group self.test_editor_group = EditorGroup.objects.create( name='test_editor_group') self.test_manager_group = ManagerGroup.objects.create( name='test_manager_group', managed_group=self.test_editor_group) # create an editor group managing user test_utils.create_manager_user('manageruser', '*****@*****.**', 'secret', (self.test_editor_group, self.test_manager_group)) # create an editor user test_utils.create_editor_user('editoruser', '*****@*****.**', 'secret', (self.test_editor_group,)) # make sure the index does not contain any stale entries call_command('rebuild_index', interactive=False, using=settings.TEST_MODE_NAME) # init Selenium driver = getattr(webdriver, settings.SELENIUM_DRIVER, None) assert driver, "settings.SELENIUM_DRIVER contains non-existing driver" self.driver = driver() self.driver.implicitly_wait(30) host = getattr(settings, 'SELENIUM_TESTSERVER_HOST', 'localhost') port = getattr(settings, 'SELENIUM_TESTSERVER_PORT', 8000) self.base_url = 'http://{0}:{1}/{2}'.format(host, port, DJANGO_BASE) self.verification_errors = []
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),))
def setUpClass(cls): """ 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. """ EditorTest.test_editor_group = EditorGroup.objects.create( name='test_editor_group') EditorTest.test_manager_group = \ ManagerGroup.objects.create(name='test_manager_group', managed_group=EditorTest.test_editor_group) staffuser = User.objects.create_user('staffuser', '*****@*****.**', 'secret') staffuser.is_staff = True staffuser.save() User.objects.create_user('normaluser', '*****@*****.**', 'secret') editoruser = test_utils.create_editor_user('editoruser', '*****@*****.**', 'secret', (EditorTest.test_editor_group,)) test_utils.create_manager_user( 'manageruser', '*****@*****.**', 'secret', (EditorTest.test_editor_group, EditorTest.test_manager_group)) User.objects.create_superuser('superuser', '*****@*****.**', 'secret') # login POST dicts EditorTest.staff_login = { REDIRECT_FIELD_NAME: ADMINROOT, LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } EditorTest.normal_login = { REDIRECT_FIELD_NAME: ADMINROOT, LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } EditorTest.editor_login = { REDIRECT_FIELD_NAME: ADMINROOT, LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } EditorTest.manager_login = { REDIRECT_FIELD_NAME: ADMINROOT, LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } EditorTest.superuser_login = { REDIRECT_FIELD_NAME: ADMINROOT, LOGIN_FORM_KEY: 1, 'username': '******', 'password': '******', } EditorTest.testfixture = cls.import_test_resource( EditorTest.test_editor_group) # second resource which is only visible by the superuser EditorTest.testfixture2 = cls.import_test_resource(None, TESTFIXTURE2_XML) # third resource which is owned by the editoruser EditorTest.testfixture3 = cls.import_test_resource(None, TESTFIXTURE3_XML) EditorTest.testfixture3.owners.add(editoruser) EditorTest.testfixture3.save()