def test_isIdentifier(self):
     good = [
         u"linux",
         u"Linux",
         u"abc123",
         u"a" * 50,
     ]
     for g in good:
         log.msg('expect %r to be good' % (g, ))
         self.assertTrue(identifiers.isIdentifier(50, g))
     bad = [
         None,
         u'',
         'linux',
         u'a/b',
         u'\N{SNOWMAN}',
         u"a.b.c.d",
         u"a-b_c.d9",
         'spaces not allowed',
         u"a" * 51,
         u"123 no initial digits",
     ]
     for b in bad:
         log.msg('expect %r to be bad' % (b, ))
         self.assertFalse(identifiers.isIdentifier(50, b))
Esempio n. 2
0
    def test_isIdentifier(self):
        os_encoding = locale.getpreferredencoding()
        try:
            '\N{SNOWMAN}'.encode(os_encoding)
        except UnicodeEncodeError:
            # Default encoding of Windows console is 'cp1252'
            # which cannot encode the snowman.
            raise (unittest.SkipTest(
                "Cannot encode weird unicode "
                "on this platform with {}".format(os_encoding)))

        good = ["linux", "Linux", "abc123", "a" * 50, '\N{SNOWMAN}']
        for g in good:
            log.msg('expect %r to be good' % (g, ))
            self.assertTrue(identifiers.isIdentifier(50, g))
        bad = [
            None,
            '',
            b'linux',
            'a/b',
            "a.b.c.d",
            "a-b_c.d9",
            'spaces not allowed',
            "a" * 51,
            "123 no initial digits",
            '\N{SNOWMAN}.\N{SNOWMAN}',
        ]
        for b in bad:
            log.msg('expect %r to be bad' % (b, ))
            self.assertFalse(identifiers.isIdentifier(50, b))
Esempio n. 3
0
 def test_isIdentifier(self):
     good = [
         u"linux", u"Linux", u"abc123", u"a" * 50,
     ]
     for g in good:
         log.msg('expect %r to be good' % (g,))
         self.assertTrue(identifiers.isIdentifier(50, g))
     bad = [
         None, u'', 'linux', u'a/b', u'\N{SNOWMAN}', u"a.b.c.d",
         u"a-b_c.d9", 'spaces not allowed', u"a" * 51,
         u"123 no initial digits",
     ]
     for b in bad:
         log.msg('expect %r to be bad' % (b,))
         self.assertFalse(identifiers.isIdentifier(50, b))
Esempio n. 4
0
 def findWorkerId(self, name):
     tbl = self.db.model.workers
     # callers should verify this and give good user error messages
     assert identifiers.isIdentifier(50, name)
     return self.findSomethingId(tbl=tbl,
                                 whereclause=(tbl.c.name == name),
                                 insert_values=dict(
                                     name=name,
                                     info={},
                                 ))
Esempio n. 5
0
 def findBuildslaveId(self, name):
     tbl = self.db.model.buildslaves
     # callers should verify this and give good user error messages
     assert identifiers.isIdentifier(50, name)
     return self.findSomethingId(
         tbl=tbl,
         whereclause=(tbl.c.name == name),
         insert_values=dict(
             name=name,
             info={},
         ))
Esempio n. 6
0
 def findWorkerId(self, name):
     tbl = self.db.model.workers
     # callers should verify this and give good user error messages
     assert identifiers.isIdentifier(50, name)
     return self.findSomethingId(
         tbl=tbl,
         whereclause=(tbl.c.name == name),
         insert_values=dict(
             name=name,
             info={},
             paused=0,
             graceful=0,
         ))
Esempio n. 7
0
    def test_isIdentifier(self):
        os_encoding = locale.getpreferredencoding()
        try:
            u'\N{SNOWMAN}'.encode(os_encoding)
        except UnicodeEncodeError:
            # Default encoding of Windows console is 'cp1252'
            # which cannot encode the snowman.
            raise(unittest.SkipTest("Cannot encode weird unicode "
                "on this platform with {}".format(os_encoding)))

        good = [
            u"linux", u"Linux", u"abc123", u"a" * 50,
        ]
        for g in good:
            log.msg('expect %r to be good' % (g,))
            self.assertTrue(identifiers.isIdentifier(50, g))
        bad = [
            None, u'', b'linux', u'a/b', u'\N{SNOWMAN}', u"a.b.c.d",
            u"a-b_c.d9", 'spaces not allowed', u"a" * 51,
            u"123 no initial digits",
        ]
        for b in bad:
            log.msg('expect %r to be bad' % (b,))
            self.assertFalse(identifiers.isIdentifier(50, b))
Esempio n. 8
0
 def findWorkerId(self, name):
     if not identifiers.isIdentifier(50, name):
         raise ValueError("Worker name %r is not a 50-character identifier" % (name,))
     return self.master.db.workers.findWorkerId(name)
Esempio n. 9
0
 def findWorkerId(self, name):
     if not identifiers.isIdentifier(50, name):
         raise ValueError(
             "Worker name %r is not a 50-character identifier" % (name, ))
     return self.master.db.workers.findWorkerId(name)
Esempio n. 10
0
 def findBuildslaveId(self, name):
     if not identifiers.isIdentifier(50, name):
         raise ValueError("Buildslave name %r is not a 50-character identifier" % (name,))
     return self.master.db.buildslaves.findBuildslaveId(name)
Esempio n. 11
0
 def findBuildslaveId(self, name):
     if not identifiers.isIdentifier(50, name):
         raise ValueError(
             "Buildslave name %r is not a 50-character identifier" %
             (name, ))
     return self.master.db.buildslaves.findBuildslaveId(name)