First pass at tool to list gerrits included in a karaf distribution
[integration/test.git] / tools / distchanges / tests / test_changes_old.py.old
1 #!/usr/bin/env python
2
3 import unittest
4 from distchanges.cmd import Changes
5
6 CHANGE_ID = 'Ic96517f4a57fe547d42495274a74ec5aa32b7d9e'
7 REMOTE_URL = 'ssh://git.opendaylight.org:29418'
8 PROJECT = 'netvirt'
9 PROJECT_NAMES = ['genius', 'mdsal', 'netvirt', 'neutron', 'openflowjava', 'openflowplugin', 'ovsdb', 'yangtools']
10 BRANCH = 'master'
11 LIMIT = 5
12 QLIMIT = 50
13 DISTRO_PATH = "/home/shague/data/images/official/distribution-karaf-0.6.0-20170109.201555-2968/distribution-karaf-0.6.0-SNAPSHOT"
14 PROPERTIES_FILE = "/home/shague/data/images/official/distribution-karaf-0.6.0-20170109.201555-2968/distribution-karaf-0.6.0-SNAPSHOT/system/org/opendaylight/netvirt/aclservice-api/0.4.0-SNAPSHOT/aclservice-api-0.4.0-SNAPSHOT.jar"
15
16
17 class TestChangesOld(unittest.TestCase):
18     @classmethod
19     def setUpClass(cls):
20         cls.json = {}
21         for project in 'netvirt', 'genius':
22             json = []
23             for line in open('changes.' + project + '.10.json.txt'):
24                 if line.find('stats') == -1:
25                     json.append(line)
26             cls.json[project] = json
27
28     def setUp(self):
29         print("Starting test: %s" % self.id())
30
31     def test_get_sub_time(self):
32         self.assertEquals(1483974872, changes.get_subm_time(self.json['netvirt'][0]))
33
34     def test_get_sub_time_10(self):
35         for line in self.json['netvirt']:
36             self.assertNotEquals(0, changes.get_subm_time(line))
37
38     def test_get_sub_time_fail(self):
39         self.assertEquals(0, changes.get_subm_time('this is a bad json file'))
40
41     def test_get_gerrit(self):
42         gerrits = changes.get_gerrits(REMOTE_URL, 'netvirt', 'master', CHANGE_ID, 1)
43         for gerrit in gerrits:
44             print("gerrit: %s" % str(gerrit))
45
46     def test_get_gerrits(self):
47         for project in PROJECT_NAMES:
48             gerrits = changes.get_gerrits(REMOTE_URL, project, 'master', limit=10)
49             for gerrit in gerrits:
50                 print("gerrit: %s %s" % (project, str(gerrit)))
51
52     def test_get_gitproperties_file(self):
53         pfile = changes.extract_gitproperties_file(PROPERTIES_FILE)
54         self.assertNotEqual(None, pfile)
55
56     def test_get_changeid_from_properties(self):
57         pfile = changes.extract_gitproperties_file(PROPERTIES_FILE)
58         self.assertNotEqual(None, pfile)
59         self.assertNotEqual(None, changes.get_changeid_from_properties(pfile))
60
61     def test_get_build_changeid(self):
62         self.assertNotEqual(None, changes.find_distro_changeid(DISTRO_PATH, 'netvirt'))
63
64     def test_run_cmd_master(self):
65         # project_names = PROJECT_NAMES
66         project_names = ['openflowplugin']
67         # project_names = ['netvirt']
68         changes = Changes(BRANCH, DISTRO_PATH, LIMIT, QLIMIT, project_names, REMOTE_URL)
69         projects = changes.run_cmd()
70         changes.pretty_print_projects(projects)
71
72 if __name__ == '__main__':
73     unittest.main()