示例#1
0
    def test_unsubscribe_post(self):
        response = self.client.post(
            "/api/v1/unsubscribe",
            urlencode({
                "name": "테스터",
                "email": "*****@*****.**",
            }),
            content_type="application/x-www-form-urlencoded",
        )

        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
示例#2
0
        def delete(self, path, data={}, **extra):
            "Construct a DELETE request."

            parsed = urlparse(path)
            r = {
                'PATH_INFO': self._get_path(parsed),
                'QUERY_STRING': urlencode(data, doseq=True) or parsed[4],
                'REQUEST_METHOD': 'DELETE',
                'wsgi.input': FakePayload('')
            }
            r.update(extra)
            return self.request(**r)
示例#3
0
        def options(self, path, data={}, **extra):
            "Constrict an OPTIONS request"

            parsed = urlparse(path)
            r = {
                'PATH_INFO': self._get_path(parsed),
                'QUERY_STRING': urlencode(data, doseq=True) or parsed[4],
                'REQUEST_METHOD': 'OPTIONS',
                'wsgi.input': FakePayload('')
            }
            r.update(extra)
            return self.request(**r)
示例#4
0
    def test_subscribe_post(self):
        response = self.client.post(
            "/api/v1/subscribe",
            urlencode({
                "name": "김준영",
                "email": "*****@*****.**",
            }),
            content_type="application/x-www-form-urlencoded",
        )

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(response.data["name"], "김준영")
        self.assertEqual(response.data["email"], "*****@*****.**")
示例#5
0
    def test_mail_all_post(self):
        headers = {"HTTP_AUTHORIZATION": self.authorization}
        response = self.client.post(
            "/api/v1/mail-all",
            urlencode({
                "subject": "메일 전체에게 보내기 테스트",
                "content": "내용2다",
            }),
            content_type="application/x-www-form-urlencoded",
            **headers,
        )

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
示例#6
0
        def head(self, path, data={}, **extra):
            "Construct a HEAD request."

            parsed = urlparse(path)
            r = {
                'CONTENT_TYPE': 'text/html; charset=utf-8',
                'PATH_INFO': self._get_path(parsed),
                'QUERY_STRING': urlencode(data, doseq=True) or parsed[4],
                'REQUEST_METHOD': 'HEAD',
                'wsgi.input': FakePayload('')
            }
            r.update(extra)
            return self.request(**r)
示例#7
0
    def test_mail_post_to_not_subscriber(self):
        headers = {"HTTP_AUTHORIZATION": self.authorization}
        response = self.client.post(
            "/api/v1/mail",
            urlencode({
                "mailto": "*****@*****.**",
                "subject": "메일 하나 보내기 테스트",
                "content": "내용입니다",
            }),
            content_type="application/x-www-form-urlencoded",
            **headers,
        )

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
示例#8
0
    def test_mail_post_to_subscriber(self):
        headers = {"HTTP_AUTHORIZATION": self.authorization}
        response = self.client.post(
            "/api/v1/mail",
            urlencode({
                "mailto": "*****@*****.**",
                "subject": "메일 하나 보내기 테스트",
                "content": "내용입니다",
            }),
            content_type="application/x-www-form-urlencoded",
            **headers,
        )

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
示例#9
0
    def test_mail_v2_post_(self):
        headers = {"HTTP_AUTHORIZATION": self.authorization}
        response = self.client.post(
            "/api/v2/mail",
            urlencode({
                "mailto": "*****@*****.**",
                "subject": "메일 하나 보내기 v2 테스트",
                "content": "내용입니다",
            }),
            content_type="application/x-www-form-urlencoded",
            **headers,
        )
        print(response.data)

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
示例#10
0
    def test_mail_v2_post_redirection(self):
        headers = {"HTTP_AUTHORIZATION": self.authorization}
        response = self.client.post(
            "/api/v2/mail",
            urlencode({
                "mailto": "*****@*****.**",
                "subject": "메일 하나 보내기 v2 테스트",
                "content": "내용입니다",
            }),
            content_type="application/x-www-form-urlencoded",
            **headers,
        )
        print(response.__dict__)

        self.assertEqual(response.status_code,
                         status.HTTP_301_MOVED_PERMANENTLY)