Ejemplo n.º 1
0
    def test_output_testinfo(self):
        "Output an example file, then ensure it is parsed succesfully"
        ti1 = parse_string(u"""\
# Test comment
Owner:        Jane Doe <*****@*****.**>
Name:         /examples/coreutils/example-simple-test
Path:         /mnt/tests/examples/coreutils/example-simple-test
Description:  This test ensures that cafés are generated and validated correctly
TestTime:     1m
TestVersion:  1.1
License:      GPL
Destructive:  yes
RunFor:       coreutils
Requires:     coreutils python
NeedProperty: CAKE = CHOCOLATE
NeedProperty: SLICES > 3
SiteConfig(server): Hostname of server
SiteConfig(username): Username to use
SiteConfig(password): Password to use
SiteConfig(ssl/server): Hostname of server to try SSL auth against
SiteConfig(ssl/username): Username to use for SSL auth
SiteConfig(ssl/password): Password to use for SSL auth
SiteConfig(tls/server): Hostname of server to try TLS auth against
SiteConfig(tls/username): Username to use for TLS auth
SiteConfig(tls/password): Password to use for TLS auth
SiteConfig(/stable-servers/ldap/hostname): Location of stable LDAP server to use
        """, raise_errors=True)
        file = tempfile.NamedTemporaryFile(mode='w')
        ti1.output(file)
        file.flush()

        ti2 = parse_string(open(file.name).read().decode('utf8'))
        self.assertEquals(ti2.owner, u"Jane Doe <*****@*****.**>")
        self.assertEquals(ti2.test_name, u"/examples/coreutils/example-simple-test")
        self.assertEquals(ti2.test_path, u"/mnt/tests/examples/coreutils/example-simple-test")
        self.assertEquals(ti2.test_description, u"This test ensures that cafés are generated and validated correctly")
        self.assertEquals(ti2.avg_test_time, 60)
        self.assertEquals(ti2.testversion, u"1.1")
        self.assertEquals(ti2.license, u"GPL")
        self.assertEquals(ti2.destructive, True)
        self.assertEquals(ti2.runfor, [u"coreutils"])
        self.assertEquals(ti2.requires, [u"coreutils", u"python"])
        self.assertEquals(ti2.need_properties, [(u'CAKE', u'=', u'CHOCOLATE'), (u'SLICES', u'>', u'3')])
        self.assertEquals(ti2.siteconfig, [(u'/examples/coreutils/example-simple-test/server', u'Hostname of server'),
                                           (u'/examples/coreutils/example-simple-test/username', u'Username to use'),
                                           (u'/examples/coreutils/example-simple-test/password', u'Password to use'),
                                           (u'/examples/coreutils/example-simple-test/ssl/server', u'Hostname of server to try SSL auth against'),
                                           (u'/examples/coreutils/example-simple-test/ssl/username', u'Username to use for SSL auth'),
                                           (u'/examples/coreutils/example-simple-test/ssl/password', u'Password to use for SSL auth'),
                                           (u'/examples/coreutils/example-simple-test/tls/server', u'Hostname of server to try TLS auth against'),
                                           (u'/examples/coreutils/example-simple-test/tls/username', u'Username to use for TLS auth'),
                                           (u'/examples/coreutils/example-simple-test/tls/password', u'Password to use for TLS auth'),
                                           (u'/stable-servers/ldap/hostname', u'Location of stable LDAP server to use')])
Ejemplo n.º 2
0
 def test_nested_relative_siteconfig(self):
     "Ensure that a relative SiteConfig declaration containing a path works"
     ti = parse_string(u"""
     Name: /desktop/evolution/mail/imap/authentication
     SiteConfig(ssl/server): Hostname of server to try SSL auth against
     SiteConfig(ssl/username): Username to use for SSL auth
     SiteConfig(ssl/password): Password to use for SSL auth
     SiteConfig(tls/server): Hostname of server to try TLS auth against
     SiteConfig(tls/username): Username to use for TLS auth
     SiteConfig(tls/password): Password to use for TLS auth
     """,
                       raise_errors=False)
     self.assertEquals(
         ti.siteconfig,
         [(u'/desktop/evolution/mail/imap/authentication/ssl/server',
           u"Hostname of server to try SSL auth against"),
          (u'/desktop/evolution/mail/imap/authentication/ssl/username',
           u"Username to use for SSL auth"),
          (u'/desktop/evolution/mail/imap/authentication/ssl/password',
           u"Password to use for SSL auth"),
          (u'/desktop/evolution/mail/imap/authentication/tls/server',
           u"Hostname of server to try TLS auth against"),
          (u'/desktop/evolution/mail/imap/authentication/tls/username',
           u"Username to use for TLS auth"),
          (u'/desktop/evolution/mail/imap/authentication/tls/password',
           u"Password to use for TLS auth")])
