def test_user_exists(self): field = mock.Mock() field.data = TEST_USER_EMAIL with mock.patch('models.User.get_user_by_email', return_value=None): try: user_exists(None, field) except ValidationError: self.fail( 'user_exists() raised an exception while no user is returned.' ) with mock.patch('models.User.get_user_by_email', return_value=test_admin_user): with self.assertRaises(ValidationError): user_exists(None, field)
def get(self): logging.debug("GET") self.response.headers['Content-Type'] = 'text/html' if utilities.user_is_logged_in(): if not utilities.user_exists(): utilities.add_new_user(utilities.get_user()) renderer.render_addanagram(self, utilities.get_logout_url(self), utilities.get_anagrams_of_user(utilities.get_my_user())) else: renderer.render_login(self, utilities.get_login_url(self))
def get(self): self.response.headers['Content-Type'] = 'text/html' if utilities.user_is_logged_in(): if not utilities.user_exists(): utilities.add_new_user(utilities.get_user()) result, wordCount, totalCount = utilities.get_anagrams_of_user( utilities.get_my_user()) renderer.render_main(self, utilities.get_logout_url(self), result, wordCount, totalCount) else: renderer.render_login(self, utilities.get_login_url(self))
def get(self): logging.debug("GET") self.response.headers['Content-Type'] = 'text/html' if utilities.user_is_logged_in(): if not utilities.user_exists(): utilities.add_new_user(utilities.get_user()) renderer.render_searchtext( self, utilities.get_logout_url(self), utilities.generate_id(self.request.get('value')), utilities.prepare_text_input(self.request.get('value')), utilities.get_anagrams_of_user(utilities.get_my_user())) else: renderer.render_login(self, utilities.get_login_url(self))
def get(self): logging.debug("GET") self.response.headers['Content-Type'] = 'text/html' if utilities.user_is_logged_in(): # if myuser object is None --> No user with key found --> new user --> make new user in datastore if not utilities.user_exists(): utilities.add_new_user(utilities.get_user()) renderer.render_subanagram( self, utilities.get_logout_url(self), self.request.get('name'), utilities.get_anagrams_of_user(utilities.get_my_user())) # if no user is logged in create login url else: renderer.render_login(self, utilities.get_login_url(self))
def get(self): logging.debug('GET') self.response.headers['Content-Type'] = 'text/html' # check whether user is logged in if utilities.is_user_logged_in(): # if myuser object is None --> No user with key found --> new user --> make new user in datastore if not utilities.user_exists(): utilities.add_new_user(utilities.get_user()) self.navigate() # get all directories and files in the current path directories_in_current_path = utilities.get_directories_in_current_path() files_in_current_path = utilities.get_files_in_current_path() # sort all directories and files alphabetically directories_in_current_path = utilities.sort_list(directories_in_current_path) files_in_current_path = utilities.sort_list(files_in_current_path) # extract file and directory names from the key list # so that only the names have to be send to the gui and not the whole object directories_in_current_path = utilities.get_names_from_list(directories_in_current_path) files_in_current_path = utilities.get_names_from_list(files_in_current_path) renderer.render_main(self, utilities.get_logout_url(self), directories_in_current_path, files_in_current_path, utilities.get_current_directory_object().path, utilities.is_in_root_directory(), blobstore.create_upload_url('/upload')) # if no user is logged in create login url else: renderer.render_login(self, utilities.get_login_url(self))
def test_user_does_not_exist(self): # is the user successfully not found? self.assertFalse(utilities.user_exists('not_a_user'))
def test_user_exists(self): # is the user successfully found? self.assertTrue(utilities.user_exists('vahidrogo'))
#end ugliness ######################################################### parser = xml.sax.make_parser() handler = ITunesHandler() parser.setContentHandler(handler) path = settings.get('itunes_data', 'path') #path = settings.get('itunes_data', 'path_test') TEST file_location = "/Users/%s/%s" % (user, path) #file_location = "/Users/%s/%s" % ('cwood', path) TEST db_path = get_db_path('central') central_db = db_wrapper(db_path) local_db_dir = settings.get('db_settings', 'local_db_dir') #Is this a new user in the central db? Wipe out any existing local db if so if not user_exists(user): #--------------------First Time User-------------------- confirm = raw_input('''**************************************************** The directory %s is about to be created, if it already exists it will be destroyed. Keep going? (y/n)''' % (local_db_dir)) if confirm[0].lower() == 'y': central_db.add_user(user) set_up_dir(user) set_up_local_db(user) else: raise_error('abort', '\nSidus user creation has been cancelled.\n') #do a full parse of the itunes xml parser.parse(file_location)