def test_writer_class_fs(): """File System writer is the appropriate class when a protocol isn't present.""" client = Client('/path/to/somewhere') assert client.base == '/path/to/somewhere' assert client.writer_class == FSWriteContent client = Client('file://somewhere') assert client.base == 'somewhere' assert client.writer_class == FSWriteContent
def test_writer_class(self): settings.API_BASE = '' client = Client() self.assertEqual('FSWriteContent', client.writer_class.__name__) settings.GIT_OUTPUT_DIR = 'some path' client = Client() self.assertEqual('GitWriteContent', client.writer_class.__name__) settings.GIT_OUTPUT_DIR = '' settings.API_BASE = 'some url' client = Client() self.assertEqual('APIWriteContent', client.writer_class.__name__)
def write_to(output, cfr_title, cfr_part): """Export data. Sends all data in the index to an external source. \b OUTPUT can be a * directory (if it does not exist, it will be created) * uri (the base url of an instance of regulations-core) * a directory prefixed with "git://". This will export to a git repository""" logger.info("Export output - %s CFR %s, Destination: %s", cfr_title, cfr_part, output) client = Client(output) write_trees(client, cfr_title, cfr_part) write_layers(client, cfr_title, cfr_part) write_notices(client, cfr_title, cfr_part) write_diffs(client, cfr_title, cfr_part) if cfr_title is None and cfr_part is None: write_preambles(client)
def test_writer_class_git(): """Git will be used if the protocol is git://""" client = Client('git://some/path') assert client.base == 'some/path' assert client.writer_class == GitWriteContent
def test_preamble(tmpdir): reg_writer = Client(str(tmpdir)).preamble("docdoc") assert reg_writer.path == str(tmpdir.join("preamble", "docdoc"))
def test_diff(tmpdir): reg_writer = Client(str(tmpdir)).diff("lablab", "oldold", "newnew") assert reg_writer.path == str( tmpdir.join("diff", "lablab", "oldold", "newnew"))
def test_notice(tmpdir): reg_writer = Client(str(tmpdir)).notice("docdoc") assert reg_writer.path == str(tmpdir.join("notice", "docdoc"))
def test_layer(tmpdir): reg_writer = Client(str(tmpdir)).layer("boblayer", "lablab", "docdoc") assert reg_writer.path == str( tmpdir.join("layer", "boblayer", "lablab", "docdoc"))
def test_regulation(tmpdir): reg_writer = Client(str(tmpdir)).regulation("lablab", "docdoc") assert reg_writer.path == str( tmpdir.join("regulation", "lablab", "docdoc"))
def test_diff(self): client = Client() reg_writer = client.diff("lablab", "oldold", "newnew") self.assertEqual("diff/lablab/oldold/newnew", reg_writer.path)
def test_notice(self): client = Client() reg_writer = client.notice("docdoc") self.assertEqual("notice/docdoc", reg_writer.path)
def test_layer(self): client = Client() reg_writer = client.layer("boblayer", "lablab", "docdoc") self.assertEqual("layer/boblayer/lablab/docdoc", reg_writer.path)
def test_regulation(self): client = Client() reg_writer = client.regulation("lablab", "docdoc") self.assertEqual("regulation/lablab/docdoc", reg_writer.path)
def test_notice(self): client = Client() reg_writer = client.notice("docdoc", '1234-56789') self.assertEqual("notice/docdoc/1234-56789", reg_writer.path)