Skip to content

Commit

Permalink
new: dev: Added some testing to and fixed a couple of bugs for the fi…
Browse files Browse the repository at this point in the history
…rst release.
  • Loading branch information
carlos-jenkins committed Sep 20, 2015
1 parent fe58c6c commit 0c693a9
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/autoapi/__init__.py
Expand Up @@ -22,6 +22,6 @@

__author__ = 'Carlos Jenkins'
__email__ = 'carlos@jenkins.co.cr'
__version__ = '0.1.0'
__version__ = '1.0.0'

__all__ = ['APINode']
8 changes: 5 additions & 3 deletions lib/autoapi/apinode.py
Expand Up @@ -217,7 +217,7 @@ def is_leaf(self):
:rtype: bool
:return: True if no other subnodes exists for this node.
"""
return len(self.subnodes) == 0
return not self.subnodes

def is_root(self):
"""
Expand All @@ -226,7 +226,9 @@ def is_root(self):
:rtype: bool
:return: True if the current node is the root node.
"""
return self.directory.keys()[0] == self.name
for key in self.directory.keys():
return key == self.name
raise Exception('Empty directory!')

def is_relevant(self):
"""
Expand Down Expand Up @@ -330,7 +332,7 @@ def __str__(self):
return self.tree()

def __repr__(self):
return self.tree()
return self.name


__all__ = ['APINode']
Expand Down
8 changes: 0 additions & 8 deletions test/test_autoapi.py
Expand Up @@ -29,14 +29,6 @@
from autoapi import __version__


def setup_module(module):
print('setup_module({})'.format(module.__name__))


def teardown_module(module):
print('teardown_module({})'.format(module.__name__))


def test_semantic_version():
"""
Check that version follows the Semantic Versioning 2.0.0 specification.
Expand Down
52 changes: 52 additions & 0 deletions test/test_autoapi_apinode.py
@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015 Carlos Jenkins <carlos@jenkins.co.cr>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

"""
Test suite for module autoapi.apinode.
See http://pythontesting.net/framework/pytest/pytest-introduction/#fixtures
"""

from __future__ import unicode_literals, absolute_import
from __future__ import print_function, division

import pytest # noqa

from autoapi import APINode


def test_autotree():
"""
Check that the APINode tree is consistent with a known package.
"""
tree = APINode('autoapi')

assert tree.is_root()
assert len(tree.directory) == 3
assert tree.is_relevant()
assert tree.has_public_api()
assert tree.get_module('autoapi.apinode') is not None
assert not tree.get_module('autoapi.apinode').is_relevant()
assert tree.tree()
assert tree.tree(fullname=False)
assert repr(tree)
assert str(tree)

for node, leaves in tree.walk():
assert not node.is_leaf()
for leaf in leaves:
assert leaf.is_leaf()

0 comments on commit 0c693a9

Please sign in to comment.