mypy: Convert zerver/tests/ to use typing.Text.

This commit is contained in:
bulat22101
2016-12-04 17:38:56 +00:00
committed by Tim Abbott
parent 88e2ff3e1c
commit 9f68efa47b
32 changed files with 108 additions and 125 deletions

View File

@@ -1,17 +1,16 @@
import ujson
from six import text_type
from typing import Dict, Optional
from typing import Dict, Optional, Text
from zerver.models import Message
from zerver.lib.webhooks.git import COMMITS_LIMIT
from zerver.lib.test_classes import WebhookTestCase
class GithubV1HookTests(WebhookTestCase):
STREAM_NAME = None # type: Optional[text_type]
STREAM_NAME = None # type: Optional[Text]
URL_TEMPLATE = u"/api/v1/external/github"
FIXTURE_DIR_NAME = 'github'
SEND_STREAM = False
BRANCHES = None # type: Optional[text_type]
BRANCHES = None # type: Optional[Text]
push_content = u"""zbenjamin [pushed](https://github.com/zbenjamin/zulip-test/compare/4f9adc4777d5...b95449196980) to branch master
@@ -40,7 +39,7 @@ class GithubV1HookTests(WebhookTestCase):
self.assertEqual(prior_count, after_count)
def get_body(self, fixture_name):
# type: (text_type) -> Dict[str, text_type]
# type: (Text) -> Dict[str, Text]
api_key = self.get_api_key(self.TEST_USER_EMAIL)
data = ujson.loads(self.fixture_data(self.FIXTURE_DIR_NAME, 'v1_' + fixture_name))
data.update({'email': self.TEST_USER_EMAIL,
@@ -54,7 +53,7 @@ class GithubV1HookTests(WebhookTestCase):
return data
def basic_test(self, fixture_name, stream_name, expected_subject, expected_content, send_stream=False, branches=None):
# type: (text_type, text_type, text_type, text_type, bool, Optional[text_type]) -> None
# type: (Text, Text, Text, Text, bool, Optional[Text]) -> None
self.STREAM_NAME = stream_name
self.SEND_STREAM = send_stream
self.BRANCHES = branches
@@ -147,11 +146,11 @@ class GithubV1HookTests(WebhookTestCase):
"zbenjamin [commented](https://github.com/zbenjamin/zulip-test/commit/7c994678d2f98797d299abed852d3ff9d0834533#commitcomment-4252307) on [7c99467](https://github.com/zbenjamin/zulip-test/commit/7c994678d2f98797d299abed852d3ff9d0834533)\n~~~ quote\nThis line adds /unlucky/ cowbell (because of its line number). We should remove it.\n~~~")
class GithubV2HookTests(WebhookTestCase):
STREAM_NAME = None # type: Optional[text_type]
STREAM_NAME = None # type: Optional[Text]
URL_TEMPLATE = u"/api/v1/external/github"
FIXTURE_DIR_NAME = 'github'
SEND_STREAM = False
BRANCHES = None # type: Optional[text_type]
BRANCHES = None # type: Optional[Text]
push_content = """zbenjamin [pushed](https://github.com/zbenjamin/zulip-test/compare/4f9adc4777d5...b95449196980) to branch master
@@ -180,7 +179,7 @@ class GithubV2HookTests(WebhookTestCase):
self.assertEqual(prior_count, after_count)
def get_body(self, fixture_name):
# type: (text_type) -> Dict[str, text_type]
# type: (Text) -> Dict[str, Text]
api_key = self.get_api_key(self.TEST_USER_EMAIL)
data = ujson.loads(self.fixture_data(self.FIXTURE_DIR_NAME, 'v2_' + fixture_name))
data.update({'email': self.TEST_USER_EMAIL,
@@ -194,7 +193,7 @@ class GithubV2HookTests(WebhookTestCase):
return data
def basic_test(self, fixture_name, stream_name, expected_subject, expected_content, send_stream=False, branches=None):
# type: (text_type, text_type, text_type, text_type, bool, Optional[text_type]) -> None
# type: (Text, Text, Text, Text, bool, Optional[Text]) -> None
self.STREAM_NAME = stream_name
self.SEND_STREAM = send_stream
self.BRANCHES = branches