forked from rwtamCaltech/cicd_test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_test.py
36 lines (27 loc) · 14.6 KB
/
app_test.py
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
"""
Unit test file for app.py
a unit test file for app.py to ensure that the string is reversed correc
"""
from PickRunner import returnBackwardsString
from PickRun import PickRun
import unittest
class TestApp(unittest.TestCase):
"""Unit tests defined for app.py"""
def test_return_backwards_string(self):
"""Test return backwards simple string"""
random_string = "This is my test string"
random_string_reversed = "gnirts tset ym si sihT"
self.assertEqual(random_string_reversed, returnBackwardsString(random_string))
def test_find_unique_stations(self):
#self.max_starttime=None
max_starttime=None
binsize=30
sampRate=100.0
starttime=None
pickrunClass=PickRun(max_starttime,binsize,sampRate,starttime)
listOfDicts=["{'endt': 1677012626, 'station': 'DAW', 'channel': 'HNN', 'samprate': 100, 'network': 'CI', 'data': '[9950, 9959, 9961, 9958, 9957, 9963, 9970, 9952, 9953, 9967, 9961, 9969, 9958, 9951, 9971, 9963, 9957, 9956, 9962, 9969, 9957, 9964, 9965, 9948, 9954, 9970, 9958, 9955, 9971, 9955, 9955, 9969, 9958, 9959, 9963, 9957, 9958, 9968, 9969, 9957, 9954, 9957, 9968, 9973, 9954, 9946, 9960, 9968, 9956, 9954, 9973, 9961, 9947, 9963, 9969, 9967, 9955, 9951, 9967, 9965, 9954, 9963, 9970, 9959, 9949, 9960, 9977, 9966, 9944, 9957, 9972, 9962, 9957, 9958, 9974, 9968, 9940, 9955, 9976, 9967, 9960, 9946, 9958, 9980, 9953, 9951, 9975, 9949, 9951, 9980, 9964, 9957, 9958, 9948, 9964, 9973, 9959, 9950, 9964, 9962]', 'startt': 1677012625}", "{'endt': 1677012616, 'station': 'CHN', 'channel': 'HHZ', 'samprate': 100, 'network': 'CI', 'data': '[995, 909, 2366, 2701, 1850, 758, -132, 677, 1480, 406, -1076, -212, 2282, 3039, 1748, 377, -376, 52, 1544, 1794, 1093, 1007, 1842, 2763, 2464, 1585, 897, -216, -1111, -219, 677, 573, 373, -502, -1701, -1265, 360, 1218, 1320, 1760, 2918, 2127, 207, -109, 492, 918, 918, 1746, 2202, 1285, 206, 650, 2106, 2236, 1439, -538, -1982, -193, 2753, 3706, 3010, 3128, 2539, 221, -1112, -1171, -787, -229, 96, 268, 328, 1694, 4146, 5048, 4306, 1645, -1620, -2333, -621, 1490, 1825, 531, -547, -625, 5, 698, 702, 375, 83, 172, 1363, 3011, 4509, 4568, 3312, 1849, 571, 91, -3, -66]', 'startt': 1677012615}", "{'endt': 1677012619, 'station': 'TRO', 'channel': 'HNN', 'samprate': 100, 'network': 'AZ', 'data': '[9915, 9571, 9512, 9773, 9470, 9729, 9751, 9507, 9904, 9586, 9439, 9834, 9523, 9669, 9844, 9478, 9654, 9705, 9557, 9787, 9651, 9650, 9753, 9404, 9662, 9788, 9562, 9786, 9657, 9537, 9738, 9613, 9651, 9756, 9560, 9687, 9661, 9494, 9714, 9692, 9630, 9754, 9604, 9575, 9742, 9626, 9616, 9730, 9646, 9582, 9631, 9668, 9709, 9734, 9619, 9601, 9685, 9616, 9637, 9713, 9609, 9707, 9681, 9504, 9713, 9698, 9613, 9704, 9581, 9639, 9713, 9578, 9683, 9713, 9627, 9692, 9596, 9629, 9718, 9602, 9694, 9693, 9579, 9724, 9641, 9561, 9770, 9639, 9579, 9743, 9582, 9606, 9744, 9651, 9638, 9637, 9655, 9660, 9631, 9672]', 'startt': 1677012618}", "{'endt': 1677012608, 'station': 'BCH', 'channel': 'HHZ', 'samprate': 100, 'network': 'CI', 'data': '[991, 988, 996, 997, 986, 995, 1008, 997, 1008, 1022, 1007, 1002, 1011, 1022, 1023, 1015, 1015, 1011, 1022, 1028, 1018, 1024, 1032, 1038, 1043, 1042, 1045, 1050, 1055, 1052, 1057, 1058, 1048, 1054, 1060, 1068, 1065, 1066, 1078, 1076, 1092, 1084, 1077, 1104, 1098, 1101, 1103, 1097, 1116, 1114, 1122, 1122, 1115, 1142, 1134, 1135, 1154, 1150, 1155, 1164, 1170, 1172, 1167, 1170, 1186, 1190, 1190, 1203, 1202, 1203, 1205, 1211, 1232, 1239, 1244, 1244, 1247, 1259, 1266, 1280, 1280, 1271, 1289, 1298, 1307, 1316, 1314, 1334, 1342, 1338, 1349, 1363, 1372, 1376, 1379, 1387, 1402, 1411, 1408, 1417]', 'startt': 1677012607}", "{'endt': 1677012601, 'station': 'WBM', 'channel': 'HHE', 'samprate': 100, 'network': 'CI', 'data': '[991, 1007, 1031, 1040, 1044, 1025, 1016, 1010, 996, 1012, 1018, 989, 969, 976, 984, 967, 959, 986, 972, 972, 1008, 992, 977, 997, 1023, 1041, 1037, 1016, 1007, 1033, 1045, 1024, 1015, 1009, 1002, 980, 968, 1017, 1059, 1064, 1028, 991, 999, 990, 1016, 1046, 1045, 1057, 1030, 1020, 1039, 1034, 1050, 1077, 1098, 1095, 1065, 1036, 983, 982, 1013, 998, 1025, 1042, 1035, 1047, 1035, 1049, 1055, 1040, 1071, 1071, 1076, 1089, 1062, 1079, 1088, 1076, 1116, 1151, 1149, 1123, 1082, 1069, 1063, 1039, 1032, 1039, 1035, 1019, 1023, 1050, 1051, 1044, 1050, 1082, 1110, 1104, 1118, 1123]', 'startt': 1677012600}", "{'endt': 1677012607, 'station': 'DAW', 'channel': 'HNN', 'samprate': 100, 'network': 'CI', 'data': '[9909, 9989, 9980, 9930, 9968, 9984, 9980, 9932, 9948, 9958, 9949, 10002, 9932, 9939, 10011, 9946, 9981, 9986, 9932, 9953, 9953, 9985, 9934, 9944, 10018, 9889, 9970, 10061, 9877, 9973, 10039, 9897, 9933, 9972, 9983, 9954, 9941, 9994, 9944, 9973, 9995, 9912, 9954, 10006, 9945, 9910, 9955, 10022, 10004, 9879, 9940, 10047, 9937, 9956, 9965, 9914, 10023, 9931, 9887, 10084, 9981, 9884, 10003, 9958, 9943, 9985, 9927, 9941, 9986, 9945, 9943, 9999, 10015, 9925, 9908, 10023, 9958, 9918, 9984, 9940, 9961, 9952, 9962, 10011, 9944, 9987, 9954, 9879, 10024, 9984, 9889, 9984, 9978, 9953, 9974, 9955, 9954, 9997, 9962, 9884]', 'startt': 1677012606}", "{'endt': 1677012598, 'station': 'SDD', 'channel': 'HHN', 'samprate': 100, 'network': 'CI', 'data': '[990, 1027, 473, 78, -206, -755, -1246, -1715, -1727, -1367, -1472, -1689, -1718, -1989, -2254, -1968, -1227, -977, -697, 8, 416, 1038, 1278, 1159, 1202, 1018, 775, 414, 20, -481, -658, -826, -1244, -1469, -1650, -1429, -1127, -891, -1053, -923, -470, -815, -403, 349, 142, -35, -122, -675, -1217, -1340, -1283, -1811, -2342, -2115, -2156, -2089, -1798, -1657, -1380, -992, -401, 148, 546, 743, 780, 721, 376, 0, 47, 16, -61, 132, -52, -367, -423, -426, -386, -223, -92, -129, -181, -285, -244, -345, -526, -462, -301, 76, -28, -186, -143, -138, -245, -836, -1320, -1676, -1853, -1928, -1912, -1919]', 'startt': 1677012597}", "{'endt': 1677012619, 'station': 'SRT', 'channel': 'HHZ', 'samprate': 100, 'network': 'CI', 'data': '[988, 1035, 1074, 1076, 1069, 1045, 1029, 1060, 1100, 1085, 1086, 1043, 992, 988, 979, 984, 978, 986, 994, 1001, 1015, 1033, 1042, 1048, 1058, 1022, 1011, 983, 930, 916, 898, 923, 929, 930, 981, 999, 1015, 1029, 1038, 1048, 1022, 1000, 1004, 1018, 1034, 1081, 1085, 1073, 1080, 1065, 1070, 1044, 1042, 1065, 1069, 1046, 1045, 1054, 1032, 1039, 1025, 1006, 1019, 1041, 1021, 1042, 1067, 1047, 1084, 1069, 1048, 1010, 983, 1001, 988, 993, 1012, 1045, 1032, 1051, 1102, 1110, 1156, 1152, 1134, 1146, 1131, 1141, 1106, 1091, 1076, 1023, 1034, 1009, 1000, 993, 971, 995, 996, 1007]', 'startt': 1677012618}", "{'endt': 1677012603, 'station': 'TER2', 'channel': 'HNZ', 'samprate': 100, 'network': 'CI', 'data': '[987, 984, 982, 988, 988, 985, 988, 988, 982, 978, 985, 990, 991, 988, 980, 979, 983, 988, 991, 985, 976, 977, 984, 990, 989, 987, 989, 988, 989, 986, 983, 986, 982, 983, 985, 986, 988, 986, 987, 986, 975, 971, 981, 986, 986, 988, 990, 991, 986, 984, 986, 988, 983, 979, 985, 989, 989, 989, 986, 984, 982, 981, 984, 986, 984, 977, 981, 985, 985, 989, 985, 979, 981, 983, 990, 987, 984, 986, 985, 988, 986, 988, 993, 986, 986, 985, 983, 989, 983, 981, 987, 986, 979, 976, 983, 988, 988, 987, 984, 984]', 'startt': 1677012602}", "{'endt': 1677012604, 'station': 'LRR2', 'channel': 'HHZ', 'samprate': 100, 'network': 'CI', 'data': '[984, 1092, 1155, 1092, 1048, 1112, 1109, 1007, 986, 990, 1036, 1103, 994, 924, 990, 1007, 1000, 999, 992, 975, 960, 924, 900, 896, 959, 989, 907, 966, 981, 974, 992, 910, 1001, 1095, 1061, 986, 973, 1061, 1055, 980, 939, 1011, 1066, 1038, 1009, 970, 1014, 1004, 1009, 995, 884, 964, 1020, 1053, 1045, 977, 1029, 1005, 1006, 944, 919, 1028, 898, 859, 1012, 1001, 1013, 1056, 945, 950, 1077, 1108, 1124, 1049, 999, 1091, 1093, 1054, 1011, 1014, 1065, 1093, 1133, 1059, 1019, 1034, 980, 984, 994, 1003, 1048, 1009, 939, 925, 927, 973, 976, 935, 940, 946]', 'startt': 1677012603}", "{'endt': 1677012603, 'station': '23077', 'channel': 'HNE', 'samprate': 100, 'network': 'CE', 'data': '[984, 1000, 1013, 1003, 923, 955, 949, 948, 964, 958, 1005, 974, 935, 928, 971, 1002, 1014, 999, 915, 959, 987, 905, 898, 997, 1022, 978, 1011, 989, 981, 952, 895, 941, 922, 951, 1041, 1035, 984, 925, 948, 968, 958, 981, 956, 945, 964, 960, 946, 992, 997, 946, 973, 967, 970, 982, 963, 971, 959, 956, 956, 978, 977, 994, 1015, 934, 939, 985, 948, 943, 984, 966, 919, 961, 980, 963, 994, 991, 970, 944, 936, 953, 929, 970, 1004, 985, 969, 914, 988, 1006, 944, 1021, 981, 912, 970, 992, 979, 981, 968, 933, 961, 993]', 'startt': 1677012603}", "{'endt': 1677012607, 'station': 'LLS', 'channel': 'HHZ', 'samprate': 100, 'network': 'CI', 'data': '[983, 2345, 3827, 4504, 4554, 3974, 2996, 1791, 436, -354, -445, -16, 829, 1980, 3026, 3635, 4236, 4558, 3765, 2165, 557, -427, -802, -900, -468, 243, 1247, 2521, 3383, 3925, 4305, 4350, 3839, 3091, 2354, 1171, -62, -742, -617, 585, 2059, 3171, 4285, 5523, 6312, 5755, 4198, 2622, 1711, 1642, 1583, 1174, 544, 22, -167, -494, -861, -830, -343, 551, 1344, 1555, 1771, 2391, 2929, 2880, 2472, 2385, 2453, 2577, 2510, 1830, 1055, 526, 214, 231, 675, 1196, 1275, 880, 552, 665, 825, 914, 769, -151, -1172, -1536, -1616, -1446, -1039, -368, 801, 1943, 2398, 1784, 1023, 1340, 2010, 2178]', 'startt': 1677012606}", "{'endt': 1677012626, 'station': 'SLB', 'channel': 'HHE', 'samprate': 100, 'network': 'CI', 'data': '[98, 67, 143, 136, 50, 64, 44, 1, 52, 108, 164, 199, 57, 20, 115, 75, 165, 214, 187, 207, 151, 213, 108, 29, 188, 157, 148, 130, 124, 179, 150, 200, 205, 163, 76, 137, 228, 120, 262, 244, 92, 176, 165, 227, 225, 133, 154, 150, 173, 209, 268, 257, 201, 214, 157, 159, 233, 234, 234, 257, 219, 200, 250, 211, 211, 213, 255, 317, 269, 287, 148, 142, 265, 180, 212, 193, 199, 260, 208, 298, 311, 313, 362, 206, 245, 254, 194, 299, 317, 447, 371, 168, 130, 142, 370, 448, 341, 326, 291, 264]', 'startt': 1677012625}", "{'endt': 1677012600, 'station': '5062', 'channel': 'EHZ', 'samprate': 100, 'network': 'NP', 'data': '[98, 144, 68, -105, -151, -61, -63, -179, -320, -349, -87, 407, 804, 911, 813, 562, 234, 2, -61, -62, 6, 255, 475, 552, 535, 333, 13, -239, -261, -71, 198, 446, 508, 297, -56, -307, -373, -406, -356, -131, 63, 166, 136, -90, -327, -336, -79, 192, 315, 243, 57, 20, 133, 275, 244, 16, -59, 60, 199, 232, 106, 19, 55, 148, 328, 490, 444, 250, 27, -178, -205, -27, 204, 335, 260, 39, -187, -288, -271, -287, -260, 6, 329, 439, 274, -80, -367, -395, -153, 11, -15, 126, 284, 361, 385, 132, -144, -208, -90, 208]', 'startt': 1677012600}", "{'endt': 1677012603, 'station': 'BLC', 'channel': 'HHN', 'samprate': 100, 'network': 'CI', 'data': '[976, 977, 995, 1010, 1011, 1015, 1011, 1017, 1011, 1017, 1027, 1006, 1014, 1011, 1011, 996, 985, 974, 931, 934, 929, 915, 902, 895, 893, 884, 897, 894, 882, 875, 874, 875, 877, 891, 884, 878, 875, 875, 870, 841, 855, 847, 835, 849, 838, 835, 822, 824, 811, 815, 825, 825, 836, 817, 837, 834, 829, 851, 840, 835, 821, 826, 827, 820, 825, 813, 821, 832, 843, 859, 837, 847, 836, 823, 846, 835, 834, 812, 818, 826, 803, 818, 810, 787, 799, 792, 798, 803, 788, 809, 778, 778, 782, 741, 734, 709, 706, 696, 691, 705]', 'startt': 1677012602}", "{'endt': 1677012625, 'station': 'BBR', 'channel': 'HNZ', 'samprate': 100, 'network': 'CI', 'data': '[973, 971, 976, 965, 974, 977, 972, 975, 969, 979, 976, 974, 982, 975, 975, 971, 976, 974, 961, 979, 979, 971, 980, 969, 970, 977, 977, 975, 972, 980, 974, 976, 981, 965, 970, 978, 970, 971, 976, 976, 969, 969, 972, 968, 975, 975, 972, 980, 971, 970, 983, 970, 967, 979, 977, 974, 979, 975, 968, 970, 969, 964, 969, 979, 971, 975, 975, 968, 977, 972, 972, 977, 970, 974, 973, 973, 977, 976, 975, 972, 974, 971, 967, 980, 977, 967, 972, 970, 975, 981, 973, 971, 974, 971, 979, 975, 972, 978, 966, 978]', 'startt': 1677012624}", "{'endt': 1677012615, 'station': 'BBR', 'channel': 'HHE', 'samprate': 100, 'network': 'CI', 'data': '[973, 903, 970, 1014, 1227, 1532, 1454, 1125, 955, 820, 804, 986, 1057, 1065, 1181, 1294, 1366, 1325, 999, 670, 559, 511, 652, 1041, 1297, 1307, 1332, 1188, 931, 861, 729, 615, 758, 917, 1027, 1213, 1320, 1275, 1179, 1032, 846, 803, 889, 888, 916, 1039, 1103, 1189, 1241, 1209, 1171, 1121, 1056, 1077, 1259, 1246, 1025, 775, 575, 672, 890, 1081, 1209, 1238, 1347, 1381, 1258, 1096, 890, 761, 794, 946, 1124, 1323, 1532, 1644, 1669, 1508, 1128, 808, 605, 631, 1054, 1465, 1479, 1368, 1256, 982, 759, 662, 648, 842, 1124, 1274, 1371, 1434, 1241, 929, 714, 599]', 'startt': 1677012614}", "{'endt': 1677012616, 'station': 'RKMO', 'channel': 'HHE', 'samprate': 100, 'network': 'CI', 'data': '[968, 953, 991, 970, 1021, 1058, 1029, 970, 991, 1014, 952, 994, 1026, 1011, 964, 894, 928, 889, 820, 911, 952, 937, 975, 928, 913, 935, 926, 918, 942, 998, 942, 925, 961, 948, 938, 961, 971, 924, 990, 1010, 900, 947, 973, 918, 1024, 1058, 989, 973, 925, 922, 991, 1060, 1053, 1014, 1046, 1003, 945, 968, 986, 1025, 1001, 1012, 1014, 940, 1014, 964, 896, 1030, 1014, 914, 932, 982, 905, 916, 1054, 970, 950, 984, 855, 889, 958, 944, 902, 887, 889, 825, 937, 1021, 957, 966, 978, 945, 937, 979, 927, 863, 915, 876, 831, 888]', 'startt': 1677012615}", "{'endt': 1677012611, 'station': 'STC', 'channel': 'HHE', 'samprate': 100, 'network': 'CI', 'data': '[968, 1004, 1265, 1650, 1707, 1540, 1101, 767, 752, 787, 835, 830, 753, 531, 393, 367, 514, 906, 1145, 1339, 1468, 1574, 1713, 1508, 1254, 1074, 896, 1000, 1227, 1467, 1591, 1402, 1207, 1114, 1046, 1069, 1219, 1368, 1543, 1719, 1259, 618, 462, 470, 495, 287, 217, 287, 142, 215, 547, 784, 706, 406, 104, 220, 490, 714, 1097, 1032, 796, 919, 1418, 1839, 1774, 1679, 1351, 986, 1021, 1182, 1368, 1442, 1468, 1535, 1559, 1439, 1261, 1241, 1178, 889, 828, 1014, 1063, 1146, 1052, 795, 624, 660, 1043, 1151, 1003, 986, 1081, 1311, 1436, 1484, 1567, 1506, 1286, 1208]', 'startt': 1677012610}", "{'endt': 1677012598, 'station': 'DTP', 'channel': 'HHN', 'samprate': 100, 'network': 'CI', 'data': '[967, 990, 950, 982, 1001, 963, 1005, 992, 971, 977, 998, 952, 974, 1026, 961, 1009, 1020, 958, 1012, 1008, 956, 990, 989, 986, 999, 997, 1019, 990, 1021, 987, 986, 1010, 969, 1026, 993, 980, 1045, 996, 978, 1035, 973, 979, 1022, 987, 1011, 1005, 1001, 1012, 982, 1011, 996, 977, 1013, 1013, 996, 1013, 1022, 983, 1022, 986, 990, 1034, 971, 1017, 1013, 1003, 1015, 999, 1010, 963, 1015, 987, 963, 1029, 989, 982, 1006, 1012, 976, 1006, 985, 969, 1022, 995, 993, 998, 1016, 976, 974, 1022, 962, 999, 1007, 982, 989, 1012, 993, 963, 1023, 949]', 'startt': 1677012597}"]
df_candidates_list, _=pickrunClass.find_candidates(listOfDicts)
df_candidates_list_expected=['CI.DAW.HN', 'CI.CHN.HH', 'AZ.TRO.HN', 'CI.BCH.HH', 'CI.WBM.HH', 'CI.SDD.HH', 'CI.SRT.HH', 'CI.TER2.HN', 'CI.LRR2.HH', 'CE.23077.HN', 'CI.LLS.HH', 'CI.SLB.HH', 'NP.5062.EH', 'CI.BLC.HH', 'CI.BBR.HN', 'CI.BBR.HH', 'CI.RKMO.HH', 'CI.STC.HH', 'CI.DTP.HH']
self.assertEqual(df_candidates_list_expected, df_candidates_list)
if __name__ == "__main__":
unittest.main()