Ejemplo n.º 3
0
    def test_example_file(self):
        "Ensure a full example file is parsed correctly"
        ti = parse_string(u"""\
# Test comment
Owner:        Jane Doe <*****@*****.**>
Name:         /examples/coreutils/example-simple-test
Path:         /mnt/tests/examples/coreutils/example-simple-test
Description:  This test ensures that cafés are generated and validated correctly
TestTime:     1m
TestVersion:  1.1
License:      GPL
RunFor:       coreutils
Requires:     coreutils python
        """,
                          raise_errors=True)
        self.assertEquals(ti.owner, u"Jane Doe <*****@*****.**>")
        self.assertEquals(ti.test_name,
                          u"/examples/coreutils/example-simple-test")
        self.assertEquals(
            ti.test_path, u"/mnt/tests/examples/coreutils/example-simple-test")
        self.assertEquals(
            ti.test_description,
            u"This test ensures that cafés are generated and validated correctly"
        )
        self.assertEquals(ti.avg_test_time, 60)
        self.assertEquals(ti.testversion, u"1.1")
        self.assertEquals(ti.license, u"GPL")
        self.assertEquals(ti.runfor, [u"coreutils"])
        self.assertEquals(ti.requires, [u"coreutils", u"python"])
Ejemplo n.º 4
0
 def test_multiline_type(self):
     "Ensure we can handle multiple Type lines"
     ti = parse_string(u"""Type: Crasher Regression
     Type: Performance Stress""",
                       raise_errors=False)
     self.assertEquals(
         ti.types, [u'Crasher', u'Regression', u'Performance', u'Stress'])
Ejemplo n.º 5
0
 def test_architectures_after_releases(self):
     "Ensure that an Architectures field following a Releases field is parsed correctly"
     ti = parse_string(u"""
     Releases: FC5 FC6
     Architectures: i386 x86_64""", raise_errors=False)
     self.assertEquals(ti.releases, [u'FC5', u'FC6'])
     self.assertEquals(ti.test_archs, [u"i386", u"x86_64"])
Ejemplo n.º 6
0
 def test_multiline_runfor(self):
     "Ensure we can handle multiple RunFor lines"
     ti = parse_string(u"""RunFor: evolution dogtail
     RunFor: foo bar""",
                       raise_errors=False)
     self.assertEquals(ti.runfor,
                       [u'evolution', u'dogtail', u'foo', u'bar'])
Ejemplo n.º 7
0
 def test_environment(self):
     "Ensure Environment field is parsed correctly"
     ti = parse_string(
         u"Environment: VAR1=VAL1\nEnvironment: VAR2=Value with spaces - 2",
         raise_errors=False)
     self.assertEquals(ti.environment["VAR1"], u"VAL1")
     self.assertEquals(ti.environment["VAR2"], u"Value with spaces - 2")
Ejemplo n.º 8
0
 def test_multiline_needproperty(self):
     "Ensure we can handle multiple NeedProperty lines"
     ti = parse_string(u"""
     NeedProperty: CAKE = CHOCOLATE
     NeedProperty: SLICES > 3
     """, raise_errors=False)
     self.assertEquals(ti.need_properties, [(u"CAKE", u"=", u"CHOCOLATE"), (u"SLICES", u">", u"3")])
Ejemplo n.º 9
0
 def test_multiline_requires(self):
     "Ensure we can handle multiple Requires lines"
     ti = parse_string(u"""Requires: evolution dogtail
     Requires: foo bar""",
                       raise_errors=False)
     self.assertEquals(ti.requires,
                       [u'evolution', u'dogtail', u'foo', u'bar'])
Ejemplo n.º 10
0
 def test_multi_options(self):
     "Ensure RhtsOptions field is parsed correctly"
     ti = parse_string(
         u"RhtsOptions: Compatible -CompatService -StrongerAVC",
         raise_errors=False)
     self.assertEquals(ti.options,
                       [u"Compatible", u"-CompatService", u"-StrongerAVC"])
Ejemplo n.º 11
0
 def test_description(self):
     "Ensure Description field is parsed correctly"
     ti = parse_string(
         u"Description: Ensure that the thingummy frobnicates the doohickey",
         raise_errors=False)
     self.assertEquals(
         ti.test_description,
         u"Ensure that the thingummy frobnicates the doohickey")
