Commit 0bd4448f authored by xa's avatar xa

add gitlab-ci

parent 57f7a2f3
Pipeline #210 passed with stage
---
before_script:
- apt install -y curl libsnappy-dev
- curl -O https://s3.amazonaws.com/bitly-downloads/nsq/nsq-0.3.5.linux-amd64.go1.4.2.tar.gz
- tar zxvf nsq-0.3.5.linux-amd64.go1.4.2.tar.gz
- python -m pip install -e .
- python -m pip install -e .[yaml]
- python -m pip install -r requirements-test.txt
- python -m pip install python-snappy
prepare nsq binaries:
type: build
python3.4 tests:
script:
- curl -O https://s3.amazonaws.com/bitly-downloads/nsq/nsq-0.3.5.linux-amd64.go1.4.2.tar.gz
- tar zxvf nsq-0.3.5.linux-amd64.go1.4.2.tar.gz
- export PATH=$PATH:$PWD/nsq-0.3.5.linux-amd64.go1.4.2/bin
tags:
- python3.4
test:
script:
- py.test --cov aionsq --cov-report term-missing tests/
tags:
- python3.4
import asyncio
import logging
from . import exceptions
from .connection import Connection
from .exceptions import NotStartedError
from .message import Message
from weakref import WeakKeyDictionary, WeakSet
......@@ -77,7 +77,7 @@ class NSQWriter(TCPHandler):
message (str): raw message bytes
"""
if not self._started:
raise exceptions.NotStartedError()
raise NotStartedError()
yield from self._conn.cmd('PUB', topic, body=message)
return True
......@@ -91,7 +91,7 @@ class NSQWriter(TCPHandler):
"""
assert isinstance(messages, (list, set))
if not self._started:
raise exceptions.NotStartedError()
raise NotStartedError()
yield from self._conn.cmd('MPUB', topic, body=messages)
return True
......
......@@ -4,9 +4,11 @@ import json
import logging
import socket
import ssl
from . import exceptions
from . import helpers
from .exceptions import AuthFailedError
from .exceptions import IdentifyFailedError
from .exceptions import ServerError
from .handlers import DeflateHandler, SnappyHandler
from .helpers import prepare_cmd, to_size, parse_frame
from aionsq.util import parse_addr
......@@ -138,7 +140,7 @@ class Connection:
@asyncio.coroutine
def cmd(self, cmd, *params, body=None):
msg = helpers.prepare_cmd(cmd, *params, body=body)
msg = prepare_cmd(cmd, *params, body=body)
self.log.info('send %s', msg)
yield from self.write(msg)
......@@ -198,14 +200,14 @@ class Connection:
self.bufferize_chunk(data)
while len(self._buf) > 4:
data = self._buf[:4]
size = helpers.to_size(data)
size = to_size(data)
self.log.debug('read size %s', size)
if len(self._buf) < (4 + size):
return
data, self._buf[:4 + size] = self._buf[4:4 + size], []
self.log.debug('read data %s', data)
frame = helpers.parse_frame(data)
frame = parse_frame(data)
self.notify_listeners(frame)
@asyncio.coroutine
......@@ -228,11 +230,11 @@ class Connection:
@asyncio.coroutine
def read(self):
block = yield from self._read(4)
size = helpers.to_size(block)
size = to_size(block)
self.log.debug('read size %s', size)
data = yield from self._read(size)
self.log.debug('read data %s', data)
frame = helpers.parse_frame(data)
frame = parse_frame(data)
self.log.debug('read frame %s', frame)
if frame.type == 0:
return frame.body
......@@ -245,7 +247,7 @@ class Connection:
def exc(frame):
if frame.error == 'E_AUTH_FAILED':
return exceptions.AuthFailedError(frame.body)
return AuthFailedError(frame.body)
if frame.error == 'E_IDENTIFY_FAILED':
return exceptions.IdentifyFailedError(frame.body)
return exceptions.ServerError(frame)
return IdentifyFailedError(frame.body)
return ServerError(frame)
pytest
pytest-asynci
pytest-asyncio
pytest-cov
pytest-flake8
json-spec
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment