예제 #1
0
파일: test_version.py 프로젝트: ntoll/p4p2p
 def test_get_version(self):
     """
     Ensures the get_version function returns a dot separated expression of
     the VERSION.
     """
     expected = '.'.join([str(i) for i in VERSION])
     actual = get_version()
     self.assertEqual(expected, actual)
예제 #2
0
파일: test_contact.py 프로젝트: ntoll/p4p2p
 def test_ne(self):
     """
     Makes sure non-equality works between a string representation of an ID
     and a PeerNode object.
     """
     address = '192.168.0.1'
     port = 9999
     version = get_version()
     last_seen = 123
     contact = PeerNode(PUBLIC_KEY, address, port, version, last_seen)
     self.assertTrue('54321' != contact)
예제 #3
0
파일: test_contact.py 프로젝트: ntoll/p4p2p
 def test_eq_wrong_type(self):
     """
     Ensure equality returns false if comparing a PeerNode with some other
     type of object.
     """
     address = '192.168.0.1'
     port = 9999
     version = get_version()
     last_seen = 123
     contact = PeerNode(PUBLIC_KEY, address, port, version, last_seen)
     self.assertFalse(12345 == contact)
예제 #4
0
파일: test_contact.py 프로젝트: ntoll/p4p2p
 def test_eq_other_peer(self):
     """
     Ensure equality works between two PeerNode instances.
     """
     address = '192.168.0.1'
     port = 9999
     version = get_version()
     last_seen = 123
     contact1 = PeerNode(PUBLIC_KEY, address, port, version, last_seen)
     contact2 = PeerNode(PUBLIC_KEY, address, port, version, last_seen)
     self.assertTrue(contact1 == contact2)
예제 #5
0
 def test_eq(self):
     """
     Makes sure equality works between a string representation of an ID and
     a PeerNode object.
     """
     network_id = '12345'
     address = '192.168.0.1'
     port = 9999
     version = get_version()
     last_seen = 123
     contact = PeerNode(network_id, address, port, version, last_seen)
     self.assertTrue(network_id == contact)
예제 #6
0
파일: test_contact.py 프로젝트: ntoll/p4p2p
 def test_eq(self):
     """
     Makes sure equality works between a string representation of an ID and
     a PeerNode object.
     """
     network_id = '0x' + sha512(PUBLIC_KEY.encode('ascii')).hexdigest()
     address = '192.168.0.1'
     port = 9999
     version = get_version()
     last_seen = 123
     contact = PeerNode(PUBLIC_KEY, address, port, version, last_seen)
     self.assertTrue(network_id == contact)
예제 #7
0
 def test_str(self):
     """
     Ensures the string representation of a PeerContact is something
     useful.
     """
     network_id = '12345'
     address = '192.168.0.1'
     port = 9999
     version = get_version()
     last_seen = 123
     contact = PeerNode(network_id, address, port, version, last_seen)
     expected = "('12345', '192.168.0.1', 9999, '%s', 123, 0)" % version
     self.assertEqual(expected, str(contact))
예제 #8
0
 def test_init_with_int_id(self):
     """
     If the ID is passed in as an int value ensure it's translated to the
     correct string representation of the hex version.
     """
     network_id = 12345
     address = '192.168.0.1'
     port = 9999
     version = get_version()
     last_seen = 123
     contact = PeerNode(network_id, address, port, version, last_seen)
     expected = '09'
     self.assertEqual(expected, contact.network_id)
     self.assertEqual(12345L, long(contact.network_id.encode('hex'), 16))
예제 #9
0
파일: test_contact.py 프로젝트: ntoll/p4p2p
 def test_str(self):
     """
     Ensures the string representation of a PeerContact is something
     useful.
     """
     network_id = '0x' + sha512(PUBLIC_KEY.encode('ascii')).hexdigest()
     address = '192.168.0.1'
     port = 9999
     version = get_version()
     last_seen = 123
     contact = PeerNode(PUBLIC_KEY, address, port, version, last_seen)
     expected = str((network_id, PUBLIC_KEY, address, port, version,
                    last_seen, 0))
     self.maxDiff = None
     self.assertEqual(expected, str(contact))
예제 #10
0
 def test_init(self):
     """
     Ensures an object is created as expected.
     """
     network_id = '12345'
     address = '192.168.0.1'
     port = 9999
     version = get_version()
     last_seen = 123
     contact = PeerNode(network_id, address, port, version, last_seen)
     self.assertEqual(network_id, contact.network_id)
     self.assertEqual(address, contact.ip_address)
     self.assertEqual(port, contact.port)
     self.assertEqual(version, contact.version)
     self.assertEqual(last_seen, contact.last_seen)
     self.assertEqual(0, contact.failed_RPCs)
예제 #11
0
파일: test_contact.py 프로젝트: ntoll/p4p2p
 def test_init(self):
     """
     Ensures an object is created as expected.
     """
     address = '192.168.0.1'
     port = 9999
     version = get_version()
     last_seen = 123
     contact = PeerNode(PUBLIC_KEY, address, port, version, last_seen)
     hex_digest = sha512(PUBLIC_KEY.encode('ascii')).hexdigest()
     self.assertEqual(contact.network_id, '0x' + hex_digest)
     self.assertEqual(address, contact.ip_address)
     self.assertEqual(port, contact.port)
     self.assertEqual(version, contact.version)
     self.assertEqual(last_seen, contact.last_seen)
     self.assertEqual(0, contact.failed_RPCs)
예제 #12
0
 def setUp(self):
     """
     Common vars.
     """
     self.version = get_version()
예제 #13
0
파일: test_version.py 프로젝트: ntoll/p4p2p
 def test_dunder_version(self):
     """
     Ensure that the __version__ attribute of the p4p2p module is the
     expected version.
     """
     self.assertEqual(__version__, get_version())
예제 #14
0
파일: conf.py 프로젝트: qq40660/p4p2p
# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'P4P2P'
copyright = u'2013, the P4P2P authors'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '.'.join([str(i) for i in VERSION[:2]])
# The full version, including alpha/beta/rc tags.
release = get_version()

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
예제 #15
0
파일: setup.py 프로젝트: ntoll/p4p2p
#!/usr/bin/env python
from setuptools import setup, find_packages
from p4p2p.version import get_version

setup(
    name='p4p2p',
    version=get_version(),
    description='A platform for peer-to-peer application development.',
    long_description=open('README.rst').read(),
    author=open('AUTHORS').read(),
    author_email='*****@*****.**',
    url='http://p4p2p.net/',
    package_dir={'': 'p4p2p'},
    packages=find_packages('p4p2p'),
    license='MIT',
    classifiers=[
        'Development Status :: 1 - Planning',
        'Environment :: No Input/Output (Daemon)',
        'Framework :: Twisted',
        'Intended Audience :: Developers',
        'Intended Audience :: Information Technology',
        'License :: OSI Approved :: MIT License',
        'Topic :: Communications',
        'Topic :: Internet',
        'Topic :: System :: Distributed Computing',
    ],
    install_requires=['twisted', ]
)