Ejemplo n.º 12
0
 def test_architectures_after_releases(self):
     "Ensure that an Architectures field following a Releases field is parsed correctly"
     ti = parse_string(u"""
     Releases: FC5 FC6
     Architectures: i386 x86_64""",
                       raise_errors=False)
     self.assertEquals(ti.releases, [u'FC5', u'FC6'])
     self.assertEquals(ti.test_archs, [u"i386", u"x86_64"])
Ejemplo n.º 13
0
 def test_absolute_siteconfig(self):
     "Ensure that an absolute SiteConfig declaration works"
     ti = parse_string(
         u"""SiteConfig(/stable-servers/ldap/hostname): Location of stable LDAP server to use""",
         raise_errors=False)
     self.assertEquals(ti.siteconfig,
                       [(u'/stable-servers/ldap/hostname',
                         u'Location of stable LDAP server to use')])
Ejemplo n.º 14
0
 def test_multiline_needproperty(self):
     "Ensure we can handle multiple NeedProperty lines"
     ti = parse_string(u"""
     NeedProperty: CAKE = CHOCOLATE
     NeedProperty: SLICES > 3
     """,
                       raise_errors=False)
     self.assertEquals(ti.need_properties, [(u"CAKE", u"=", u"CHOCOLATE"),
                                            (u"SLICES", u">", u"3")])
Ejemplo n.º 15
0
 def test_flat_relative_siteconfig(self):
     "Ensure that relative SiteConfig declarations without nesting work"
     ti = parse_string(u"""
     Name: /desktop/evolution/mail/imap/authentication/ssl
     SiteConfig(server): Hostname of server
     SiteConfig(username): Username to use
     SiteConfig(password): Password to use
     """, raise_errors=False)
     self.assertEquals(ti.siteconfig, [(u'/desktop/evolution/mail/imap/authentication/ssl/server', u"Hostname of server"),
                                       (u'/desktop/evolution/mail/imap/authentication/ssl/username', u"Username to use"),
                                       (u'/desktop/evolution/mail/imap/authentication/ssl/password', u"Password to use")
                                       ])
Ejemplo n.º 16
0
def populate(task):
    from bkr.server.tasks import Tasks
    controller = Tasks()
    filename = os.path.join(controller.task_dir, task.rpm)
    if not os.path.exists(filename):
        print 'Skipping missing %s' % filename
        return
    raw_taskinfo = controller.read_taskinfo(filename)
    tinfo = testinfo.parse_string(raw_taskinfo['desc'], raise_errors=False)
    if tinfo.owner:
        task.owner = tinfo.owner.decode('utf8')
    if tinfo.priority:
        task.priority = tinfo.priority.decode('utf8')
    task.destructive = tinfo.destructive
Ejemplo n.º 17
0
 def test_flat_relative_siteconfig(self):
     "Ensure that relative SiteConfig declarations without nesting work"
     ti = parse_string(u"""
     Name: /desktop/evolution/mail/imap/authentication/ssl
     SiteConfig(server): Hostname of server
     SiteConfig(username): Username to use
     SiteConfig(password): Password to use
     """,
                       raise_errors=False)
     self.assertEquals(
         ti.siteconfig,
         [(u'/desktop/evolution/mail/imap/authentication/ssl/server',
           u"Hostname of server"),
          (u'/desktop/evolution/mail/imap/authentication/ssl/username',
           u"Username to use"),
          (u'/desktop/evolution/mail/imap/authentication/ssl/password',
           u"Password to use")])
Ejemplo n.º 18
0
 def test_nested_relative_siteconfig(self):
     "Ensure that a relative SiteConfig declaration containing a path works"
     ti = parse_string(u"""
     Name: /desktop/evolution/mail/imap/authentication
     SiteConfig(ssl/server): Hostname of server to try SSL auth against
     SiteConfig(ssl/username): Username to use for SSL auth
     SiteConfig(ssl/password): Password to use for SSL auth
     SiteConfig(tls/server): Hostname of server to try TLS auth against
     SiteConfig(tls/username): Username to use for TLS auth
     SiteConfig(tls/password): Password to use for TLS auth
     """, raise_errors=False)
     self.assertEquals(ti.siteconfig, [(u'/desktop/evolution/mail/imap/authentication/ssl/server', u"Hostname of server to try SSL auth against"),
                                       (u'/desktop/evolution/mail/imap/authentication/ssl/username', u"Username to use for SSL auth"),
                                       (u'/desktop/evolution/mail/imap/authentication/ssl/password', u"Password to use for SSL auth"),
                                       (u'/desktop/evolution/mail/imap/authentication/tls/server', u"Hostname of server to try TLS auth against"),
                                       (u'/desktop/evolution/mail/imap/authentication/tls/username', u"Username to use for TLS auth"),
                                       (u'/desktop/evolution/mail/imap/authentication/tls/password', u"Password to use for TLS auth")
                                       ])
