import time

import pytest
from fe.access.new_seller import register_new_seller
from fe.access.book import Book
from fe.access import book
from fe.access import auth
from fe import conf
import uuid
import random
class TestSearch:
    @pytest.fixture(autouse=True)
    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()))#random.choice(["小说","励志"])
        self.title = "test_title_{}".format(str(uuid.uuid1()))#random.choice(["很","在"])
        self.store_id = "test_store_id_{}".format(str(uuid.uuid1()))
        self.page = random.randint(1,2)

        yield

    def test_search(self):
        assert self.auth.search_author(self.author, self.page) == 200
        assert self.auth.search_book_intro(self.book_intro, self.page) == 200
        assert self.auth.search_tags(self.tags, self.page) == 200
        assert self.auth.search_title(self.title, self.page) == 200