mirror of
https://github.com/nikdoof/dropbot.git
synced 2025-12-17 11:49:22 +00:00
Basic unit tests, and wercker support.
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
dropbot
|
dropbot
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
[](https://app.wercker.com/project/bykey/76f99d586d9f2fcd532e31fb0de2ab6c)
|
||||||
|
|
||||||
A XMPP bot to provide simple services to NOG8S and Predditors in general
|
A XMPP bot to provide simple services to NOG8S and Predditors in general
|
||||||
|
|
||||||
Setup
|
Setup
|
||||||
|
|||||||
@@ -113,7 +113,10 @@ class Map(networkx.Graph):
|
|||||||
|
|
||||||
def get_system_name(self, system_id):
|
def get_system_name(self, system_id):
|
||||||
"""Returns the name of the provided system id"""
|
"""Returns the name of the provided system id"""
|
||||||
return self.node[system_id]['name']
|
try:
|
||||||
|
return self.node[system_id]['name']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
def get_system_id(self, name):
|
def get_system_id(self, name):
|
||||||
"""Returns the system id of the named system"""
|
"""Returns the system id of the named system"""
|
||||||
|
|||||||
50
setup.py
Normal file
50
setup.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
from setuptools import setup
|
||||||
|
except ImportError:
|
||||||
|
from distutils.core import setup
|
||||||
|
|
||||||
|
|
||||||
|
readme = open('README.md').read()
|
||||||
|
|
||||||
|
requirements = [
|
||||||
|
# TODO: put package requirements here
|
||||||
|
]
|
||||||
|
|
||||||
|
test_requirements = [
|
||||||
|
# TODO: put package test requirements here
|
||||||
|
]
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='dropbot',
|
||||||
|
version='0.1a',
|
||||||
|
description='A XMPP bot to provide simple services to NOG8S and Predditors in general',
|
||||||
|
long_description=readme,
|
||||||
|
author='Andrew Williams',
|
||||||
|
author_email='andy@tensixtyone.com',
|
||||||
|
url='https://github.com/nikdoof/dropbot/',
|
||||||
|
packages=[
|
||||||
|
'dropbot',
|
||||||
|
],
|
||||||
|
include_package_data=True,
|
||||||
|
install_requires=requirements,
|
||||||
|
license="BSD",
|
||||||
|
zip_safe=False,
|
||||||
|
classifiers=[
|
||||||
|
'Development Status :: 2 - Pre-Alpha',
|
||||||
|
'Intended Audience :: Developers',
|
||||||
|
'License :: OSI Approved :: BSD License',
|
||||||
|
'Natural Language :: English',
|
||||||
|
"Programming Language :: Python :: 2",
|
||||||
|
'Programming Language :: Python :: 2.6',
|
||||||
|
'Programming Language :: Python :: 2.7',
|
||||||
|
],
|
||||||
|
test_suite='tests',
|
||||||
|
tests_require=test_requirements,
|
||||||
|
entry_points = {
|
||||||
|
'console_scripts': ['dropbot=dropbot.cli:main'],
|
||||||
|
}
|
||||||
|
)
|
||||||
1
tests/__init__.py
Normal file
1
tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
__author__ = 'nikdoof'
|
||||||
60
tests/test_map.py
Normal file
60
tests/test_map.py
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
from unittest import TestCase
|
||||||
|
from dropbot.map import Map
|
||||||
|
import pkgutil
|
||||||
|
|
||||||
|
class MapTestCase(TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.map = Map.from_json(pkgutil.get_data('dropbot', 'data/map.json'))
|
||||||
|
|
||||||
|
def test_load_from_package_data(self):
|
||||||
|
m = Map.from_json(pkgutil.get_data('dropbot', 'data/map.json'))
|
||||||
|
self.assertIsNotNone(m)
|
||||||
|
|
||||||
|
def test_get_system_name(self):
|
||||||
|
self.assertEquals(self.map.get_system_name(123), None)
|
||||||
|
self.assertEqual(self.map.get_system_name(30000142), 'Jita')
|
||||||
|
|
||||||
|
def test_get_system_id(self):
|
||||||
|
self.assertEqual(self.map.get_system_id('Llamatron'), None)
|
||||||
|
self.assertEqual(self.map.get_system_id('Jita'), 30000142)
|
||||||
|
|
||||||
|
def test_get_systems(self):
|
||||||
|
self.assertEquals(len(self.map.get_systems('Jita')), 1)
|
||||||
|
self.assertEquals(len(self.map.get_systems('Ji')), 14)
|
||||||
|
self.assertEquals(len(self.map.get_systems('J')), 576)
|
||||||
|
self.assertEquals(len(self.map.get_systems('123435345345')), 0)
|
||||||
|
|
||||||
|
def test_system_distance(self):
|
||||||
|
self.assertEqual(self.map.system_distance(30000142, 30000144), 2.10268108033618)
|
||||||
|
self.assertEqual(self.map.system_distance(30000142, 30000222), 9.334275248404591)
|
||||||
|
self.assertEqual(self.map.system_distance(30000142, 30000536), 39.15289747780095)
|
||||||
|
self.assertRaises(Exception, self.map.system_distance, (1, 2))
|
||||||
|
|
||||||
|
def test_route_gate(self):
|
||||||
|
r = self.map.route_gate(30001161, 30001198)
|
||||||
|
self.assertEqual(len(r), 9)
|
||||||
|
self.assertListEqual(r, [30001161, 30001158, 30001160, 30001154, 30001157, 30001155, 30001156, 30001162, 30001198])
|
||||||
|
|
||||||
|
def test_route_jump(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_route_jump_distance(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_route_jump_isotopes(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_neighbors_gate(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_neighbors_jump(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_jump_bridge_addition(self):
|
||||||
|
# HED-GP to GE-8
|
||||||
|
self.assertGreater(len(self.map.route_gate(30001161, 30001198)), 2)
|
||||||
|
self.map.add_jumpbridge(30001161, 30001198)
|
||||||
|
r = self.map.route_gate(30001161, 30001198)
|
||||||
|
self.assertEqual(len(r), 2)
|
||||||
|
self.assertListEqual(r, [30001161, 30001198])
|
||||||
12
wercker.yml
Normal file
12
wercker.yml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
box: wercker/python
|
||||||
|
build:
|
||||||
|
steps:
|
||||||
|
- virtualenv:
|
||||||
|
name: Setup virtual environment
|
||||||
|
- pip-install:
|
||||||
|
name: Install requirements
|
||||||
|
auto_run_wheel: True
|
||||||
|
- script:
|
||||||
|
name: Run unit testing
|
||||||
|
code: |
|
||||||
|
python setup.py test
|
||||||
Reference in New Issue
Block a user