Ejemplo n.º 19
0
    def test_example_file(self):
        "Ensure a full example file is parsed correctly"
        ti = parse_string(u"""\
# Test comment
Owner:        Jane Doe <*****@*****.**>
Name:         /examples/coreutils/example-simple-test
Path:         /mnt/tests/examples/coreutils/example-simple-test
Description:  This test ensures that cafés are generated and validated correctly
TestTime:     1m
TestVersion:  1.1
License:      GPL
RunFor:       coreutils
Requires:     coreutils python
        """, raise_errors=True)
        self.assertEquals(ti.owner, u"Jane Doe <*****@*****.**>")
        self.assertEquals(ti.test_name, u"/examples/coreutils/example-simple-test")
        self.assertEquals(ti.test_path, u"/mnt/tests/examples/coreutils/example-simple-test")
        self.assertEquals(ti.test_description, u"This test ensures that cafés are generated and validated correctly")
        self.assertEquals(ti.avg_test_time, 60)
        self.assertEquals(ti.testversion, u"1.1")
        self.assertEquals(ti.license, u"GPL")
        self.assertEquals(ti.runfor, [u"coreutils"])
        self.assertEquals(ti.requires, [u"coreutils", u"python"])
Ejemplo n.º 20
0
 def test_siteconfig_whitespace(self):
     "Ensure that whitespace is stripped as expected from descriptions"
     ti = parse_string(u"SiteConfig(/foo/bar):        Some value    ", raise_errors=False)
     self.assertEquals(ti.siteconfig, [(u'/foo/bar', u"Some value")])
Ejemplo n.º 21
0
 def test_destructive(self):
     ti = parse_string(u"Destructive: yes", raise_errors=False)
     self.assertEquals(ti.destructive, True)
Ejemplo n.º 22
0
 def test_single_line_needproperty(self):
     "Ensure NeedProperty field is parsed correctly"
     ti = parse_string(u"NeedProperty: PROCESSORS > 1", raise_errors=False)
     self.assertEquals(ti.need_properties, [(u"PROCESSORS", u">", u"1")])
Ejemplo n.º 23
0
 def test_multiline_type(self):
     "Ensure we can handle multiple Type lines"
     ti = parse_string(u"""Type: Crasher Regression
     Type: Performance Stress""", raise_errors=False)
     self.assertEquals(ti.types, [u'Crasher', u'Regression', u'Performance', u'Stress'])
Ejemplo n.º 24
0
 def test_multiline_runfor(self):
     "Ensure we can handle multiple RunFor lines"
     ti = parse_string(u"""RunFor: evolution dogtail
     RunFor: foo bar""", raise_errors=False)
     self.assertEquals(ti.runfor, [u'evolution', u'dogtail', u'foo', u'bar'])
Ejemplo n.º 25
0
 def test_releases(self):
     "Ensure Releases field is parsed correctly"
     ti = parse_string(u"Releases: FC5 FC6", raise_errors=False)
     self.assertEquals(ti.releases, [u'FC5', u'FC6'])
Ejemplo n.º 26
0
 def test_architectures(self):
     "Ensure Architectures field is parsed correctly"
     ti = parse_string(u"Architectures: i386 x86_64", raise_errors=False)
     self.assertEquals(ti.test_archs, [u"i386", u"x86_64"])
Ejemplo n.º 27
0
 def test_releases(self):
     "Ensure Releases field is parsed correctly"
     ti = parse_string(u"Releases: FC5 FC6", raise_errors=False)
     self.assertEquals(ti.releases, [u'FC5', u'FC6'])
Ejemplo n.º 28
0
 def test_description_with_colon(self):
     "Ensure Description field containing a colon is parsed correctly"
     ti = parse_string(u"Description: This test is from http://foo/bar",
                       raise_errors=False)
     self.assertEquals(ti.test_description,
                       u"This test is from http://foo/bar")
Ejemplo n.º 29
0
 def test_destructive(self):
     ti = parse_string(u"Destructive: yes", raise_errors=False)
     self.assertEquals(ti.destructive, True)
