def pre_run_initialization(self): self.user_id = "test_register_user_{}".format(time.time()) self.password = "******".format(time.time()) self.payment = "" self.auth = auth.Auth(conf.URL) self.seller = seller.Seller(conf.URL) yield
def pre_run_initialization(self): self.auth = auth.Auth(conf.URL) # 注册一个用户进行搜索 self.user_id = "test_global_search_content_store_id_1_{}".format( time.time()) self.password = "******" + self.user_id self.terminal = "terminal_" + self.user_id assert self.auth.register(self.user_id, self.password) == 200 # 注册一个店铺,对其进行增加库存,进行被搜索 self.another_user_id = "test_global_search_content_store_id_2_{}".format( time.time()) self.seller = register_new_seller(self.another_user_id, self.password) self.store_id = "test_global_search_content_store_id_{}".format( str(uuid.uuid1())) assert self.seller.create_store(self.store_id) == 200 # 对其增加库存(80本书) book_db = book.BookDB() self.books = book_db.get_book_info(0, 100) for b in self.books: code = self.seller.add_book(self.store_id, 0, b) assert code == 200 # 搜索的标题内容 self.search_info = "一个 女生的自白 \n" # 搜索的页数 self.page = 1 self.large_page = 20 yield
def pre_run_initialization(self): self.user_id = "test_search_user_id_".format(str(uuid.uuid1())) self.password = "******".format(str(uuid.uuid1())) self.store_id = "test_search_store_id_".format(str(uuid.uuid1())) self.search = search.Search(conf.URL) self.auth = auth.Auth(conf.URL) code = self.auth.register(self.user_id, self.password) assert code == 200 self.seller = seller.Seller(conf.URL, self.user_id, self.password) code = self.seller.create_store(self.store_id) assert code == 200 book_db = b.BookDB() books = book_db.get_book_info(0, 5) self.search_info = { 'title': [], 'tags': [], 'contents': [], 'authors_or_translators': [], 'publishers': [] } for book in books: self.search_info['title'].append(book.title) self.search_info['tags'].append(book.title) self.seller.add_book(self.store_id, 0, book) yield
def pre_run_initialization(self): book_db = BookDB() self.books = book_db.get_book_info(0, 10) self.user_id = "test_search_user_id_{}".format(str(uuid.uuid1())) self.password = "******".format(str(uuid.uuid1())) self.store_id = "test_search_store_id_{}".format(str(uuid.uuid1())) self.auth = auth.Auth(conf.URL) code = self.auth.register(self.user_id, self.password) self.seller = seller.Seller(conf.URL, self.user_id, self.password) code = self.seller.create_store(self.store_id) self.false_store_id = "test_false_store_id_{}".format(str( uuid.uuid1())) for book in self.books: code = self.seller.add_book(self.store_id, 0, book) self.search = search.Search(conf.URL) self.author1 = "test_search_author_{}".format(str(uuid.uuid1())) self.author2 = self.books[0].author self.book_intro1 = "test_search_book_intro_{}".format(str( uuid.uuid1())) self.book_intro2 = self.books[0].book_intro self.tags1 = "test_search_tags_{}".format(str(uuid.uuid1())) self.tags2 = self.books[0].tags[2] self.title1 = "test_search_title_{}".format(str(uuid.uuid1())) self.title2 = self.books[0].title yield
def test_login(username: str): a = auth.Auth(conf.URL) # register a user password = "******" + username terminal = "terminal_" + username assert a.register(username, password) # login right login_ok, token = a.login(username, password, terminal) assert login_ok my_token = token # login wrong username login_ok, token = a.login(username + "xxx", password, terminal) assert not login_ok # login wrong password login_ok, token = a.login(username, password + "xxx", terminal) assert not login_ok # logout wrong token logout_ok = a.logout(username, my_token + "xxx") assert not logout_ok # logout wrong username logout_ok = a.logout(username + "xxx", my_token) assert not logout_ok # logout right logout_ok = a.logout(username, my_token) assert logout_ok
def pre_run_initialization(self): self.auth = auth.Auth(conf.URL) # register a user self.user_id = "test_login_{}".format(time.time()) self.password = "******" + self.user_id self.terminal = "terminal_" + self.user_id assert self.auth.register(self.user_id, self.password) == 200 yield
def pre_run_initialization(self): self.auth = auth.Auth(conf.URL) self.author = "test_author_{}".format(str(uuid.uuid1())) self.book_intro = "test_book_intro_{}".format(str(uuid.uuid1())) self.tags = "test_tags_{}".format(str(uuid.uuid1())) self.title = "test_title_{}".format(str(uuid.uuid1())) self.store_id = "test_store_id_{}".format(str(uuid.uuid1())) yield
def pre_run_initialization(self): self.auth = auth.Auth(conf.URL) # register a user self.user_id = "test_password_{}".format(str(uuid.uuid1())) self.old_password = "******" + self.user_id self.new_password = "******" + self.user_id self.terminal = "terminal_" + self.user_id assert self.auth.register(self.user_id, self.old_password) == 200 yield
def test_register(username: str): a = auth.Auth(conf.URL) password = "******" + username assert a.register(username, password) assert not a.register(username, password + "_x") assert not a.unregister(username + "_x", password) assert not a.unregister(username, password + "_x") assert a.unregister(username, password) assert a.register(username, password) assert a.unregister(username, password)
def test_ok2(self): xx = 'cfwenvjhcwu' store_id = [self.store_id1, self.store_id2] id = [xx] title = [xx] author = [xx] publisher = [xx] original_title = [xx] translator = [xx] pub_year = [xx] pages = [xx] price = [xx] binding = [xx] isbn = [xx] author_intro = [xx] book_intro = [xx] content = [xx] tags = [xx] stock_level = -1 info1 = [] info1.append(store_id) info1.append(id) info1.append(title) info1.append(author) info1.append(publisher) info1.append(original_title) info1.append(translator) info1.append(pub_year) info1.append(pages) info1.append(price) info1.append(binding) info1.append(isbn) info1.append(author_intro) info1.append(book_intro) info1.append(content) info1.append(tags) info1.append(stock_level) a = auth.Auth(conf.URL) code = a.search(info1) assert code == 200
def test_ok1(self): store_id = None id = None title = None author = None publisher = None original_title = None translator = None pub_year = None pages = None price = None binding = None isbn = None author_intro = None book_intro = None content = None tags = None stock_level = None info1 = [] info1.append(store_id) info1.append(id) info1.append(title) info1.append(author) info1.append(publisher) info1.append(original_title) info1.append(translator) info1.append(pub_year) info1.append(pages) info1.append(price) info1.append(binding) info1.append(isbn) info1.append(author_intro) info1.append(book_intro) info1.append(content) info1.append(tags) info1.append(stock_level) a = auth.Auth(conf.URL) code = a.search(info1) assert code == 200
def test_password(username: str): a = auth.Auth(conf.URL) # register a user old_password = "******" + username new_password = "******" + username terminal = "terminal_" + username assert a.register(username, old_password) assert not a.password(username + "_x", old_password, new_password) assert not a.password(username, old_password + "_x", new_password) assert a.password(username, old_password, new_password) ok, new_token = a.login(username, old_password, terminal) assert not ok ok, new_token = a.login(username, new_password, terminal) assert ok assert a.logout(username, new_token)
def register_new_seller(user_id, password) -> seller.Seller: a = auth.Auth(conf.URL) code = a.register(user_id, password) assert code == 200 s = seller.Seller(conf.URL, user_id, password) return s
def register_new_buyer(user_id, password) -> buyer.Buyer: a = auth.Auth(conf.URL) code = a.register(user_id, password) assert code == 200 s = buyer.Buyer(conf.URL, user_id, password) return s
def pre_run_initialization(self): self.user_id = "test_register_user_{}".format(str(uuid.uuid1())) self.password = "******".format(str(uuid.uuid1())) self.auth = auth.Auth(conf.URL) yield