def test_add_djangorecipe_to_buildoutconfig(self): bc = BuildoutConfig() djangorecipe = recipes['djangorecipe'] dr = djangorecipe(bc, 'django') dr.settings = 'development' dr.version = '1.2.1' dr.eggs = '${eggs:eggs}' dr.project = 'greatbigcrane' dr.extra_paths = '${eggs:extra-paths}' dr.fcgi = True dr.wsgi = False django = bc['django'] assert django assert django['recipe'] == 'djangorecipe' assert django['settings'] == 'development' assert django['version'] == '1.2.1' assert django['eggs'] == '${eggs:eggs}' assert django['project'] == 'greatbigcrane' assert django['extra-paths'] == '${eggs:extra-paths}' assert django['fcgi'] == 'true' assert django['wsgi'] == 'false' fp = tempfile.NamedTemporaryFile() buildout_write(fp.name, bc) data = fp.read() assert data == """[buildout]
def test_write_obscene_amount_of_sections(self): bc = BuildoutConfig() bc['buildout']['parts'] = '' bc['1section']['a'] = '1' bc['8section']['b'] = '3' bc['2section']['c'] = '4' bc['something']['d'] = '99eleven' bc['09876']['d'] = ['yes', 'again'] bc['dusty']['kkkkk'] = '' bc['dusty']['kkkk'] = '' bc['dusty']['k'] = '' bc['dusty']['kk'] = '' bc['dusty']['kkk'] = '' bc['dusty']['argh!'] = '' assert bc.keys() != dict(bc.items()).keys(), "A regular dict's key order should be different than a BuildoutConfig's" assert bc['dusty'].keys() != dict(bc['dusty'].items()).keys() fp = tempfile.NamedTemporaryFile() buildout_write(fp.name, bc) data = fp.read() assert data == """[buildout]
def test_parse_replacements(self): fp = mktmpcfg(complicated_buildout_cfg) bc = buildout_parse(fp.name) eggrecipe = recipes['zc.recipe.egg'] eg = eggrecipe(bc, 'eggs') assert eg.extra_paths == ['${buildout:directory}/parts/django', '${buildout:directory}/parts/django-registration', '${buildout:directory}/greatbigcrane', '${buildout:directory}/parts/pyzmq', ] eg.extra_paths = '/something/${buildout:directory}/another/thing' djangorecipe = recipes['djangorecipe'] dr = djangorecipe(bc, 'django') assert dr.eggs == '${eggs:eggs}' fp.seek(0) buildout_write(fp.name, bc) data = fp.read() assert data == """[buildout]
def test_write_simplest_list_buildout(self): bc = BuildoutConfig() bc['buildout']['parts'] = '' bc['buildout']['find-links'] = ['http://pypi.python.org/simple', 'http://python.org'] fp = tempfile.NamedTemporaryFile() buildout_write(fp.name, bc) data = fp.read() assert data == '''[buildout]
def save(self, buildout): name = self.cleaned_data['name'] old_name = self.cleaned_data['old_name'] dr = recipes['zc.recipe.egg'](buildout, name) for key in self.fields: if key == "name": continue value = self.cleaned_data[key] if not isinstance(value, bool) and '\r\n' in value: value = value.split('\r\n') if value: setattr(dr, key, value) else: delattr(dr, key) if name.strip() != old_name.strip(): del buildout[old_name] buildout.remove_part(old_name) buildout_write(self.project.buildout_filename(), buildout)
def test_change_existing_djangorecipe(self): fp = mktmpcfg(complicated_buildout_cfg) bc = buildout_parse(fp.name) djangorecipe = recipes['djangorecipe'] dr = djangorecipe(bc, 'django') dr.settings = 'production' dr.version = '1.1.1' dr.fcgi = False dr.wsgi = False dr.eggs = [dr.eggs, '${pyzmq:parts}'] fp.seek(0) buildout_write(fp.name, bc) data = fp.read() assert data == """[buildout]
def test_write_complicated_config(self): bc = BuildoutConfig() sec = bc['buildout'] sec['parts'] = ['eggs', 'django', 'pyzmq'] sec['unzip'] = 'true' sec = bc['eggs'] sec['recipe'] = 'zc.recipe.egg' sec['eggs'] = ['south==0.7.1', 'IPython'] sec['extra-paths'] = ['${buildout:directory}/parts/django', '${buildout:directory}/parts/django-registration', '${buildout:directory}/greatbigcrane', '${buildout:directory}/parts/pyzmq'] sec = bc['django'] sec['settings'] = 'development' sec['recipe'] = 'djangorecipe' sec['version'] = '1.2.1' sec['eggs'] = '${eggs:eggs}' sec['project'] = 'greatbigcrane' sec['extra-paths'] = '${eggs:extra-paths}' sec['fcgi'] = 'True' sec['wsgi'] = 'True' sec = bc['pyzmq'] sec['recipe'] = 'zerokspot.recipe.git' sec['repository'] = 'http://github.com/zeromq/pyzmq.git' sec['as_egg'] = 'True' fp = tempfile.NamedTemporaryFile() buildout_write(fp.name, bc) data = fp.read() assert data == """[buildout]