def testCheckName(self): assert tools.checkName('domain') assert not tools.checkName('doma:in') assert tools.checkName('doD432_main') assert tools.checkName('doD432-main') assert not tools.checkName('doma:in') assert not tools.checkName(' domain') assert not tools.checkName('do main') assert not tools.checkName('doma?in') assert not tools.checkName('doma@in')
def addDomain(self, identifier): if identifier == '': raise ValueError('No name given.') elif not checkName(identifier): raise ValueError('Name is not valid. Only use alphanumeric characters.') filename = "{}.domain".format(identifier) if self._exists(filename): raise ValueError('The domain already exists.') self._save(JsonDict(dict(identifier=identifier)), filename)
def addDomain(self, identifier): if identifier == '': raise ValueError('No name given.') elif not checkName(identifier): raise ValueError( 'Name is not valid. Only use alphanumeric characters.') if self._store.exists(identifier, 'domain'): raise ValueError('The domain already exists.') self._store.addData(identifier, 'domain', JsonDict({'identifier': identifier}))
def addRepositoryGroup(self, identifier, domainId): domain = self.getDomain(domainId) filename = "{}.{}.repositoryGroup".format(domainId, identifier) if identifier == '': raise ValueError('No name given.') elif not checkName(identifier): raise ValueError('Name is not valid. Only use alphanumeric characters.') if identifier.lower() in [g.lower() for g in domain.get('repositoryGroupIds', [])]: raise ValueError('The repositoryGroup already exists.') self._save(JsonDict(dict(identifier=identifier)), filename) domain.setdefault('repositoryGroupIds', []).append(identifier) self._save(domain, "{}.domain".format(domainId))
def addRepository(self, identifier, domainId, repositoryGroupId): group = self.getRepositoryGroup(repositoryGroupId, domainId) filename = "{}.{}.repository".format(domainId, identifier) if identifier == '': raise ValueError('No name given.') elif not checkName(identifier): raise ValueError('Name is not valid. Only use alphanumeric characters.') if identifier.lower() in [r.lower() for r in group.get('repositoryIds', [])]: raise ValueError('The repository already exists.') self._save(JsonDict(dict(identifier=identifier, repositoryGroupId=repositoryGroupId)), filename) group.setdefault('repositoryIds', []).append(identifier) self._save(group, "{}.{}.repositoryGroup".format(domainId, repositoryGroupId))
def addRepositoryGroup(self, identifier, domainId): domain = self.getDomain(domainId) if identifier is None or identifier.strip() == '': raise ValueError('No name given.') elif not checkName(identifier): raise ValueError( 'Name is not valid. Only use alphanumeric characters.') if identifier.lower() in [ g.lower() for g in domain.get('repositoryGroupIds', []) ]: raise ValueError('The repositoryGroup already exists.') self._store.addData(id_combine(domainId, identifier), 'repositoryGroup', {'identifier': identifier}) domain.setdefault('repositoryGroupIds', []).append(identifier) self._store.addData(domainId, 'domain', domain)
def addRepository(self, identifier, domainId, repositoryGroupId): group = self.getRepositoryGroup(repositoryGroupId, domainId) if identifier == '': raise ValueError('No name given.') elif not checkName(identifier): raise ValueError( 'Name is not valid. Only use alphanumeric characters.') if identifier.lower() in [ r.lower() for r in group.get('repositoryIds', []) ]: raise ValueError('The repository already exists.') if self._store.exists(id_combine(domainId, identifier), 'repository'): raise ValueError("Repository name already in use.") self._store.addData( id_combine(domainId, identifier), 'repository', JsonDict( dict(identifier=identifier, repositoryGroupId=repositoryGroupId))) group.setdefault('repositoryIds', []).append(identifier) self._store.addData(id_combine(domainId, repositoryGroupId), 'repositoryGroup', group)