# Path: bento/core/testing.py
# def create_fake_package_from_bento_info(top_node, bento_info):
#     d = raw_parse(bento_info)
#     _kw, files = raw_to_pkg_kw(d, {}, None)
#     kw = {}
#     if "extensions" in _kw:
#         kw["extensions"] = _kw["extensions"].values()
#     if "py_modules" in _kw:
#         kw["modules"] = _kw["py_modules"]
#     if "packages" in _kw:
#         kw["packages"] = _kw["packages"]
#     if "compiled_libraries" in _kw:
#         kw["compiled_libraries"] = _kw["compiled_libraries"].values()
#     if "extra_source_files" in _kw:
#         kw["extra_source_files"] = _kw["extra_source_files"]
#     if "sub_directory" in _kw:
#         kw["sub_directory"] = _kw["sub_directory"]
#     if "data_files" in _kw:
#         kw["data_files"] = _kw["data_files"]
#     return create_fake_package(top_node, **kw)


import os
import tempfile
import shutil
import os.path as op
from bento.compat.api.moves \
    import \
        unittest
from bento.core.package \
    import \
        PackageDescription
from bento.core.node_package \
    import \
        NodeRepresentation
from bento.core.node \
    import \
        create_root_with_source_tree
from bento.core.testing \
    import \
        create_fake_package_from_bento_info

Library:
    Extension: _foo
        Sources: src/foo.c, src/bar.c
"""
        create_fake_package_from_bento_info(self.top_node, bento_info)

        bento_info = """\
Name: foo

Library:
    Extension: _foo
        Sources: src/foo.c, src/bar.c
"""
        pkg = PackageDescription.from_string(bento_info)
        node_pkg = NodeRepresentation(self.top_node, self.top_node)
        node_pkg.update_package(pkg)

        extensions = dict(node_pkg.iter_category("extensions"))
        self.assertEqual(len(extensions), 1)
        self.assertEqual(len(extensions["_foo"].nodes), 2)

    def test_sources_glob(self):
        bento_info = """\
Name: foo

Library:
    Extension: _foo
        Sources: src/foo.c, src/bar.c
"""

# Path: bento/core/testing.py
# def create_fake_package_from_bento_info(top_node, bento_info):
#     d = raw_parse(bento_info)
#     _kw, files = raw_to_pkg_kw(d, {}, None)
#     kw = {}
#     if "extensions" in _kw:
#         kw["extensions"] = _kw["extensions"].values()
#     if "py_modules" in _kw:
#         kw["modules"] = _kw["py_modules"]
#     if "packages" in _kw:
#         kw["packages"] = _kw["packages"]
#     if "compiled_libraries" in _kw:
#         kw["compiled_libraries"] = _kw["compiled_libraries"].values()
#     if "extra_source_files" in _kw:
#         kw["extra_source_files"] = _kw["extra_source_files"]
#     if "sub_directory" in _kw:
#         kw["sub_directory"] = _kw["sub_directory"]
#     if "data_files" in _kw:
#         kw["data_files"] = _kw["data_files"]
#     return create_fake_package(top_node, **kw)


# Path: bento/core/tests/test_node_representation.py
import os
import tempfile
import shutil
import os.path as op
from bento.compat.api.moves \
    import \
        unittest
from bento.core.package \
    import \
        PackageDescription
from bento.core.node_package \
    import \
        NodeRepresentation
from bento.core.node \
    import \
        create_root_with_source_tree
from bento.core.testing \
    import \
        create_fake_package_from_bento_info


Library:
    Extension: _foo
        Sources: src/foo.c, src/bar.c
"""
        create_fake_package_from_bento_info(self.top_node, bento_info)

        bento_info = """\
Name: foo

Library:
    Extension: _foo
        Sources: src/foo.c, src/bar.c
"""
        pkg = PackageDescription.from_string(bento_info)
        node_pkg = NodeRepresentation(self.top_node, self.top_node)
        node_pkg.update_package(pkg)

        extensions = dict(node_pkg.iter_category("extensions"))
        self.assertEqual(len(extensions), 1)
        self.assertEqual(len(extensions["_foo"].nodes), 2)

    def test_sources_glob(self):
        bento_info = """\
Name: foo

Library:
    Extension: _foo
        Sources: src/foo.c, src/bar.c
"""

        create_fake_package_from_bento_info(self.top_node, bento_info)