Ejemplo n.º 30
0
    def test_output_testinfo(self):
        "Output an example file, then ensure it is parsed succesfully"
        ti1 = parse_string(u"""\
# Test comment
Owner:        Jane Doe <*****@*****.**>
Name:         /examples/coreutils/example-simple-test
Path:         /mnt/tests/examples/coreutils/example-simple-test
Description:  This test ensures that cafés are generated and validated correctly
TestTime:     1m
TestVersion:  1.1
License:      GPL
Destructive:  yes
RunFor:       coreutils
Requires:     coreutils python
NeedProperty: CAKE = CHOCOLATE
NeedProperty: SLICES > 3
SiteConfig(server): Hostname of server
SiteConfig(username): Username to use
SiteConfig(password): Password to use
SiteConfig(ssl/server): Hostname of server to try SSL auth against
SiteConfig(ssl/username): Username to use for SSL auth
SiteConfig(ssl/password): Password to use for SSL auth
SiteConfig(tls/server): Hostname of server to try TLS auth against
SiteConfig(tls/username): Username to use for TLS auth
SiteConfig(tls/password): Password to use for TLS auth
SiteConfig(/stable-servers/ldap/hostname): Location of stable LDAP server to use
        """,
                           raise_errors=True)
        file = tempfile.NamedTemporaryFile(mode='w')
        ti1.output(file)
        file.flush()

        ti2 = parse_string(open(file.name).read().decode('utf8'))
        self.assertEquals(ti2.owner, u"Jane Doe <*****@*****.**>")
        self.assertEquals(ti2.test_name,
                          u"/examples/coreutils/example-simple-test")
        self.assertEquals(
            ti2.test_path,
            u"/mnt/tests/examples/coreutils/example-simple-test")
        self.assertEquals(
            ti2.test_description,
            u"This test ensures that cafés are generated and validated correctly"
        )
        self.assertEquals(ti2.avg_test_time, 60)
        self.assertEquals(ti2.testversion, u"1.1")
        self.assertEquals(ti2.license, u"GPL")
        self.assertEquals(ti2.destructive, True)
        self.assertEquals(ti2.runfor, [u"coreutils"])
        self.assertEquals(ti2.requires, [u"coreutils", u"python"])
        self.assertEquals(ti2.need_properties, [(u'CAKE', u'=', u'CHOCOLATE'),
                                                (u'SLICES', u'>', u'3')])
        self.assertEquals(
            ti2.siteconfig,
            [(u'/examples/coreutils/example-simple-test/server',
              u'Hostname of server'),
             (u'/examples/coreutils/example-simple-test/username',
              u'Username to use'),
             (u'/examples/coreutils/example-simple-test/password',
              u'Password to use'),
             (u'/examples/coreutils/example-simple-test/ssl/server',
              u'Hostname of server to try SSL auth against'),
             (u'/examples/coreutils/example-simple-test/ssl/username',
              u'Username to use for SSL auth'),
             (u'/examples/coreutils/example-simple-test/ssl/password',
              u'Password to use for SSL auth'),
             (u'/examples/coreutils/example-simple-test/tls/server',
              u'Hostname of server to try TLS auth against'),
             (u'/examples/coreutils/example-simple-test/tls/username',
              u'Username to use for TLS auth'),
             (u'/examples/coreutils/example-simple-test/tls/password',
              u'Password to use for TLS auth'),
             (u'/stable-servers/ldap/hostname',
              u'Location of stable LDAP server to use')])
Ejemplo n.º 31
0
 def test_single_line_requires(self):
     "Ensure Requires field is parsed correctly"
     ti = parse_string(u"Requires: evolution dogtail", raise_errors=False)
     self.assertEquals(ti.requires, [u'evolution', u'dogtail'])
Ejemplo n.º 32
0
 def test_description(self):
     "Ensure Description field is parsed correctly"
     ti = parse_string(u"Description: Ensure that the thingummy frobnicates the doohickey", raise_errors=False)
     self.assertEquals(ti.test_description, u"Ensure that the thingummy frobnicates the doohickey")
Ejemplo n.º 33
0
 def test_single_line_needproperty(self):
     "Ensure NeedProperty field is parsed correctly"
     ti = parse_string(u"NeedProperty: PROCESSORS > 1", raise_errors=False)
     self.assertEquals(ti.need_properties, [(u"PROCESSORS", u">", u"1")])
Ejemplo n.º 34
0
 def test_siteconfig_whitespace(self):
     "Ensure that whitespace is stripped as expected from descriptions"
     ti = parse_string(u"SiteConfig(/foo/bar):        Some value    ",
                       raise_errors=False)
     self.assertEquals(ti.siteconfig, [(u'/foo/bar', u"Some value")])
Ejemplo n.º 35
0
 def test_rhtsoptions(self):
     "Ensure RhtsOptions field is parsed correctly"
     ti = parse_string(u"RhtsOptions: Compatible", raise_errors=False)
     self.assertEquals(ti.options, [u"Compatible"])
Ejemplo n.º 36
0
 def test_single_line_type(self):
     "Ensure Type field is parsed correctly"
     ti = parse_string(u"Type: Crasher Regression", raise_errors=False)
     self.assertEquals(ti.types, [u'Crasher', u'Regression'])
