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_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.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() # 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.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()
def setUp(self): self.client = Client() self.headers = { 'HTTP_AUTHORIZATION': 'Basic ' + base64.b64encode(b'user1:123').decode("ascii") } # Create an author that will send a request self.test_sender = Author.objects.create(**get_test_credentials(), **get_author_fields()) self.test_sender.set_password("123") self.test_sender.save() # Create an author that will receive a request self.test_receiver = Author.objects.create(**get_test_credentials(1), **get_author_fields(1)) self.test_receiver.set_password("123") self.test_receiver.save() self.follow = FriendShip.objects.create( author_local=self.test_receiver, author_remote=AuthorSerializer(self.test_sender).data) self.follow_serialized = FriendshipSerializer(self.follow)
def setUp(self): self.client = Client() # self.headers = { # 'HTTP_AUTHORIZATION': 'Basic ' + # base64.b64encode(b'user1:123').decode("ascii") # } # Create an author that will receive a request self.test_receiver = Author.objects.create(**get_test_credentials(), **get_author_fields()) self.test_receiver.set_password("123") self.test_receiver.save() # Create an author that will send a request self.test_sender1 = Author.objects.create(**get_test_credentials(1), **get_author_fields(1)) self.test_sender1.set_password("123") self.test_sender1.save() # Create an author that will send a request self.test_sender2 = Author.objects.create(**get_test_credentials(2), **get_author_fields(2)) self.test_sender2.set_password("123") self.test_sender2.save() # Create follow connections FriendShip.objects.create(author_local=self.test_receiver, author_remote=AuthorSerializer( self.test_sender1).data, accepted=True) FriendShip.objects.create(author_local=self.test_receiver, author_remote=AuthorSerializer( self.test_sender2).data, accepted=True) self.senders = [self.test_sender1, self.test_sender2]
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) self.body = {"visibility": "FRIENDS", "unlisted": True}