Browse Source

Merge branch 'master' into feature/capture-requests

pull/46/head
Andrei 8 years ago
parent
commit
3c4d3e1f1e
  1. 1
      .gitignore
  2. 4
      .travis.yml
  3. 5
      setup.cfg
  4. 2
      setup.py
  5. 0
      tests/api/__init__.py
  6. 8
      tests/api/reason.py
  7. 0
      tests/bot/__init__.py
  8. 0
      tests/bot/bot.py
  9. 0
      tests/gateway/__init__.py
  10. 20
      tests/gateway/events.py
  11. 0
      tests/imports.py
  12. 0
      tests/types/__init__.py
  13. 6
      tests/types/channel.py
  14. 0
      tests/types/embeds.py
  15. 0
      tests/types/types.py
  16. 0
      tests/types/user.py
  17. 0
      tests/util/__init__.py
  18. 0
      tests/util/limiter.py
  19. 27
      tests/utils.py
  20. 0
      tests/voice/__init__.py
  21. 0
      tests/voice/queue.py

1
.gitignore

@ -5,6 +5,7 @@ storage.db
storage.json
*.dca
.eggs/
.cache/
# Documentation stuff
docs/api/

4
.travis.yml

@ -8,6 +8,8 @@ python:
- '3.4'
- '3.5'
- '3.6'
- 'nightly'
install:
- pip install -U pip setuptools pytest
script: 'python setup.py test'

5
setup.cfg

@ -0,0 +1,5 @@
[aliases]
test=pytest
[tool:pytest]
python_files = tests/*.py

2
setup.py

@ -32,6 +32,8 @@ setup(
install_requires=requirements,
extras_require=extras_require,
test_suite='tests',
setup_requires=['pytest-runner==2.11.1'],
tests_require=['pytest==3.1.3', 'pytest-benchmark==3.1.0a2'],
classifiers=[
'Development Status :: 4 - Beta',
'License :: OSI Approved :: MIT License',

0
tests/api/__init__.py

8
tests/test_reason.py → tests/api/reason.py

@ -1,18 +1,18 @@
from unittest import TestCase
from tests.utils import APIClient
class TestReason(TestCase):
def test_set_unicode_reason(self):
from tests.utils import TestAPIClient
api = TestAPIClient()
api = APIClient()
api.guilds_channels_modify(1, 2, 3, reason=u'yo \U0001F4BF test')
_, kwargs = api.http.calls[0]
self.assertEqual(kwargs['headers']['X-Audit-Log-Reason'], 'yo%20%F0%9F%92%BF%20test')
def test_null_reason(self):
from tests.utils import TestAPIClient
api = TestAPIClient()
api = APIClient()
api.guilds_channels_modify(1, 2, 3, reason=None)
_, kwargs = api.http.calls[0]

0
tests/bot/__init__.py

0
tests/test_bot.py → tests/bot/bot.py

0
tests/gateway/__init__.py

20
tests/gateway/events.py

@ -0,0 +1,20 @@
from disco.gateway.events import GatewayEvent, Resumed
def create_resumed_payload():
return GatewayEvent.from_dispatch(None, {
't': 'RESUMED',
'd': {
'_trace': ['test', '1', '2', '3'],
}
})
def test_from_dispatch():
event = create_resumed_payload()
assert isinstance(event, Resumed)
assert event.trace == ['test', '1', '2', '3']
def test_event_creation(benchmark):
benchmark(create_resumed_payload)

0
tests/test_imports.py → tests/imports.py

0
tests/types/__init__.py

6
tests/test_channel.py → tests/types/channel.py

@ -4,7 +4,7 @@ from disco.types.channel import Channel, ChannelType
class TestChannel(TestCase):
def test_nsfw_channel(self):
def test_deprecated_nsfw_channel(self):
channel = Channel(
name='nsfw-testing',
type=ChannelType.GUILD_TEXT)
@ -19,3 +19,7 @@ class TestChannel(TestCase):
name='nsfw_testing',
type=ChannelType.GUILD_TEXT)
self.assertFalse(channel.is_nsfw)
def test_nsfw_channel(self):
channel = Channel(name='test', nsfw=True, type=ChannelType.GUILD_TEXT)
assert channel.is_nsfw

0
tests/test_embeds.py → tests/types/embeds.py

0
tests/test_types.py → tests/types/types.py

0
tests/test_user.py → tests/types/user.py

0
tests/util/__init__.py

0
tests/test_util_limiter.py → tests/util/limiter.py

27
tests/utils.py

@ -1,6 +1,4 @@
import time
import contextlib
from disco.api.client import APIClient
from disco.api.client import APIClient as _APIClient
class CallContainer(object):
@ -11,28 +9,7 @@ class CallContainer(object):
self.calls.append((args, kwargs))
class TestAPIClient(APIClient):
class APIClient(_APIClient):
def __init__(self):
self.client = None
self.http = CallContainer()
def bench(times, func):
main_start = time.time()
worst = None
best = None
for _ in range(times):
start = time.time()
func()
dur = time.time() - start
if not worst or dur > worst:
worst = dur
if not best or dur < best:
best = dur
main_dur = time.time() - main_start
return main_dur, worst, best

0
tests/voice/__init__.py

0
tests/tests_voice_queue.py → tests/voice/queue.py

Loading…
Cancel
Save