Ejemplo n.º 37
0
 def test_single_line_type(self):
     "Ensure Type field is parsed correctly"
     ti = parse_string(u"Type: Crasher Regression", raise_errors=False)
     self.assertEquals(ti.types, [u'Crasher', u'Regression'])
Ejemplo n.º 38
0
 def test_name(self):
     "Ensure Name field is parsed correctly"
     ti = parse_string(u"Name: /CoreOS/cups/foo/bar", raise_errors=False)
     self.assertEquals(ti.test_name, u"/CoreOS/cups/foo/bar")
Ejemplo n.º 39
0
 def test_multi_options(self):
     "Ensure RhtsOptions field is parsed correctly"
     ti = parse_string(u"RhtsOptions: Compatible -CompatService -StrongerAVC", raise_errors=False)
     self.assertEquals(ti.options, [u"Compatible", u"-CompatService", u"-StrongerAVC"])
Ejemplo n.º 40
0
 def test_requires_with_case_differences(self):
     "Ensure Requires field is parsed correctly"
     ti = parse_string(u"Requires: opencryptoki openCryptoki",
                       raise_errors=False)
     self.assertEquals(ti.requires, [u'opencryptoki', u'openCryptoki'])
Ejemplo n.º 41
0
 def test_environment(self):
     "Ensure Environment field is parsed correctly"
     ti = parse_string(u"Environment: VAR1=VAL1\nEnvironment: VAR2=Value with spaces - 2", raise_errors=False)
     self.assertEquals(ti.environment["VAR1"], u"VAL1")
     self.assertEquals(ti.environment["VAR2"], u"Value with spaces - 2")
Ejemplo n.º 42
0
 def test_name(self):
     "Ensure Name field is parsed correctly"
     ti = parse_string(u"Name: /CoreOS/cups/foo/bar", raise_errors=False)
     self.assertEquals(ti.test_name, u"/CoreOS/cups/foo/bar")
Ejemplo n.º 43
0
 def test_single_line_runfor(self):
     "Ensure RunFor field is parsed correctly"
     ti = parse_string(u"RunFor: evolution dogtail", raise_errors=False)
     self.assertEquals(ti.runfor, [u'evolution', u'dogtail'])
Ejemplo n.º 44
0
 def test_absolute_siteconfig(self):
     "Ensure that an absolute SiteConfig declaration works"
     ti = parse_string(u"""SiteConfig(/stable-servers/ldap/hostname): Location of stable LDAP server to use""", raise_errors=False)
     self.assertEquals(ti.siteconfig, [(u'/stable-servers/ldap/hostname', u'Location of stable LDAP server to use')])
Ejemplo n.º 45
0
 def test_testtime_hours(self):
     "Ensure TestTime field can handle hours"
     ti = parse_string(u"TestTime: 2h", raise_errors=False)
     self.assertEquals(ti.avg_test_time, (2*60*60))
Ejemplo n.º 46
0
 def test_single_line_requires(self):
     "Ensure Requires field is parsed correctly"
     ti = parse_string(u"Requires: evolution dogtail", raise_errors=False)
     self.assertEquals(ti.requires, [u'evolution', u'dogtail'])
Ejemplo n.º 47
0
 def test_multiline_requires(self):
     "Ensure we can handle multiple Requires lines"
     ti = parse_string(u"""Requires: evolution dogtail
     Requires: foo bar""", raise_errors=False)
     self.assertEquals(ti.requires, [u'evolution', u'dogtail', u'foo', u'bar'])
Ejemplo n.º 48
0
 def test_path_relative(self):
     "Ensure relative Path field is parsed correctly"
     ti = parse_string(u"Path: CoreOS/cups/foo/bar", raise_errors=False)
     self.assertEquals(ti.test_path, u"/mnt/tests/CoreOS/cups/foo/bar")
Ejemplo n.º 49
0
 def test_requires_with_case_differences(self):
     "Ensure Requires field is parsed correctly"
     ti = parse_string(u"Requires: opencryptoki openCryptoki", raise_errors=False)
     self.assertEquals(ti.requires, [u'opencryptoki', u'openCryptoki'])
Ejemplo n.º 50
0
 def test_description_with_colon(self):
     "Ensure Description field containing a colon is parsed correctly"
     ti = parse_string(u"Description: This test is from http://foo/bar", raise_errors=False)
     self.assertEquals(ti.test_description, u"This test is from http://foo/bar")
Ejemplo n.º 51
0
 def test_single_line_runfor(self):
     "Ensure RunFor field is parsed correctly"
     ti = parse_string(u"RunFor: evolution dogtail", raise_errors=False)
     self.assertEquals(ti.runfor, [u'evolution', u'dogtail'])
