summaryrefslogtreecommitdiffstats
path: root/scripts/gettestcaseswithchanges.py
blob: c1d44c2143c0780d990d78880259c41a933b92cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sys, json
from dbaccess import execQuery
from misc import printJSONHeader


class GetTestCasesWithChanges:

    def __init__(self):
        pass

    def execute(self):
        self.test_cases = execQuery(
            "SELECT value FROM (SELECT DISTINCT testCaseId FROM change)"
            " AS foo, testCase WHERE testCase.id = testCaseId"
            " ORDER BY value", ())

        # Flatten one level:
        self.test_cases = (
            [item for sublist in self.test_cases for item in sublist])

        self.writeOutput()

    def writeOutputAsJSON(self):
        printJSONHeader()
        json.dump({ 'testCases': self.test_cases }, sys.stdout)


class GetTestCasesWithChangesAsJSON(GetTestCasesWithChanges):
    def writeOutput(self):
        self.writeOutputAsJSON()