summaryrefslogtreecommitdiffstats
path: root/For Weekly Test/19-08-2011/TrueTable2.py
blob: 31652a892836d1f2f5aeb952edde2fd4f7c2b576 (plain) (blame)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# check signal on rz 1, 2, and 3 to indicated test
# only have option destination to GSM RZ, such as SIP to GSM RZ not SIP to GSM RZ 1, 2 or 3!
# if the result is not 200 or 486, do one more test. because its means we have problem with handler. waiting 5 second and do the test.

#resultsList = list()
#resultsList = [['sip', 'GSMRZ1', '200'],['sip', 'GSMRZ2', '200'],['sip', 'GSMRZ3', '200']]
resultsList = [['sip', 'GSMExt.O2', '486'],['sip', 'GSMExt.Voda', '486'],['sip', 'GSMExt.Tm', '486']]
callerList = ['sip']
destinationList = ['GSMRZ']

def initDB():
    global dbStatus
    global db
    
    db = DbClass.DBMySQLConnection('root', 'randompasswordSQL', 'localhost', 'gsmselftesting')
    db.connectDB()
    dbStatus = db.connectDB()

def initTest(callFrom,callTo):
    global dest
    global caller
    global callAdd
    global accCaller
    global recAdd
    global destNo
    global accDest
    global result
    
    initDB()
    
    if dbStatus != 0:
        
        dest = db.deviceAddress(str(callTo))
        
        caller = db.deviceAddress(str(callFrom))
        
        callAdd = caller[0]
        accCaller = caller[2]+':'+caller[3]+':'+caller[4]+':'
        
        recAdd = destination[0]
        destNo = destination[1]
        accDest = destination[2]+':'+destination[3]+':'+destination[4]+':'
        
        makeTest = ControllerClass.test(caller, callAdd, accCaller, callTo, recAdd, destNo, accDest)	
        makeTest.FuncTest()
        
        result = makeTest.testResult
    else:
        print "No connection to Database"
            
    return result

def smartTest():
    
    for callFrom in callerList:
        for destination in destinationList:
            
            if destination == 'GSMRZ':
                print "make a call to GSMRZ1"
                initTest('sip','GSMRZ1')
                
                if result == '200':
                    print "make a call to GSMRZ2"
                    initTest('sip','GSMRZ2')
                    
                    if result == '200':
                        print "make a call to GSMRZ3"
                        initTest('sip','GSMRZ3')
                        
                        if result == '200': 
                            print "all netwrok on GSMRZ are fine"
                        elif result == '486':
                            print "BTS 3 Down"
                        else:
                            print "have problem with handler"
                    
                    elif result == '486':
                        print "make a call to GSMRZ3"
                        initTest('sip','GSMRZ3')
                        
                        if result == '200':
                            print "BTS 2 Down"
                        elif result == '486':
                            print "BTS 2 and 3 indicate having problem"
                        else:
                            print "have problem with handler"
                    else:
                        print "have problem with handler"
                
                elif result == '486':
                    print "make a call to GSMRZ2"
                    initTest('sip','GSMRZ2')
                    
                    if result == '200':
                        print "make a call to GSMRZ3"
                        initTest('sip','GSMRZ3')
                        
                        if result == '200': 
                            print "BTS 1 Down"
                        else:
                            print "BTS 1 & 3 indicate having problem"
                    
                    else:
                        print "make a call to GSMRZ3"
                        
                        if result == '200':
                            print "BTS 1 & 2 indicate having problem"
                        else:
                            print "OpenBSc Down"
                else:
                    print "have problem with handler"
        
        
        
            
            elif destination == 'GSMExt':
                print "make a call to O2"
                initTest('sip','GSMExt.O2')
                    
                    if result == '200':
                        print "make a call to Voda"
                        initTest('sip','GSMExt.Voda')
                        
                        if result == '200':
                            print "make a call to T-Mobile"
                            initTest('sip','GSMExt.Tm')
                            
                            if result == '200': 
                                print "All netwrok on GSM external are fine"
                            else:
                                print "T-Mobile card indicate having problem"
                        
                        else:
                            print "make a call to T-Mobile"
                            initTest('sip','GSMExt.Tm')
                            
                            if result == '200':
                                print "Vodaphone card indicate having problem"
                            else:
                                print "Vodaphone and T-Mobile card indicate having problem"
                    
                    if result != '200':
                        print "make a call to Vodaphone"
                        initTest('sip','GSMExt.Voda')
                        
                        if result == '200':
                            print "make a call to T-Mobile"
                            initTest('sip','GSMExt.Tm')
                            
                            if result == '200': 
                                print "O2 card indicate having problem"
                            else:
                                print "O2 and T-Mobile card indicate having problem"
                        
                        else:
                            print "make a call to T-Mobile"
                            initTest('sip','GSMExt.Tm')
                            
                            if result == '200':
                                print "O2 and Vodaphone card indicate having problem"
                            else:
                                print "GSM External Modem Down"
            
            elif destination == 'SIP':
                print "make a call to Landline"
                initTest('sip','Landline')
                
                if result == '200':
                    print "make a call to UNISIP"
                    initTest('sip','unisip')
                    
                    if result =='200':
                        print "All SIP network is fine"
                    else:
                        print "UNISIP indicate having problem"
                
                else:
                    print "making a call to UNISIP"
                    initTest('sip','unisip')
                    
                    if result == '200':
                        print "Landline indicate having problem"
                    else:
                        print "SIP Network Down"


for caller in callerList:
    smartTest()