|
@@ -56,7 +56,7 @@ class MyTestCase(unittest.TestCase):
|
|
|
|
|
|
start_time = 1664632800
|
|
|
end_time = 1664640000
|
|
|
- painter = ChannelSpeedAnalyzePainter(start_time=start_time, end_time=end_time, chnames=set(['feimingyunew']), card_types={4},spec=100)
|
|
|
+ painter = ChannelSpeedAnalyzePainter(start_time=start_time, end_time=end_time, chnames=set(['feimingyunew']), card_types={4}, spec=100)
|
|
|
painter.paint()
|
|
|
|
|
|
def test_chcov_ratio(self):
|
|
@@ -64,7 +64,7 @@ class MyTestCase(unittest.TestCase):
|
|
|
|
|
|
start_time = int(time.time()) - 10 * 86400 - 3600
|
|
|
end_time = int(time.time()) - 10 * 86400
|
|
|
- painter = ChannelCovPainter(start_time=start_time, end_time=end_time, chnames=set(), card_types={4, 5, 6},filter_wave=3600)
|
|
|
+ painter = ChannelCovPainter(start_time=start_time, end_time=end_time, chnames=set(), card_types={4, 5, 6}, filter_wave=3600)
|
|
|
painter.paint()
|
|
|
|
|
|
def test_chcov_succ(self):
|
|
@@ -72,7 +72,7 @@ class MyTestCase(unittest.TestCase):
|
|
|
|
|
|
start_time = int(time.time()) - 20 * 86400 - 3600
|
|
|
end_time = int(time.time()) - 20 * 86400
|
|
|
- painter = ChannelCovSuccPainter(start_time=start_time, end_time=end_time, chnames=set(), card_types={4, 5, 6},filter_wave=3600)
|
|
|
+ painter = ChannelCovSuccPainter(start_time=start_time, end_time=end_time, chnames=set(), card_types={4, 5, 6}, filter_wave=3600)
|
|
|
painter.paint()
|
|
|
|
|
|
def test_mch_ratio_painter(self):
|
|
@@ -99,14 +99,24 @@ class MyTestCase(unittest.TestCase):
|
|
|
painter = MerchantAmountPainter(start_time=start_time, end_time=end_time, mchids=set(), card_types={4, 5, 6})
|
|
|
painter.paint()
|
|
|
|
|
|
+
|
|
|
+ def test_ChannelWriter(self):
|
|
|
+ from refill import ChannelWriter, open_hdf5
|
|
|
+ import time
|
|
|
+
|
|
|
+ hfive = open_hdf5('/var/www/html/data/stdata/channel.hdf5', True)
|
|
|
+ chwriter = ChannelWriter(hfive)
|
|
|
+ item = {'channel_name':'zero', 'time':time.time(), 'spec':50, 'card_type':4, 'channel_amount':49, 'period':30}
|
|
|
+ chwriter.write('ch_succ',item)
|
|
|
+
|
|
|
def test_netcheck(self):
|
|
|
from refill import NetchkReader
|
|
|
import time
|
|
|
from refill import day_stamp
|
|
|
|
|
|
day = day_stamp(int(time.time()) - 4 * 86400)
|
|
|
- days = [day,day-86400]
|
|
|
-
|
|
|
+ days = [day, day - 86400]
|
|
|
+
|
|
|
net = NetchkReader()
|
|
|
channels = net.tuple_path(day)
|
|
|
channels = net.many_tuple_path(days)
|
|
@@ -209,7 +219,7 @@ class MyTestCase(unittest.TestCase):
|
|
|
time.sleep(0.01)
|
|
|
|
|
|
handler = PrintHandler()
|
|
|
- consumer = WriterConsumer(handler,'PrintHandler')
|
|
|
+ consumer = WriterConsumer(handler, 'PrintHandler')
|
|
|
consumer.start()
|
|
|
|
|
|
for i in range(100000):
|
|
@@ -221,8 +231,8 @@ class MyTestCase(unittest.TestCase):
|
|
|
from collections import defaultdict
|
|
|
import time as time
|
|
|
|
|
|
- def merge(l,r):
|
|
|
- for name,ls in l.items():
|
|
|
+ def merge(l, r):
|
|
|
+ for name, ls in l.items():
|
|
|
if name in r:
|
|
|
ls.extend(r[name])
|
|
|
k = set(ls)
|
|
@@ -235,27 +245,23 @@ class MyTestCase(unittest.TestCase):
|
|
|
a = {'yunchonggongfs': [(4, 100), (4, 30), (4, 50)]}
|
|
|
b = {'yunchonggongfs': [(4, 100), (4, 200), (4, 50)]}
|
|
|
|
|
|
- all = merge(a,all)
|
|
|
- all = merge(b,all)
|
|
|
+ all = merge(a, all)
|
|
|
+ all = merge(b, all)
|
|
|
x = 0;
|
|
|
|
|
|
def test_split(self):
|
|
|
def split_card(card_specs):
|
|
|
result = dict()
|
|
|
- for card_type,spec in card_specs:
|
|
|
+ for card_type, spec in card_specs:
|
|
|
if card_type not in result:
|
|
|
result[card_type] = []
|
|
|
result[card_type].append(spec)
|
|
|
return result
|
|
|
|
|
|
-
|
|
|
- tups = [(4, 100), (4, 50) ,(5,10),(4, 30),(5,30),(6,100),(5,100),]
|
|
|
+ tups = [(4, 100), (4, 50), (5, 10), (4, 30), (5, 30), (6, 100), (5, 100), ]
|
|
|
x = split_card(tups)
|
|
|
y = 1
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
if __name__ == '__main__':
|
|
|
unittest.main()
|