# Path: scribbler/errors.py
# class ScribblerError(Exception):
#     pass


import os.path
import shutil
import yaml
from tempfile import mkdtemp
from filecmp import cmp
from copy import copy
from time import sleep
from pickle import load
from scribbler.notebook import *
from scribbler.content import *
from scribbler.errors import ScribblerError
from mock import MagicMock, patch
from nose.tools import *

def teardown_pelicanconf():
    os.remove('pelicanconf.py')
    os.remove('pelicanconf.pyc')

@with_setup(setup_null, teardown_pelicanconf)        
@patch('scribbler.notebook.Notebook.pelican_settings', mock_psettings)
def pelicanconf_test():
    """
    Chekcs Notebook.make_pelicaconf() and Notebook.del_pelicanconf() create and delete pelicanconf.py correctly.
    """
    nb.make_pelicanconf()
    shutil.copy(os.path.join(loc, nb.PELICANCONF_FILE), 'pelicanconf.py')
    conf = __import__('pelicanconf')
    conf_dict = vars(conf)
    for key in ['__builtins__', '__doc__', '__file__', '__name__',
                '__package__']:
        del conf_dict[key]
    assert conf_dict == nb.pelican_settings
    assert nb.del_pelicanconf()
    assert not os.path.isfile(os.path.join(loc, nb.PELICANCONF_FILE))
    assert not nb.del_pelicanconf()
        
@raises(NotImplementedError)
def list_test():
    """
    Tests Notebook.list_contents(), which is not yet implemented.
    """
    nb.list_contents()


# Path: scribbler/errors.py
# class ScribblerError(Exception):
#     pass


# Path: tests/notebook_test.py
import os.path
import shutil
import yaml
from tempfile import mkdtemp
from filecmp import cmp
from copy import copy
from time import sleep
from pickle import load
from scribbler.notebook import *
from scribbler.content import *
from scribbler.errors import ScribblerError
from mock import MagicMock, patch
from nose.tools import *


def teardown_pelicanconf():
    os.remove('pelicanconf.py')
    os.remove('pelicanconf.pyc')

@with_setup(setup_null, teardown_pelicanconf)        
@patch('scribbler.notebook.Notebook.pelican_settings', mock_psettings)
def pelicanconf_test():
    """
    Chekcs Notebook.make_pelicaconf() and Notebook.del_pelicanconf() create and delete pelicanconf.py correctly.
    """
    nb.make_pelicanconf()
    shutil.copy(os.path.join(loc, nb.PELICANCONF_FILE), 'pelicanconf.py')
    conf = __import__('pelicanconf')
    conf_dict = vars(conf)
    for key in ['__builtins__', '__doc__', '__file__', '__name__',
                '__package__']:
        del conf_dict[key]
    assert conf_dict == nb.pelican_settings
    assert nb.del_pelicanconf()
    assert not os.path.isfile(os.path.join(loc, nb.PELICANCONF_FILE))
    assert not nb.del_pelicanconf()
        
@raises(NotImplementedError)
def list_test():
    """
    Tests Notebook.list_contents(), which is not yet implemented.
    """
    nb.list_contents()


@raises(ScribblerError)