Repository navigation
Expand file tree
/
Copy pathUnitTester.py
More file actions
172 lines (133 loc) · 5.37 KB
/
Copy pathUnitTester.py
File metadata and controls
172 lines (133 loc) · 5.37 KB
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
import json
from pprint import pprint
from Parser import Decompiler, ParseFull, ParseHeader
from FileManager import FileManager
from DatabaseManager import DatabaseManager, CSVManager
from ReplayDatabaseManager import ReplayDatabaseManager
class FileManagerTest:
def __init__(self):
pass
def test(self):
#manager = FileManager()
# startTime=time.time()
# manager.writeOneByOne(path='Replay Database BC', useBC=True)
# print('Boxcars run time: ' + str(time.time() - startTime))
# startTime=time.time()
# manager.writeOneByOne(path='Replay Database RT', useBC=False)
# print('Rattletrap run time: ' + str(time.time() - startTime))
#pprint(manager.getReplayGUID(['C:/Users/Joseph/Documents/GitHub/CalculatedGG-Uploader/Refactor/0F84A75D45E7EB7F8D174E89F9AF530F.replay']))
# B061283E11E8FABB3863BE9B893AE1C5
#pprint(manager.replayBatches)
#manager.testDecompileTime()
# Boxcars run time: 164.7187614440918 seconds - 2mins 44secs
# Rattletrap run time: 985.8462634086609 seconds - 16mins 26secs
# Boxcars decompile time: 124.69161868095398 seconds - 2mins 4 seconds
# Rattletrap decompile time: 510.35151839256287 seconds - 8mins 30 seconds
pass
class UploaderTest:
def __init__(self):
pass
class ReplayDatabaseManagerTest:
def __init__(self):
self.exportHeaders()
pass
def test(self):
# manager = ReplayDatabaseManager()
# manager.importReplayDatabase()
# value = manager.getGUIDFromDatabase('87B11D4743F1EAE859CAC9B48DAA8E89.replay')
# pprint(value)
#manager.exportReplayDatabase()
#manager.importReplayDatabase()
pass
def exportHeaders(self):
fmanager = FileManager()
demoPathAttributes = fmanager.getAttributes()
rmanager = ReplayDatabaseManager(demoPathAttributes)
rmanager.getBatchHeaders()
def testDecompileTime(self):
startTime = time.time()
for replay in tqdm(self.replayList):
replayAnalyzer = ReplayManager(replay[0], onlyGUID=True)
print('Boxcars run time: ' + str(time.time() - startTime))
startTime = time.time()
for replay in tqdm(self.replayList):
replayAnalyzer = ReplayManager(replay[0], onlyGUID=False)
print('Rattletrap run time: ' + str(time.time() - startTime))
class DatabaseManagerTest:
def __init__(self):
self.manager = DatabaseManager()
self.cmanager = CSVManager()
#manager.exportReplayDatabase()
def createDatabase(self):
pass
def importDatabase(self, databasePath):
return self.manager.read(databasePath)
def exportDatabase(self, data, header, filePath, createBackup):
self.cmanager.write(data, header, filePath, createBackup)
def dropTest(self, colName, database):
return self.manager.delCol(colName, database)
def swapTest(self, cols, database):
return self.manager.swapCols(cols, database)
def delDuplicatesTest(self, database):
return self.manager.delDupes(database)
def databaseTester(self):
testReplay = '87B11D4743F1EAE859CAC9B48DAA8E89.replay'
# testDB = pd.read_csv(defaultDatabasePath)
# print(testDB)
dbm = DatabaseManager()
dbm.read()
#print(dbm.database)
row = dbm.getRow(testReplay)
print(row)
value = row.iloc[0]['GUID']
print(value)
# csvManager = CSVManager()
# reader = csvManager.Reader(testPath)
# db = reader.database
# print(db)
# db1 = reader.getRow(testReplay)
# print(db1.iloc[0]['Name'])
# print(reader.valueExists([testReplay]))
# #print(db1.index)
class ParserTest:
def __init__(self):
self.replayPath = "C:/Users/Joseph/Documents/GitHub/Vextra/TestFiles/Replays/Set of 100/9058036243440939A62D4A91DAE72D35.replay"
#self.replayPath = "C:/Users/Joseph/Documents/GitHub/Vextra/TestFiles/Replays/Set of 100/DFFE296847EFE13FD1AB1587B64C59DE.replay"
self.logDecompileTime = False
self.testDecompile()
#self.getGUID()
self.getBasicData()
self.dataJson = self.dictToJson(self.basicData)
self.printAttributes()
self.outputJSON(self.dataJson)
def testDecompile(self):
self.jsonObject = Decompiler(self.replayPath).decompile(logTime=self.logDecompileTime, onlyHeader=True)
def getGUID(self):
self.guid = ParseFull(self.jsonObject, 'boxcars').getGUID()
def getBasicData(self):
self.basicData = ParseHeader(self.jsonObject).getHeaderData()
def dictToJson(self, dictData):
data = json.dumps(dictData)
loadedData = json.loads(data)
return loadedData
def printAttributes(self):
#pprint('GUID: ' + self.guid)
pprint(self.basicData)
def outputJSON(self, jsonObject):
with open('data.json', 'w') as outfile:
json.dump(jsonObject, outfile, indent=4, separators=(',', ': '), sort_keys=True)
#parserTest = ParserTest()
rTest = ReplayDatabaseManagerTest()
# databaseManager = DatabaseManagerTest()
# db = databaseManager.importDatabase('C:/Users/Joseph/Documents/GitHub/CalculatedGG-Uploader/Refactor/Complete (With Duplicates).csv')
# #db_drop = databaseManager.dropTest('index', db)
# #db_newCols = databaseManager.swapTest(['Name', 'GUID', 'Path'], db_drop)
# db_delDupes = databaseManager.delDuplicatesTest(db)
# # print(db)
# # print(db_delDupes)
# databaseManager.exportDatabase(data=db_delDupes, header=list(db_delDupes), filePath='Complete.csv', createBackup=False)
# # tbt = databaseManager.importDatabase('C:/Users/Joseph/Documents/GitHub/CalculatedGG-Uploader/Refactor/Tobetrimmed.csv')
# # tbt_drop = databaseManager.dropTest('JSON', tbt)
# # databaseManager.exportDatabase(data=tbt_drop, header=list(tbt), filePath='tbt.csv', createBackup=False)
# databaseManager = DatabaseManagerTest()
# databaseManager.databaseTester()