lugito/tests/test_ircconnector.py
Ben Johnston f327136c34
* Added updating IRC in response to newly created/edited diffs
* Significant refactoring: lugito wrapped into a class with common methods, IRC
and Launchpad communications separated as connectors with a separate webhook
module.
* Some unit-tests added
* Added functionality for ircbot to respond to diff links and info as well as
extracting anchor links from tasks / diffs e.g. D15#167
* Built into a python package structure

Still Requires:
* Improved test coverage
* Package documentation
* Additional functionality for other phabricator apps
2018-11-16 01:42:02 +11:00

50 lines
1.0 KiB
Python

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# S.D.G
"""
Test IRC connector
"""
# Imports
import os
import json
import phabricator
from lugito import IRCConnector
from unittest.mock import MagicMock
# Setup ###############################################################
TEST_DIR = os.path.dirname(__file__)
# Force phabricator to use the ./tests/.arcconfig file
TEST_CONFIG = os.path.join(TEST_DIR, '.arcconfig')
with open(TEST_CONFIG, 'r') as f:
phabricator.ARCRC = json.load(f)
# Tests ###############################################################
def test_init():
"""Test initialise irc connector"""
obj = IRCConnector()
assert('irc.freenode.net' == obj.host)
assert(6697 == obj.port)
assert('someusername' == obj.username)
assert('somepassword' == obj.password)
assert('#somechannel' == obj.channel)
assert('http://127.0.0.1:9091/' == obj.phab_host)
def test_connect():
"""Test initial connection"""
obj = IRCConnector()
obj._socket_conn = MagicMock()
# obj.conn.recv = MagicMock(side_effect=[