# Path: pubs/content.py
# class UnableToDecodeTextFile(Exception):
#     def __init__(self, path):
#     def __str__(self):
# def _check_system_path_exists(path, fail=True):
# def _check_system_path_is(nature, path, fail=True):
# def system_path(path):
# def _open(path, mode):
# def check_file(path, fail=True):
# def check_directory(path, fail=True):
# def read_text_file(filepath, fail=True):
# def read_binary_file(filepath, fail=True):
# def remove_file(filepath):
# def write_file(filepath, data, mode='w'):
# def content_type(path):
# def url_exists(url):
# def check_content(path):
# def _get_byte_url_content(path, ui=None):
# def _dump_byte_url_content(source, target):
# def get_content(path, ui=None):
# def move_content(source, target, overwrite=False):
# def copy_content(source, target, overwrite=False):
# 
# Path: pubs/filebroker.py
# META_EXT = '.yaml'
# BIB_EXT  = '.bib'
# def filter_filename(filename, ext):
#     def __init__(self, directory, create=False):
#     def _create(self):
#     def bib_path(self, citekey):
#     def meta_path(self, citekey):
#     def pull_cachefile(self, filename):
#     def push_cachefile(self, filename, data):
#     def mtime_metafile(self, citekey):
#     def mtime_bibfile(self, citekey):
#     def pull_metafile(self, citekey):
#     def pull_bibfile(self, citekey):
#     def push_metafile(self, citekey, metadata):
#     def push_bibfile(self, citekey, bibdata):
#     def push(self, citekey, metadata, bibdata):
#     def remove(self, citekey):
#     def exists(self, citekey, meta_check=False):
#     def listing(self, filestats=True):
#     def __init__(self, directory, scheme='docsdir', subdir='doc'):
#     def in_docsdir(self, docpath):
#     def real_docpath(self, docpath):
#     def add_doc(self, citekey, source_path, overwrite=False):
#     def remove_doc(self, docpath, silent=True):
#     def rename_doc(self, docpath, new_citekey):
# class FileBroker(object):
# class DocBroker(object):


import unittest
import os
import dotdot
import fake_env
from pubs import content, filebroker
# -*- coding: utf-8 -*-




class TestFileBroker(fake_env.TestFakeFs):

    def test_pushpull1(self):

        fb = filebroker.FileBroker('bla', create = True)

        fb.push_metafile('citekey1', 'abc')
        fb.push_bibfile('citekey1', 'cdef')

        self.assertEqual(fb.pull_metafile('citekey1'), 'abc')
        self.assertEqual(fb.pull_bibfile('citekey1'), 'cdef')

        fb.push_bibfile('citekey1', 'ghi')


# Path: pubs/content.py
# class UnableToDecodeTextFile(Exception):
#     def __init__(self, path):
#     def __str__(self):
# def _check_system_path_exists(path, fail=True):
# def _check_system_path_is(nature, path, fail=True):
# def system_path(path):
# def _open(path, mode):
# def check_file(path, fail=True):
# def check_directory(path, fail=True):
# def read_text_file(filepath, fail=True):
# def read_binary_file(filepath, fail=True):
# def remove_file(filepath):
# def write_file(filepath, data, mode='w'):
# def content_type(path):
# def url_exists(url):
# def check_content(path):
# def _get_byte_url_content(path, ui=None):
# def _dump_byte_url_content(source, target):
# def get_content(path, ui=None):
# def move_content(source, target, overwrite=False):
# def copy_content(source, target, overwrite=False):
# 
# Path: pubs/filebroker.py
# META_EXT = '.yaml'
# BIB_EXT  = '.bib'
# def filter_filename(filename, ext):
#     def __init__(self, directory, create=False):
#     def _create(self):
#     def bib_path(self, citekey):
#     def meta_path(self, citekey):
#     def pull_cachefile(self, filename):
#     def push_cachefile(self, filename, data):
#     def mtime_metafile(self, citekey):
#     def mtime_bibfile(self, citekey):
#     def pull_metafile(self, citekey):
#     def pull_bibfile(self, citekey):
#     def push_metafile(self, citekey, metadata):
#     def push_bibfile(self, citekey, bibdata):
#     def push(self, citekey, metadata, bibdata):
#     def remove(self, citekey):
#     def exists(self, citekey, meta_check=False):
#     def listing(self, filestats=True):
#     def __init__(self, directory, scheme='docsdir', subdir='doc'):
#     def in_docsdir(self, docpath):
#     def real_docpath(self, docpath):
#     def add_doc(self, citekey, source_path, overwrite=False):
#     def remove_doc(self, docpath, silent=True):
#     def rename_doc(self, docpath, new_citekey):
# class FileBroker(object):
# class DocBroker(object):


# Path: tests/test_filebroker.py
import unittest
import os
import dotdot
import fake_env
from pubs import content, filebroker

# -*- coding: utf-8 -*-




class TestFileBroker(fake_env.TestFakeFs):

    def test_pushpull1(self):

        fb = filebroker.FileBroker('bla', create = True)

        fb.push_metafile('citekey1', 'abc')
        fb.push_bibfile('citekey1', 'cdef')

        self.assertEqual(fb.pull_metafile('citekey1'), 'abc')
        self.assertEqual(fb.pull_bibfile('citekey1'), 'cdef')

        fb.push_bibfile('citekey1', 'ghi')


        self.assertEqual(fb.pull_bibfile('citekey1'), 'ghi')