def setUp(self): self.client = Client() self.headers = { 'HTTP_AUTHORIZATION': 'Basic ' + base64.b64encode(b'user0:123').decode("ascii") } # Create test author to create posts self.test_author = Author.objects.create(**get_test_credentials(), **get_author_fields()) self.test_author.set_password("123") self.test_author.save() # Test posts, mix of public, private, etc. settings self.test_post1 = Post.objects.create( **get_post_fields(i=0, visibility='PUBLIC', unlisted=False), author_id=self.test_author ) self.test_post2 = Post.objects.create( **get_post_fields(i=1, visibility='PRIVATE', unlisted=True), author_id=self.test_author ) self.test_post3 = Post.objects.create( **get_post_fields(i=2, visibility='PUBLIC', unlisted=False), author_id=self.test_author )
def setUp(self): self.client = Client() self.headers = { 'HTTP_AUTHORIZATION': 'Basic ' + base64.b64encode(b'user0:123').decode("ascii") } # Create 3 authors that create 1 post each self.test_authors = [] self.test_posts = [] for i in range(3): self.test_authors.append( Author.objects.create(**get_test_credentials(i=i), **get_author_fields(i=i))) self.test_posts.append( Post.objects.create(**get_post_fields(i=i), author_id=self.test_authors[i])) # Create test author to like all 3 posts self.test_liker = Author.objects.create(**get_test_credentials(5), **get_author_fields(5)) self.test_liked_posts = [] for i in range(3): self.test_liked_posts.append( Like.objects.create(**get_like_fields( id=self.test_posts[i].post_id), author_id=self.test_authors[i], liker_id=AuthorSerializer( self.test_liker).data))
def setUp(self): self.client = Client() self.headers = { 'HTTP_AUTHORIZATION': 'Basic ' + base64.b64encode(b'user0:123').decode("ascii") } # Create test author to create posts self.test_author = Author.objects.create(**get_test_credentials(), **get_author_fields()) self.test_author.set_password("123") self.test_author.save() # Create a test post self.test_post = Post.objects.create( **get_post_fields(), author_id=self.test_author ) self.test_commenter = Author.objects.create(**get_test_credentials(20), **get_author_fields(20)) self.test_author.set_password("123") self.test_author.save() self.payload = post_comment_fields(id=self.test_author)
def setUp(self): self.client = Client() self.headers = { 'HTTP_AUTHORIZATION': 'Basic ' + base64.b64encode(b'user0:123').decode("ascii") } # Create test author to create posts self.test_author = Author.objects.create(**get_test_credentials(), **get_author_fields()) self.test_author.set_password("123") self.test_author.save() # Create a test post self.test_post = Post.objects.create( **get_post_fields(), author_id=self.test_author ) self.test_commenters = [] for i in range(5): # Create test commentor to comment on posts self.test_commenters.append( Author.objects.create(**get_test_credentials(i+1), **get_author_fields(i+1)) ) self.test_author.set_password("123") self.test_author.save() for i in range(5): Comment.objects.create( **get_comment_fields(), post_id=self.test_post, author_id=AuthorSerializer(self.test_author).data )
def setUp(self): self.client = Client() self.test_author_fields = get_author_fields() self.test_author = Author.objects.create(**self.test_author_fields) self.test_post_fields = get_post_fields() self.test_post = Post.objects.create(**self.test_post_fields, author_id=self.test_author)
def setUp(self): self.client = Client() self.headers = { 'HTTP_AUTHORIZATION': 'Basic ' + base64.b64encode(b'user0:123').decode("ascii") } self.test_credentials = get_test_credentials() self.test_author_fields = get_author_fields() self.test_author = Author.objects.create(**self.test_author_fields, **self.test_credentials) self.test_author.set_password("123") self.test_author.save() self.test_post_fields = get_post_fields() self.test_post = Post.objects.create(**self.test_post_fields, author_id=self.test_author)