Adding comparison script to list patches added to one distro compared to another
[integration/test.git] / tools / distchanges / tests / test_changes.py
1 #!/usr/bin/env python
2
3 import unittest
4 import distcompare
5 from changes import Changes
6
7 REMOTE_URL = 'ssh://git.opendaylight.org:29418'
8 NETVIRT_PROJECTS = ["netvirt", "controller", "dlux", "dluxapps", "genius", "infrautils", "mdsal", "netconf",
9                     "neutron", "odlparent", "openflowplugin", "ovsdb", "sfc", "yangtools"]
10 PROJECT_NAMES = NETVIRT_PROJECTS
11 DISTRO_PATH = "/tmp/distribution-karaf"
12 BRANCH = 'master'
13 LIMIT = 10
14 QLIMIT = 50
15
16
17 class TestChanges(unittest.TestCase):
18
19     def setUp(self):
20         print("Starting test: %s" % self.id())
21
22     @staticmethod
23     def run_cmd(branch, distro_patch, limit, qlimit, project_names, remote_url):
24         changes = Changes(branch, distro_patch, limit, qlimit, project_names, remote_url, 0)
25         projects = changes.run_cmd()
26         changes.pretty_print_projects(projects)
27
28     def test_run_cmd_single(self):
29         project_names = ['netvirt']
30         self.run_cmd(BRANCH, DISTRO_PATH, LIMIT, QLIMIT, project_names, REMOTE_URL)
31
32     def test_run_cmd_multiple(self):
33         project_names = PROJECT_NAMES
34         self.run_cmd(BRANCH, DISTRO_PATH, LIMIT, QLIMIT, project_names, REMOTE_URL)
35
36     def test_pretty_print(self):
37         project_names = PROJECT_NAMES
38         changes = Changes(BRANCH, DISTRO_PATH, LIMIT, QLIMIT, project_names, REMOTE_URL)
39         projects = {}
40         for project in project_names:
41             projects[project] = {"commit": 1, "includes": [{'a': 1}]}
42         changes.pretty_print_projects(projects)
43         for project in project_names:
44             projects[project] = {"commit": 1,
45                                  "includes": [{"grantedOn": 1, "lastUpdated": 11,
46                                                "number": "12345", "subject": "This is a test for " + project},
47                                               {"grantedOn": 2, "lastUpdated": 22,
48                                                "number": "56789", "subject": "This is a test for " + project}]}
49         changes.pretty_print_projects(projects)
50
51     def test_epoch_to_utc(self):
52         project_names = PROJECT_NAMES
53         changes = Changes(BRANCH, DISTRO_PATH, LIMIT, QLIMIT, project_names, REMOTE_URL)
54         print("utc: %s" % changes.epoch_to_utc(1483974872))
55
56     def test_distcompare(self):
57         distcompare.main()
58
59
60 if __name__ == '__main__':
61     unittest.main()