def test_build(): box = Box.create(box1_path) box2 = Box.create(box2_path) foo_path = os.path.join(sourcedirs_path, 'foo') foo_source = SourceDir(foo_path) assert foo_source.path == foo_path bar_path = os.path.join(sourcedirs_path, 'bar') bar_source = SourceDir(bar_path) foo = foo_source.build(box) bar = bar_source.build(box) foo_new = foo_source.build(box, name_suffix='-new') assert foo.enabled == False assert foo_new.enabled == True assert os.path.samefile(os.path.join(box.virtual_path, 'lib', 'd', 'foo'), os.path.join(foo_new.path, 'lib', 'd', 'foo')) assert foo_source.unittest() == True assert bar_source.unittest() == False foo_source.build(box2) # Should clean before assert len(list(box.packages(only_enabled=True))) == 2 box.disable_package(foo_new) assert not os.path.exists(os.path.join(box.virtual_path, 'lib', 'd', 'foo')) foo_source.clean() bar_source.clean()
def test_packages(): box = Box.create(box1_path) foo = box.create_package('foo-0.1', app_name='foo', app_version='0.1', enabled=True) bar = box.create_package('bar-0.2', app_name='bar', app_version='0.2', enabled=False) assert len(list(box.packages())) == 2 l = list(box.packages(only_enabled=True)) assert len(l) == 1 assert l[0] is foo box.disable_package(foo) assert len(list(box.packages(only_enabled=True))) == 0 box.enable_package(foo) box.enable_package(bar) assert len(list(box.packages(only_enabled=True))) == 2 assert len(list(box.packages(only_enabled=True, matching=['foo.*']))) == 1 box.disable_package(foo) assert len(list(box.packages(only_enabled=True, matching=['foo.*']))) == 0 assert len(list(box.packages(matching=['foo.*']))) == 1 box.disable_package(bar, remove=True) assert len(list(box.packages())) == 1
def test_create(): assert_raises(UserError, Box, box1_path) # No box, should raise box = Box.create(box1_path) assert box.path == box1_path assert_raises(UserError, Box.create, box1_path)
def _run(self, config, cmd_options, cmd_args): self._require_args(cmd_args, 1, 1) box_path = cmd_args[0] Box.create(box_path)