Remove remnants of sfc project
[integration/test.git] / tools / distchanges / tests / test_changes.py
1 #!/usr/bin/env python
2
3 # TODO: Add more tests here using all the tests/resources/* and automate those tests in a verify job
4
5 import logging
6 import unittest
7 import distcompare
8 from changes import Changes
9
10 REMOTE_URL = "ssh://git.opendaylight.org:29418"
11 PROJECT_NAMES = [
12     "controller",
13     "dlux",
14     "dluxapps",
15     "infrautils",
16     "mdsal",
17     "netconf",
18     "neutron",
19     "odlparent",
20     "openflowplugin",
21     "ovsdb",
22     "yangtools",
23 ]
24 DISTRO_PATH = "/tmp/distribution-karaf"
25 BRANCH = "master"
26 LIMIT = 10
27 QLIMIT = 50
28
29
30 class TestChanges(unittest.TestCase):
31     def setUp(self):
32         print("Starting test: %s" % self.id())
33
34     @staticmethod
35     def run_cmd(
36         branch, distro_patch, limit, qlimit, project_names, remote_url, loglevel=0
37     ):
38         changes = Changes(
39             branch, distro_patch, limit, qlimit, project_names, remote_url, loglevel
40         )
41         projects = changes.run_cmd()
42         changes.pretty_print_projects(projects)
43
44     def test_run_cmd_multiple(self):
45         project_names = PROJECT_NAMES
46         branch = BRANCH
47         self.run_cmd(
48             branch, DISTRO_PATH, LIMIT, QLIMIT, project_names, REMOTE_URL, logging.INFO
49         )
50
51     def test_pretty_print(self):
52         project_names = PROJECT_NAMES
53         changes = Changes(BRANCH, DISTRO_PATH, LIMIT, QLIMIT, project_names, REMOTE_URL)
54         projects = {}
55         for project in project_names:
56             projects[project] = {"commit": 1, "includes": [{"a": 1}]}
57         changes.pretty_print_projects(projects)
58         for project in project_names:
59             projects[project] = {
60                 "commit": 1,
61                 "includes": [
62                     {
63                         "grantedOn": 1,
64                         "lastUpdated": 11,
65                         "number": "12345",
66                         "subject": "This is a test for " + project,
67                     },
68                     {
69                         "grantedOn": 2,
70                         "lastUpdated": 22,
71                         "number": "56789",
72                         "subject": "This is a test for " + project,
73                     },
74                 ],
75             }
76         changes.pretty_print_projects(projects)
77
78     def test_epoch_to_utc(self):
79         project_names = PROJECT_NAMES
80         changes = Changes(BRANCH, DISTRO_PATH, LIMIT, QLIMIT, project_names, REMOTE_URL)
81         print("utc: %s" % changes.epoch_to_utc(1483974872))
82
83     def test_distcompare(self):
84         distcompare.main()
85
86
87 if __name__ == "__main__":
88     unittest.main()