2 # Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
5 # @author Chulwoo Shin <cw1.shin@samsung.com>
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
26 from tic.repo import Repo
27 from tic.repo import get_repodata_from_repos
29 CWD = os.path.dirname(__file__) or '.'
30 TEST_REPODATA_LOC=os.path.join(CWD, 'dependency_fixtures')
31 DEFAULT_CACHEDIR='/var/tmp/tic-core/cached'
34 return unittest.makeSuite(RepodataTest)
36 class RepodataTest(unittest.TestCase):
38 # test environment setup
39 self.local_repo = ['file:/' + TEST_REPODATA_LOC + '/base',
40 'file:/' + TEST_REPODATA_LOC + '/mobile']
42 self.remote_repo = ['http://download.tizen.org/snapshots/tizen/base/latest/repos/arm64/packages',
43 'http://download.tizen.org/snapshots/tizen/mobile/latest/repos/arm64-wayland/packages']
46 # clear environment after test
50 def test_local_repodata(self):
52 for repo_url in self.local_repo:
53 repos.append(Repo(base64.urlsafe_b64encode(repo_url), repo_url))
54 repodata_list = get_repodata_from_repos(repos, DEFAULT_CACHEDIR)
56 for repo_info in repodata_list:
57 self.assertNotEqual(repo_info, None)
58 self.assertNotEqual(repo_info.get('repomd'), None)
59 self.assertNotEqual(repo_info.get('primary'), None)
60 if not os.path.exists(repo_info.get('repomd')):
61 raise self.failureException
62 if not os.path.exists(repo_info.get('primary')):
63 raise self.failureException
65 def test_remote_repodata(self):
67 for repo_url in self.remote_repo:
68 repos.append(Repo(base64.urlsafe_b64encode(repo_url), repo_url))
69 repodata_list = get_repodata_from_repos(repos, DEFAULT_CACHEDIR)
71 for repo_info in repodata_list:
72 self.assertNotEqual(repo_info, None)
73 self.assertNotEqual(repo_info.get('repomd'), None)
74 self.assertNotEqual(repo_info.get('primary'), None)
75 if not os.path.exists(repo_info.get('repomd')):
76 raise self.failureException
77 if not os.path.exists(repo_info.get('primary')):
78 raise self.failureException
80 if __name__ == "__main__":
81 #import sys;sys.argv = ['', 'Test.testName']