Ejemplo n.º 52
0
 def test_architectures(self):
     "Ensure Architectures field is parsed correctly"
     ti = parse_string(u"Architectures: i386 x86_64", raise_errors=False)
     self.assertEquals(ti.test_archs, [u"i386", u"x86_64"])
Ejemplo n.º 53
0
 def test_path_relative(self):
     "Ensure relative Path field is parsed correctly"
     ti = parse_string(u"Path: CoreOS/cups/foo/bar", raise_errors=False)
     self.assertEquals(ti.test_path, u"/mnt/tests/CoreOS/cups/foo/bar")
Ejemplo n.º 54
0
 def test_rhtsoptions(self):
     "Ensure RhtsOptions field is parsed correctly"
     ti = parse_string(u"RhtsOptions: Compatible", raise_errors=False)
     self.assertEquals(ti.options, [u"Compatible"])
Ejemplo n.º 55
0
 def test_rhtsoptions_minus(self):
     "Ensure RhtsOptions field parses options preceded with dash correctly"
     ti = parse_string(u"RhtsOptions: -Compatible", raise_errors=False)
     self.assertEquals(ti.options, [u"-Compatible"])
Ejemplo n.º 56
0
 def test_rhtsoptions_minus(self):
     "Ensure RhtsOptions field parses options preceded with dash correctly"
     ti = parse_string(u"RhtsOptions: -Compatible", raise_errors=False)
     self.assertEquals(ti.options, [u"-Compatible"])
Ejemplo n.º 57
0
    def create_from_taskinfo(cls, raw_taskinfo):
        """Create a new task object based on details retrieved from an RPM"""

        tinfo = testinfo.parse_string(raw_taskinfo['desc'].decode('utf8'))

        if len(tinfo.test_name) > 255:
            raise BX(_("Task name should be <= 255 characters"))
        if tinfo.test_name.endswith('/'):
            raise BX(_(u'Task name must not end with slash'))
        if '//' in tinfo.test_name: # pylint:disable=unsupported-membership-test
            raise BX(_(u'Task name must not contain redundant slashes'))

        existing_task = Task.query.filter(Task.name == tinfo.test_name).first()
        if existing_task is not None:
            task = existing_task
            # RPM is the same version we have. don't process
            if existing_task.version == raw_taskinfo['hdr']['ver']:
                raise BX(_("Failed to import,  %s is the same version we already have" % task.version))
            # if the task is already present, check if a downgrade has been requested
            downgrade = cls.check_downgrade(task.version, raw_taskinfo['hdr']['ver'])
        else:
            task = Task(name=tinfo.test_name)
            downgrade = False

        task.version = raw_taskinfo['hdr']['ver']
        task.description = tinfo.test_description
        task.types = []
        task.bugzillas = []
        task.required = []
        task.runfor = []
        task.needs = []
        task.excluded_osmajors = []
        task.exclusive_osmajors = []
        task.excluded_arches = []
        task.exclusive_arches = []
        for family in tinfo.releases:
            if family.startswith('-'):
                try:
                    osmajor = OSMajor.by_name_alias(family.lstrip('-'))
                    if osmajor not in task.excluded_osmajors:
                        task.excluded_osmajors.append(osmajor)
                except NoResultFound:
                    pass
            else:
                try:
                    osmajor = OSMajor.by_name_alias(family)
                    if osmajor not in task.exclusive_osmajors:
                        task.exclusive_osmajors.append(osmajor)
                except NoResultFound:
                    pass
        for value in tinfo.test_archs:
            if value.startswith('-'):
                try:
                    arch = Arch.by_name(value.lstrip('-'))
                except ValueError:
                    pass
                else:
                    if arch not in task.excluded_arches:
                        task.excluded_arches.append(arch)
            else:
                try:
                    arch = Arch.by_name(value)
                except ValueError:
                    pass
                else:
                    if arch not in task.exclusive_arches:
                        task.exclusive_arches.append(arch)
        task.avg_time = tinfo.avg_test_time
        for type in tinfo.types:
            ttype = TaskType.lazy_create(type=type)
            task.types.append(ttype)
        for bug in tinfo.bugs:
            task.bugzillas.append(TaskBugzilla(bugzilla_id=bug))
        task.path = tinfo.test_path
        # Bug 772882. Remove duplicate required package here
        # Avoid ORM insert in task_packages_required_map twice.
        tinfo.runfor = list(set(tinfo.runfor))
        for runfor in tinfo.runfor:
            package = TaskPackage.lazy_create(package=runfor)
            task.runfor.append(package)
        task.priority = tinfo.priority
        task.destructive = tinfo.destructive
        # Bug 772882. Remove duplicate required package here
        # Avoid ORM insert in task_packages_required_map twice.
        tinfo.requires = list(set(tinfo.requires))
        for require in tinfo.requires:
            package = TaskPackage.lazy_create(package=require)
            task.required.append(package)
        for need in tinfo.needs:
            task.needs.append(TaskPropertyNeeded(property=need))
        task.license = tinfo.license
        task.owner = tinfo.owner

        try:
            task.uploader = identity.current.user
        except identity.RequestRequiredException:
            task.uploader = User.query.get(1)

        task.valid = True

        return task, downgrade
