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