def test_custom_tags(self): args = parse_args(["dev", "build", "--tag", "CUSTOM_TAG", "--dry"]) cmd, dfile, pipfile = build(args) self.assertTrue( dockerimage_tag_matches(cmd, "forensicarchitecture/mtriage:CUSTOM_TAG")) args = parse_args( ["run", "docs/tutorial/1/1a.yaml", "--tag", "CUSTOM_TAG", "--dry"]) cmd = run(args) self.assertTrue(cmd[-1] == "forensicarchitecture/mtriage:CUSTOM_TAG")
def test_whitelist(self): args = parse_args(["dev", "build", "--whitelist", self.BLANK_WL, "--dry"]) cmd, dfile, pipfile = build(args) with open("src/build/core.requirements.txt", "r") as f: core_deps = f.readlines() self.assertListEqual(core_deps, pipfile) args = parse_args(["dev", "build", "--whitelist", self.SELECTOR_WL, "--dry"]) cmd, dfile, pipfile = build(args) self.assertListEqual( pipfile, core_deps + read_deps("youtube") + read_deps("twitter") )
def test_default_build(self): args = parse_args(["dev", "build", "--dry"]) cmd, dfile, pipfile = build(args) self.assertTrue( dockerimage_tag_matches(cmd, "forensicarchitecture/mtriage:dev") ) self.assertTrue(builds_from_cpu_dockerfile(dfile))
def test_whitelist(self): args = parse_args( ["dev", "build", "--whitelist", self.BLANK_WL, "--dry"]) cmd, dfile, pipfile = build(args) with open("src/build/core.requirements.txt", "r") as f: core_deps = f.readlines() self.assertListEqual(core_deps, pipfile) args = parse_args( ["dev", "build", "--whitelist", self.SELECTOR_WL, "--dry"]) cmd, dfile, pipfile = build(args) expected_pipfile = core_deps + read_deps("Youtube") + read_deps( "Twitter") expected_pipfile = [x for x in expected_pipfile if x != '\n'] pipfile = [x for x in pipfile if x != '\n'] self.assertListEqual(pipfile, expected_pipfile)
def test_dev_tag(self): dev_args = parse_args(["run", "examples/frames.yaml", "--dev", "--dry"]) cmd = run(dev_args) vs = get_volumes(cmd) media_re = r".*/mtriage/src:/mtriage/src$" has_src = False for v in vs: if re.match(media_re, v): has_src = True break self.assertTrue(has_src) no_dev_args = parse_args(["run", "examples/frames.yaml", "--dry"]) cmd = run(no_dev_args) vs = get_volumes(cmd) matched = False for v in vs: if re.match(media_re, v) is not None: matched = True self.assertFalse(matched)
import os import sys import bonobo import bonobo_sqlalchemy from bonobo.config import use_context @use_context def extract(context): context.set_output_fields(['id', 'value']) for i in range(1000): yield i, 'value for {}'.format(i) def get_graph(**options): graph = bonobo.Graph() graph.add_chain(extract, bonobo_sqlalchemy.InsertOrUpdate('example')) return graph # The __main__ block actually execute the graph. if __name__ == '__main__': sys.path.append(os.path.dirname(__file__)) import commands, services with commands.parse_args() as options: bonobo.run(get_graph(**options), services=services.get_services())
def test_gpu_build(self): args = parse_args(["dev", "build", "--gpu", "--dry"]) cmd, dfile, pipfile = build(args) self.assertTrue(builds_from_gpu_dockerfile(dfile))