[TIC-CORE] provides default-recipe for 1st-release
[archive/20170607/tools/tic-core.git] / test / test_repodata.py
1 #!/usr/bin/python
2 # Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
3 #
4 # Contact: 
5 # @author Chulwoo Shin <cw1.shin@samsung.com>
6
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19 # Contributors:
20 # - S-Core Co., Ltd
21
22 import os
23 import unittest
24 from tic.repo import get_repodata_from_repos
25
26 CWD = os.path.dirname(__file__) or '.'
27 TEST_REPODATA_LOC=os.path.join(CWD, 'dependency_fixtures')
28 DEFAULT_CACHEDIR='/var/tmp/tic-core/cached'
29
30 def suite():
31     return unittest.makeSuite(RepodataTest)
32
33 class RepodataTest(unittest.TestCase):
34     def setUp(self):
35         # test environment setup
36         self.local_repo = [{'name': 'local_base',
37                             'url': 'file:/' + TEST_REPODATA_LOC + '/base'},
38                            {'name': 'local_mobile',
39                             'url': 'file:/' + TEST_REPODATA_LOC + '/mobile'}]
40         
41         self.remote_repo = [{'name': 'local_base',
42                             'url': 'http://download.tizen.org/snapshots/tizen/base/latest/repos/arm64/packages'},
43                             {'name': 'local_mobile',
44                              'url': 'http://download.tizen.org/snapshots/tizen/mobile/latest/repos/arm64-wayland/packages'}]
45
46     def tearDown(self):
47         # clear environment after test 
48         del self.local_repo
49         del self.remote_repo
50
51     def test_local_repodata(self):
52         repodata_list = get_repodata_from_repos(self.local_repo, DEFAULT_CACHEDIR)
53         
54         for repo_info in repodata_list: 
55             self.assertNotEqual(repo_info, None)
56             self.assertNotEqual(repo_info.get('repomd'), None)
57             self.assertNotEqual(repo_info.get('primary'), None)
58             if not os.path.exists(repo_info.get('repomd')):
59                 raise self.failureException
60             if not os.path.exists(repo_info.get('primary')):
61                 raise self.failureException
62     
63     def test_remote_repodata(self):
64         repodata_list = get_repodata_from_repos(self.remote_repo, DEFAULT_CACHEDIR)
65         
66         for repo_info in repodata_list: 
67             self.assertNotEqual(repo_info, None)
68             self.assertNotEqual(repo_info.get('repomd'), None)
69             self.assertNotEqual(repo_info.get('primary'), None)
70             if not os.path.exists(repo_info.get('repomd')):
71                 raise self.failureException
72             if not os.path.exists(repo_info.get('primary')):
73                 raise self.failureException
74     
75 if __name__ == "__main__":
76     #import sys;sys.argv = ['', 'Test.testName']
77     unittest.main()