author | Richard Taylor <richard.i.taylor@nokia.com> |
Tue, 04 May 2010 12:08:55 +0100 | |
branch | wip |
changeset 507 | 54a88b895bcd |
parent 504 | ea75c3a64a17 |
permissions | -rw-r--r-- |
498 | 1 |
# |
2 |
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
# All rights reserved. |
|
4 |
# This component and the accompanying materials are made available |
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
|
6 |
# which accompanies this distribution, and is available |
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
# |
|
9 |
# Initial Contributors: |
|
10 |
# Nokia Corporation - initial contribution. |
|
11 |
# |
|
12 |
# Contributors: |
|
13 |
# |
|
14 |
# Description: |
|
15 |
# raptor_api_unit module |
|
16 |
||
17 |
import generic_path |
|
18 |
import raptor |
|
19 |
import raptor_api |
|
20 |
import unittest |
|
21 |
||
22 |
class TestRaptorApi(unittest.TestCase): |
|
23 |
||
24 |
def testContext(self): |
|
25 |
api = raptor_api.Context() |
|
26 |
||
27 |
def testContextInitialiser(self): |
|
28 |
r = raptor.Raptor() |
|
29 |
api = raptor_api.Context(r) |
|
30 |
||
31 |
def testAliases(self): |
|
32 |
r = raptor.Raptor() |
|
33 |
r.cache.Load( generic_path.Join(r.home, "test", "config", "api.xml") ) |
|
34 |
||
35 |
api = raptor_api.Context(r) |
|
36 |
||
504
ea75c3a64a17
change to lowercase method names
Richard Taylor <richard.i.taylor@nokia.com>
parents:
500
diff
changeset
|
37 |
aliases = api.getaliases() # type == "" |
498 | 38 |
self.failUnlessEqual(len(aliases), 4) |
39 |
self.failUnlessEqual(set(["alias_A","alias_B","s1","s2"]), |
|
40 |
set(a.name for a in aliases)) |
|
41 |
||
507
54a88b895bcd
apply review comments
Richard Taylor <richard.i.taylor@nokia.com>
parents:
504
diff
changeset
|
42 |
aliases = api.getaliases(raptor_api.ALL) # ignore type |
498 | 43 |
self.failUnlessEqual(len(aliases), 6) |
44 |
||
504
ea75c3a64a17
change to lowercase method names
Richard Taylor <richard.i.taylor@nokia.com>
parents:
500
diff
changeset
|
45 |
aliases = api.getaliases("X") # type == "X" |
498 | 46 |
self.failUnlessEqual(len(aliases), 1) |
47 |
self.failUnlessEqual(aliases[0].name, "alias_D") |
|
48 |
self.failUnlessEqual(aliases[0].meaning, "a.b.c.d") |
|
49 |
||
50 |
def testConfig(self): |
|
51 |
r = raptor.Raptor() |
|
52 |
r.cache.Load( generic_path.Join(r.home, "test", "config", "api.xml") ) |
|
53 |
||
54 |
api = raptor_api.Context(r) |
|
55 |
||
500
69637e02a1ce
forgot windows drive letter in test
Richard Taylor <richard.i.taylor@nokia.com>
parents:
498
diff
changeset
|
56 |
if r.filesystem == "unix": |
69637e02a1ce
forgot windows drive letter in test
Richard Taylor <richard.i.taylor@nokia.com>
parents:
498
diff
changeset
|
57 |
path = "/home/raptor/foo/bar" |
69637e02a1ce
forgot windows drive letter in test
Richard Taylor <richard.i.taylor@nokia.com>
parents:
498
diff
changeset
|
58 |
else: |
69637e02a1ce
forgot windows drive letter in test
Richard Taylor <richard.i.taylor@nokia.com>
parents:
498
diff
changeset
|
59 |
path = "C:/home/raptor/foo/bar" |
69637e02a1ce
forgot windows drive letter in test
Richard Taylor <richard.i.taylor@nokia.com>
parents:
498
diff
changeset
|
60 |
|
504
ea75c3a64a17
change to lowercase method names
Richard Taylor <richard.i.taylor@nokia.com>
parents:
500
diff
changeset
|
61 |
config = api.getconfig("buildme") |
498 | 62 |
self.failUnlessEqual(config.fullname, "buildme") |
500
69637e02a1ce
forgot windows drive letter in test
Richard Taylor <richard.i.taylor@nokia.com>
parents:
498
diff
changeset
|
63 |
self.failUnlessEqual(config.outputpath, path) |
498 | 64 |
|
504
ea75c3a64a17
change to lowercase method names
Richard Taylor <richard.i.taylor@nokia.com>
parents:
500
diff
changeset
|
65 |
config = api.getconfig("buildme.foo") |
498 | 66 |
self.failUnlessEqual(config.fullname, "buildme.foo") |
500
69637e02a1ce
forgot windows drive letter in test
Richard Taylor <richard.i.taylor@nokia.com>
parents:
498
diff
changeset
|
67 |
self.failUnlessEqual(config.outputpath, path) |
498 | 68 |
|
504
ea75c3a64a17
change to lowercase method names
Richard Taylor <richard.i.taylor@nokia.com>
parents:
500
diff
changeset
|
69 |
config = api.getconfig("s1") |
498 | 70 |
self.failUnlessEqual(config.fullname, "buildme.foo") |
500
69637e02a1ce
forgot windows drive letter in test
Richard Taylor <richard.i.taylor@nokia.com>
parents:
498
diff
changeset
|
71 |
self.failUnlessEqual(config.outputpath, path) |
498 | 72 |
|
504
ea75c3a64a17
change to lowercase method names
Richard Taylor <richard.i.taylor@nokia.com>
parents:
500
diff
changeset
|
73 |
config = api.getconfig("s2.product_A") |
498 | 74 |
self.failUnlessEqual(config.fullname, "buildme.foo.bar.product_A") |
500
69637e02a1ce
forgot windows drive letter in test
Richard Taylor <richard.i.taylor@nokia.com>
parents:
498
diff
changeset
|
75 |
self.failUnlessEqual(config.outputpath, path) |
498 | 76 |
|
77 |
def testProducts(self): |
|
78 |
r = raptor.Raptor() |
|
79 |
r.cache.Load( generic_path.Join(r.home, "test", "config", "api.xml") ) |
|
80 |
||
81 |
api = raptor_api.Context(r) |
|
82 |
||
504
ea75c3a64a17
change to lowercase method names
Richard Taylor <richard.i.taylor@nokia.com>
parents:
500
diff
changeset
|
83 |
products = api.getproducts() # type == "product" |
498 | 84 |
self.failUnlessEqual(len(products), 2) |
85 |
self.failUnlessEqual(set(["product_A","product_C"]), |
|
86 |
set(p.name for p in products)) |
|
87 |
||
88 |
# run all the tests |
|
89 |
||
90 |
from raptor_tests import SmokeTest |
|
91 |
||
92 |
def run(): |
|
93 |
t = SmokeTest() |
|
94 |
t.name = "raptor_api_unit" |
|
95 |
||
96 |
tests = unittest.makeSuite(TestRaptorApi) |
|
97 |
result = unittest.TextTestRunner(verbosity=2).run(tests) |
|
98 |
||
99 |
if result.wasSuccessful(): |
|
100 |
t.result = SmokeTest.PASS |
|
101 |
else: |
|
102 |
t.result = SmokeTest.FAIL |
|
103 |
||
104 |
return t |