Beispiel #1
0
    def test_output_testinfo(self):
        "Output an example file, then ensure it is parsed succesfully"
        ti1 = parse_string("""\
# Test comment
Owner:        Jane Doe <*****@*****.**>
Name:         /examples/coreutils/example-simple-test
Path:         /mnt/tests/examples/coreutils/example-simple-test
Description:  This test ensures that md5sums 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()

        p = StrictParser(raise_errors=True)
        p.parse(open(file.name, "r").readlines())
        ti2= p.info
        self.assertEquals(ti2.owner, "Jane Doe <*****@*****.**>")
        self.assertEquals(ti2.test_name, "/examples/coreutils/example-simple-test")
        self.assertEquals(ti2.test_path, "/mnt/tests/examples/coreutils/example-simple-test")
        self.assertEquals(ti2.test_description, "This test ensures that md5sums are generated and validated correctly")
        self.assertEquals(ti2.avg_test_time, 60)
        self.assertEquals(ti2.testversion, "1.1")
        self.assertEquals(ti2.license, "GPL")
        self.assertEquals(ti2.destructive, True)
        self.assertEquals(ti2.runfor, ["coreutils"])
        self.assertEquals(ti2.requires, ["coreutils", "python"])
        self.assertEquals(ti2.need_properties, [('CAKE', '=', 'CHOCOLATE'), ('SLICES', '>', '3')])
        self.assertEquals(ti2.siteconfig, [('/examples/coreutils/example-simple-test/server', 'Hostname of server'),
                                           ('/examples/coreutils/example-simple-test/username', 'Username to use'),
                                           ('/examples/coreutils/example-simple-test/password', 'Password to use'),
                                           ('/examples/coreutils/example-simple-test/ssl/server', 'Hostname of server to try SSL auth against'),
                                           ('/examples/coreutils/example-simple-test/ssl/username', 'Username to use for SSL auth'),
                                           ('/examples/coreutils/example-simple-test/ssl/password', 'Password to use for SSL auth'),
                                           ('/examples/coreutils/example-simple-test/tls/server', 'Hostname of server to try TLS auth against'),
                                           ('/examples/coreutils/example-simple-test/tls/username', 'Username to use for TLS auth'),
                                           ('/examples/coreutils/example-simple-test/tls/password', 'Password to use for TLS auth'),
                                           ('/stable-servers/ldap/hostname', 'Location of stable LDAP server to use')])
Beispiel #2
0
 def test_non_ascii_owner(self):
     parser = StrictParser(raise_errors=True)
     parser.handle_owner('Owner', u'Gęśla Jaźń <*****@*****.**>')
     self.assertEquals(parser.info.owner, u'Gęśla Jaźń <*****@*****.**>')
Beispiel #3
0
 def test_owner_with_hyphen(self):
     parser = StrictParser(raise_errors=True)
     parser.handle_owner('Owner', u'Endre Balint-Nagy <*****@*****.**>')
     self.assertEquals(parser.info.owner, u'Endre Balint-Nagy <*****@*****.**>')
Beispiel #4
0
 def test_non_ascii_owner(self):
     parser = StrictParser(raise_errors=True)
     parser.handle_owner('Owner', u'Gęśla Jaźń <*****@*****.**>')
     self.assertEquals(parser.info.owner, u'Gęśla Jaźń <*****@*****.**>')
Beispiel #5
0
 def test_owner_with_hyphen(self):
     parser = StrictParser(raise_errors=True)
     parser.handle_owner('Owner', u'Endre Balint-Nagy <*****@*****.**>')
     self.assertEquals(parser.info.owner,
                       u'Endre Balint-Nagy <*****@*****.**>')
Beispiel #6
0
    def test_output_testinfo(self):
        "Output an example file, then ensure it is parsed succesfully"
        ti1 = parse_string("""\
# Test comment
Owner:        Jane Doe <*****@*****.**>
Name:         /examples/coreutils/example-simple-test
Path:         /mnt/tests/examples/coreutils/example-simple-test
Description:  This test ensures that md5sums 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()

        p = StrictParser(raise_errors=True)
        p.parse(open(file.name, "r").readlines())
        ti2 = p.info
        self.assertEquals(ti2.owner, "Jane Doe <*****@*****.**>")
        self.assertEquals(ti2.test_name,
                          "/examples/coreutils/example-simple-test")
        self.assertEquals(ti2.test_path,
                          "/mnt/tests/examples/coreutils/example-simple-test")
        self.assertEquals(
            ti2.test_description,
            "This test ensures that md5sums are generated and validated correctly"
        )
        self.assertEquals(ti2.avg_test_time, 60)
        self.assertEquals(ti2.testversion, "1.1")
        self.assertEquals(ti2.license, "GPL")
        self.assertEquals(ti2.destructive, True)
        self.assertEquals(ti2.runfor, ["coreutils"])
        self.assertEquals(ti2.requires, ["coreutils", "python"])
        self.assertEquals(ti2.need_properties, [('CAKE', '=', 'CHOCOLATE'),
                                                ('SLICES', '>', '3')])
        self.assertEquals(
            ti2.siteconfig,
            [('/examples/coreutils/example-simple-test/server',
              'Hostname of server'),
             ('/examples/coreutils/example-simple-test/username',
              'Username to use'),
             ('/examples/coreutils/example-simple-test/password',
              'Password to use'),
             ('/examples/coreutils/example-simple-test/ssl/server',
              'Hostname of server to try SSL auth against'),
             ('/examples/coreutils/example-simple-test/ssl/username',
              'Username to use for SSL auth'),
             ('/examples/coreutils/example-simple-test/ssl/password',
              'Password to use for SSL auth'),
             ('/examples/coreutils/example-simple-test/tls/server',
              'Hostname of server to try TLS auth against'),
             ('/examples/coreutils/example-simple-test/tls/username',
              'Username to use for TLS auth'),
             ('/examples/coreutils/example-simple-test/tls/password',
              'Password to use for TLS auth'),
             ('/stable-servers/ldap/hostname',
              'Location of stable LDAP server to use')])