# Path: binstar_client/inspect_package/ipynb.py
# def inspect_ipynb_package(filename, fileobj, *args, **kwargs):
#     notebook = nbformat.read(fileobj, nbformat.NO_CONVERT)
#     summary = notebook['metadata'].get('summary', 'Jupyter Notebook')
#     description = notebook['metadata'].get('description', 'Jupyter Notebook')
# 
#     package_data = {
#         'name': re.sub('\-ipynb$', '', parameterize(os.path.basename(filename))),
#         'summary': summary,
#         'description': description,
#     }
# 
#     if 'parser_args' in kwargs and kwargs['parser_args'].thumbnail:
#         package_data['thumbnail'] = data_uri_from(kwargs['parser_args'].thumbnail)
# 
#     release_data = {
#         'version': datetime.now().strftime('%Y.%m.%d.%H%M'),
#         'summary': summary,
#         'description': description,
#     }
# 
#     file_data = {
#         'basename': os.path.basename(filename),
#         'attrs': {}
#     }
# 
#     return package_data, release_data, file_data
# 
# Path: binstar_client/utils/test/utils.py
# def data_dir(filename):
#     base_path = inspect.stack()[1][1]  # function caller path
#     test_data = os.path.join(os.path.dirname(base_path), 'data')
#     return os.path.join(test_data, filename)


import unittest
from collections import namedtuple
from freezegun import freeze_time
from binstar_client.inspect_package.ipynb import inspect_ipynb_package
from binstar_client.utils.test.utils import data_dir
            'summary': 'ipynb summary',
        }, package_data)

    def test_package_data_no_metadata(self):
        with open(data_dir('notebook-no-metadata.ipynb')) as fd:
            package_data, _, _ = inspect_ipynb_package('notebook.ipynb', fd)

        self.assertEqual({
            'name': 'notebook',
            'description': 'Jupyter Notebook',
            'summary': 'Jupyter Notebook',
        }, package_data)

    def test_package_data_normalized_name(self):
        with open(data_dir('notebook.ipynb')) as fd:
            package_data, _, _ = inspect_ipynb_package('test nótëbOOk.ipynb', fd)

        self.assertIn('name', package_data)
        self.assertEqual(package_data['name'], 'test-notebook')

    def test_package_thumbnail(self):
        parser_args = namedtuple('parser_args', ['thumbnail'])(data_dir('43c9b994a4d96f779dad87219d645c9f.png'))
        with open(data_dir('notebook.ipynb')) as fd:
            package_data, _, _ = inspect_ipynb_package('notebook.ipynb', fd, parser_args=parser_args)

        self.assertIn('thumbnail', package_data)

    def test_release_data(self):
        with freeze_time('2018-02-01 09:10:00', tz_offset=0):
            with open(data_dir('notebook.ipynb')) as fd:

# Path: binstar_client/inspect_package/ipynb.py
# def inspect_ipynb_package(filename, fileobj, *args, **kwargs):
#     notebook = nbformat.read(fileobj, nbformat.NO_CONVERT)
#     summary = notebook['metadata'].get('summary', 'Jupyter Notebook')
#     description = notebook['metadata'].get('description', 'Jupyter Notebook')
# 
#     package_data = {
#         'name': re.sub('\-ipynb$', '', parameterize(os.path.basename(filename))),
#         'summary': summary,
#         'description': description,
#     }
# 
#     if 'parser_args' in kwargs and kwargs['parser_args'].thumbnail:
#         package_data['thumbnail'] = data_uri_from(kwargs['parser_args'].thumbnail)
# 
#     release_data = {
#         'version': datetime.now().strftime('%Y.%m.%d.%H%M'),
#         'summary': summary,
#         'description': description,
#     }
# 
#     file_data = {
#         'basename': os.path.basename(filename),
#         'attrs': {}
#     }
# 
#     return package_data, release_data, file_data
# 
# Path: binstar_client/utils/test/utils.py
# def data_dir(filename):
#     base_path = inspect.stack()[1][1]  # function caller path
#     test_data = os.path.join(os.path.dirname(base_path), 'data')
#     return os.path.join(test_data, filename)


# Path: binstar_client/inspect_package/tests/test_ipynb.py
import unittest
from collections import namedtuple
from freezegun import freeze_time
from binstar_client.inspect_package.ipynb import inspect_ipynb_package
from binstar_client.utils.test.utils import data_dir

            'summary': 'ipynb summary',
        }, package_data)

    def test_package_data_no_metadata(self):
        with open(data_dir('notebook-no-metadata.ipynb')) as fd:
            package_data, _, _ = inspect_ipynb_package('notebook.ipynb', fd)

        self.assertEqual({
            'name': 'notebook',
            'description': 'Jupyter Notebook',
            'summary': 'Jupyter Notebook',
        }, package_data)

    def test_package_data_normalized_name(self):
        with open(data_dir('notebook.ipynb')) as fd:
            package_data, _, _ = inspect_ipynb_package('test nótëbOOk.ipynb', fd)

        self.assertIn('name', package_data)
        self.assertEqual(package_data['name'], 'test-notebook')

    def test_package_thumbnail(self):
        parser_args = namedtuple('parser_args', ['thumbnail'])(data_dir('43c9b994a4d96f779dad87219d645c9f.png'))
        with open(data_dir('notebook.ipynb')) as fd:
            package_data, _, _ = inspect_ipynb_package('notebook.ipynb', fd, parser_args=parser_args)

        self.assertIn('thumbnail', package_data)

    def test_release_data(self):
        with freeze_time('2018-02-01 09:10:00', tz_offset=0):
            with open(data_dir('notebook.ipynb')) as fd:

                _, release_data, _ = inspect_ipynb_package('notebook.ipynb', fd)