# 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 add_note_bad_date_test():
    """
    Checks error raised when malformed date passed to Notebook.add_note(). 
    """
    nb.addnote('2015-20-27', 'Test', 'test.md')

@raises(ScribblerError)
def add_note_existing_test():
    """
    Checks error raised when Notebook.add_note() tries to add a note in existing file. 
    """
    testnb = Notebook('test notebook', 'test_notebook')
    testnb.notes['test.md'] = None
    testnb.addnote('2015-10-27', 'Test', 'test_notebook/notes/test.md')
    
@patch('scribbler.content.ScribblerContent.__init__')
@patch('scribbler.notebook.Notebook.save', mock_save)
def add_page_test(add):
    """
    Tests Notebook.add_page() behave correctly.
    """
    testnb = Notebook('test notebook', 'test_notebook')
    add.return_value = None
    testnb.addpage('Test', 'test.md')
    add.assert_called_with('Test', '????-??-??', '../../test.md', testnb)
    testnb.addpage('Test', 'test_notebook/appendices/test.md')
    add.assert_called_with('Test', '????-??-??', 'test.md', testnb)
    testnb.addpage('Test 2', 'test_notebook/appendices/test.md', True)
    add.assert_called_with('Test 2', '????-??-??', 'test.md', testnb)


# 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 add_note_bad_date_test():
    """
    Checks error raised when malformed date passed to Notebook.add_note(). 
    """
    nb.addnote('2015-20-27', 'Test', 'test.md')

@raises(ScribblerError)
def add_note_existing_test():
    """
    Checks error raised when Notebook.add_note() tries to add a note in existing file. 
    """
    testnb = Notebook('test notebook', 'test_notebook')
    testnb.notes['test.md'] = None
    testnb.addnote('2015-10-27', 'Test', 'test_notebook/notes/test.md')
    
@patch('scribbler.content.ScribblerContent.__init__')
@patch('scribbler.notebook.Notebook.save', mock_save)
def add_page_test(add):
    """
    Tests Notebook.add_page() behave correctly.
    """
    testnb = Notebook('test notebook', 'test_notebook')
    add.return_value = None
    testnb.addpage('Test', 'test.md')
    add.assert_called_with('Test', '????-??-??', '../../test.md', testnb)
    testnb.addpage('Test', 'test_notebook/appendices/test.md')
    add.assert_called_with('Test', '????-??-??', 'test.md', testnb)
    testnb.addpage('Test 2', 'test_notebook/appendices/test.md', True)
    add.assert_called_with('Test 2', '????-??-??', 'test.md', testnb)


@raises(ScribblerError)