mirror of
https://github.com/lubuntu-team/lugito.git
synced 2025-07-01 10:01:30 +00:00
* 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
50 lines
1.0 KiB
Python
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=[
|
|
|