Ejemplo n.º 58
0
    def create_from_taskinfo(cls, raw_taskinfo):
        """Create a new task object based on details retrieved from an RPM"""

        tinfo = testinfo.parse_string(raw_taskinfo['desc'].decode('utf8'))

        if len(tinfo.test_name) > 255:
            raise BX(_("Task name should be <= 255 characters"))
        if tinfo.test_name.endswith('/'):
            raise BX(_(u'Task name must not end with slash'))
        if '//' in tinfo.test_name:
            raise BX(_(u'Task name must not contain redundant slashes'))

        task = cls.lazy_create(name=tinfo.test_name)

        # RPM is the same version we have. don't process
        if task.version == raw_taskinfo['hdr']['ver']:
            raise BX(
                _("Failed to import,  %s is the same version we already have" %
                  task.version))

        # if the task is already present, check if a downgrade has been requested
        if task.version:
            downgrade = cls.check_downgrade(task.version,
                                            raw_taskinfo['hdr']['ver'])
        else:
            downgrade = False

        task.version = raw_taskinfo['hdr']['ver']
        task.description = tinfo.test_description
        task.types = []
        task.bugzillas = []
        task.required = []
        task.runfor = []
        task.needs = []
        task.excluded_osmajor = []
        task.excluded_arch = []
        includeFamily = []
        for family in tinfo.releases:
            if family.startswith('-'):
                try:
                    if family.lstrip('-') not in task.excluded_osmajor:
                        task.excluded_osmajor.append(
                            TaskExcludeOSMajor(osmajor=OSMajor.by_name_alias(
                                family.lstrip('-'))))
                except InvalidRequestError:
                    pass
            else:
                try:
                    includeFamily.append(OSMajor.by_name_alias(family).osmajor)
                except InvalidRequestError:
                    pass
        families = set(['%s' % family.osmajor for family in OSMajor.query])
        if includeFamily:
            for family in families.difference(set(includeFamily)):
                if family not in task.excluded_osmajor:
                    task.excluded_osmajor.append(
                        TaskExcludeOSMajor(
                            osmajor=OSMajor.by_name_alias(family)))
        if tinfo.test_archs:
            arches = set(['%s' % arch.arch for arch in Arch.query])
            for arch in arches.difference(set(tinfo.test_archs)):
                if arch not in task.excluded_arch:
                    task.excluded_arch.append(
                        TaskExcludeArch(arch=Arch.by_name(arch)))
        task.avg_time = tinfo.avg_test_time
        for type in tinfo.types:
            ttype = TaskType.lazy_create(type=type)
            task.types.append(ttype)
        for bug in tinfo.bugs:
            task.bugzillas.append(TaskBugzilla(bugzilla_id=bug))
        task.path = tinfo.test_path
        # Bug 772882. Remove duplicate required package here
        # Avoid ORM insert in task_packages_required_map twice.
        tinfo.runfor = list(set(tinfo.runfor))
        for runfor in tinfo.runfor:
            package = TaskPackage.lazy_create(package=runfor)
            task.runfor.append(package)
        task.priority = tinfo.priority
        task.destructive = tinfo.destructive
        # Bug 772882. Remove duplicate required package here
        # Avoid ORM insert in task_packages_required_map twice.
        tinfo.requires = list(set(tinfo.requires))
        for require in tinfo.requires:
            package = TaskPackage.lazy_create(package=require)
            task.required.append(package)
        for need in tinfo.needs:
            task.needs.append(TaskPropertyNeeded(property=need))
        task.license = tinfo.license
        task.owner = tinfo.owner

        try:
            task.uploader = identity.current.user
        except identity.RequestRequiredException:
            task.uploader = User.query.get(1)

        task.valid = True

        return task, downgrade
Ejemplo n.º 59
0
 def test_testtime_minutes(self):
     "Ensure TestTime field can handle minutes"
     ti = parse_string(u"TestTime: 10m", raise_errors=False)
     self.assertEquals(ti.avg_test_time, 600)