diff --git a/src/backend/apps/event/tests/test_event_serializer.py b/src/backend/apps/event/tests/test_event_serializer.py index e6d77813d..34cbf78a6 100644 --- a/src/backend/apps/event/tests/test_event_serializer.py +++ b/src/backend/apps/event/tests/test_event_serializer.py @@ -111,7 +111,7 @@ def test_serializer_data(self): assert self.serializer_two.data['route_display'] == \ "Test Road Two to Test Avenue Two" assert self.serializer_two.data['direction_display'] == \ - "Both" + "Both directions" # Eastern time auto adjusted to Pacific time assert self.serializer_two.data['last_updated'] == \ diff --git a/src/backend/apps/webcam/tests/test_webcam_serializer.py b/src/backend/apps/webcam/tests/test_webcam_serializer.py index ef97d878b..10a3d88ea 100644 --- a/src/backend/apps/webcam/tests/test_webcam_serializer.py +++ b/src/backend/apps/webcam/tests/test_webcam_serializer.py @@ -53,5 +53,6 @@ def setUp(self): self.serializer = WebcamSerializer(self.webcam) + # 2024/03/26 added 'dbc_mark' and 'credit' def test_serializer_data(self): - assert len(self.serializer.data) == 24 + assert len(self.serializer.data) == 26 diff --git a/src/backend/test.py b/src/backend/test.py deleted file mode 100644 index 754a02647..000000000 --- a/src/backend/test.py +++ /dev/null @@ -1,1088 +0,0 @@ -from datetime import datetime -from zoneinfo import ZoneInfo -from pprint import pprint -import json -import re -import requests - -import pytz - -NEWLINES = re.compile(r'\n') -HTML = re.compile('<.*?>') - -from PIL import Image, ImageDraw, ImageFont - -font = ImageFont.truetype('BCSans.otf', size=16) - -im = Image.open('228.jpg') -tz = ZoneInfo("America/Vancouver") - -x, y = im.size -ti = Image.new('RGB', (x, y + 24)) -ti.paste(im) -d = ImageDraw.Draw(ti) -now = datetime.now(tz=tz) -month = now.strftime('%b') -day = now.strftime('%d') -day = day[1:] if day[:1] == '0' else day -ts = f'{month} {day}, {now.strftime("%Y %H:%M:%S %p %Z")}' -d.text((x - 5, y + 18), ts, fill="white", anchor='rs', font=font) -d.text((5, y + 18), "DriveBC.ca", fill="white", anchor='ls', font=font) -# ti.show() - -ids = [ - 893, - 126, - 478, - 254, - 495, - 156, - 874, - 198, - 172, - 197, - 134, - 601, - 602, - 566, - 593, - 146, - 892, - 111, - 1039, - 286, - 794, - 143, - 795, - 378, - 775, - 776, - 778, - 336, - 799, - 823, - 859, - 800, - 6, - 703, - 702, - 701, - 779, - 781, - 782, - 500, - 77, - 815, - 816, - 817, - 812, - 813, - 367, - 784, - 785, - 786, - 236, - 496, - 828, - 122, - 801, - 802, - 803, - 774, - 772, - 773, - 936, - 787, - 788, - 789, - 808, - 809, - 97, - 1017, - 966, - 98, - 99, - 217, - 968, - 967, - 216, - 864, - 865, - 339, - 483, - 141, - 560, - 804, - 807, - 989, - 990, - 226, - 805, - 987, - 988, - 123, - 887, - 205, - 850, - 943, - 1083, - 140, - 353, - 489, - 151, - 256, - 1040, - 1041, - 144, - 110, - 255, - 945, - 484, - 485, - 124, - 970, - 612, - 125, - 980, - 589, - 590, - 591, - 592, - 819, - 820, - 821, - 822, - 288, - 10, - 979, - 471, - 472, - 473, - 475, - 253, - 488, - 888, - 889, - 886, - 166, - 880, - 165, - 376, - 885, - 900, - 100, - 870, - 871, - 924, - 940, - 925, - 958, - 960, - 957, - 959, - 565, - 382, - 200, - 335, - 491, - 328, - 840, - 466, - 912, - 913, - 298, - 297, - 109, - 377, - 1103, - 1104, - 588, - 155, - 451, - 594, - 595, - 239, - 1059, - 295, - 294, - 877, - 878, - 1102, - 1095, - 1094, - 337, - 1098, - 1099, - 1101, - 1100, - 842, - 777, - 59, - 431, - 604, - 603, - 673, - 672, - 670, - 671, - 736, - 12, - 517, - 296, - 697, - 698, - 668, - 669, - 584, - 585, - 586, - 587, - 11, - 486, - 159, - 101, - 487, - 386, - 385, - 875, - 876, - 135, - 901, - 902, - 214, - 189, - 142, - 1016, - 218, - 219, - 558, - 557, - 524, - 220, - 221, - 383, - 467, - 1112, - 65, - 1064, - 1065, - 246, - 452, - 862, - 863, - 235, - 810, - 941, - 942, - 64, - 446, - 265, - 266, - 783, - 247, - 157, - 174, - 162, - 334, - 793, - 158, - 5, - 306, - 754, - 1004, - 1005, - 129, - 881, - 882, - 631, - 213, - 1090, - 1091, - 928, - 929, - 930, - 60, - 175, - 131, - 1116, - 1117, - 1118, - 569, - 567, - 570, - 1072, - 1074, - 1071, - 303, - 1030, - 304, - 1031, - 632, - 935, - 965, - 470, - 160, - 1025, - 1026, - 307, - 61, - 1056, - 1057, - 1055, - 1058, - 56, - 287, - 58, - 818, - 657, - 687, - 688, - 161, - 798, - 685, - 686, - 379, - 380, - 676, - 677, - 2, - 734, - 674, - 675, - 666, - 667, - 281, - 282, - 1044, - 1045, - 501, - 502, - 1110, - 1111, - 453, - 338, - 605, - 606, - 607, - 608, - 972, - 971, - 250, - 1028, - 1043, - 1027, - 442, - 860, - 861, - 443, - 1053, - 1054, - 755, - 1049, - 1048, - 1050, - 229, - 173, - 494, - 627, - 628, - 630, - 879, - 305, - 759, - 626, - 455, - 469, - 139, - 952, - 506, - 248, - 1023, - 1024, - 518, - 188, - 969, - 482, - 481, - 164, - 890, - 355, - 289, - 760, - 761, - 762, - 234, - 633, - 583, - 249, - 561, - 914, - 937, - 938, - 939, - 183, - 132, - 1021, - 1022, - 883, - 884, - 133, - 177, - 1002, - 1003, - 176, - 130, - 252, - 866, - 1076, - 769, - 770, - 771, - 55, - 872, - 340, - 873, - 1051, - 1052, - 78, - 516, - 53, - 368, - 922, - 923, - 230, - 57, - 532, - 533, - 127, - 147, - 148, - 149, - 150, - 637, - 638, - 639, - 640, - 369, - 634, - 635, - 636, - 215, - 454, - 891, - 370, - 867, - 868, - 41, - 194, - 251, - 497, - 96, - 206, - 1070, - 228, - 707, - 662, - 663, - 622, - 623, - 624, - 625, - 618, - 619, - 620, - 621, - 614, - 615, - 616, - 617, - 1006, - 1007, - 853, - 1069, - 1068, - 854, - 852, - 851, - 763, - 73, - 72, - 71, - 1029, - 36, - 113, - 112, - 115, - 114, - 683, - 684, - 292, - 275, - 903, - 904, - 905, - 906, - 277, - 278, - 279, - 280, - 535, - 536, - 537, - 538, - 54, - 354, - 356, - 461, - 462, - 463, - 464, - 268, - 271, - 269, - 270, - 204, - 223, - 224, - 225, - 405, - 403, - 404, - 406, - 656, - 7, - 1096, - 1097, - 556, - 559, - 128, - 629, - 468, - 330, - 333, - 331, - 332, - 324, - 327, - 325, - 326, - 806, - 240, - 899, - 898, - 918, - 919, - 920, - 921, - 231, - 193, - 195, - 192, - 362, - 360, - 359, - 361, - 364, - 365, - 366, - 363, - 1012, - 1013, - 1014, - 1015, - 998, - 999, - 1008, - 1009, - 1011, - 1010, - 459, - 456, - 457, - 458, - 449, - 450, - 448, - 460, - 954, - 961, - 503, - 504, - 232, - 505, - 493, - 492, - 465, - 242, - 241, - 726, - 725, - 719, - 720, - 827, - 826, - 358, - 357, - 721, - 722, - 723, - 724, - 995, - 996, - 997, - 199, - 973, - 841, - 329, - 916, - 917, - 104, - 103, - 79, - 82, - 80, - 81, - 708, - 709, - 710, - 711, - 434, - 435, - 436, - 437, - 438, - 439, - 440, - 441, - 301, - 300, - 299, - 302, - 843, - 844, - 845, - 846, - 983, - 984, - 985, - 986, - 1106, - 1107, - 1108, - 1109, - 86, - 95, - 93, - 94, - 83, - 764, - 84, - 85, - 991, - 992, - 993, - 994, - 811, - 848, - 849, - 814, - 525, - 515, - 682, - 712, - 713, - 714, - 715, - 716, - 717, - 718, - 529, - 699, - 700, - 534, - 613, - 571, - 572, - 573, - 574, - 575, - 609, - 527, - 526, - 610, - 580, - 581, - 582, - 659, - 658, - 660, - 661, - 727, - 728, - 729, - 730, - 311, - 312, - 90, - 89, - 87, - 88, - 319, - 318, - 732, - 796, - 797, - 696, - 695, - 731, - 735, - 780, - 767, - 768, - 791, - 91, - 92, - 577, - 578, - 579, - 733, - 323, - 322, - 211, - 210, - 209, - 208, - 315, - 317, - 316, - 178, - 704, - 705, - 706, - 693, - 694, - 691, - 692, - 689, - 690, - 179, - 665, - 1062, - 1063, - 521, - 520, - 180, - 765, - 766, - 182, - 596, - 597, - 598, - 599, - 152, - 894, - 895, - 896, - 897, - 833, - 834, - 847, - 835, - 519, - 528, - 522, - 829, - 830, - 831, - 832, - 1020, - 1019, - 1018, - 22, - 21, - 20, - 18, - 17, - 19, - 67, - 70, - 309, - 310, - 66, - 291, - 308, - 34, - 33, - 373, - 374, - 371, - 372, - 31, - 30, - 29, - 1115, - 32, - 824, - 825, - 963, - 964, - 962, - 313, - 314, - 391, - 393, - 390, - 392, - 285, - 284, - 836, - 838, - 839, - 837, - 678, - 679, - 680, - 681, - 258, - 1000, - 1001, - 245, - 244, - 243, - 1113, - 1114, - 944, - 907, - 908, - 741, - 742, - 743, - 744, - 737, - 738, - 739, - 740, - 476, - 479, - 430, - 480, - 749, - 750, - 751, - 752, - 399, - 398, - 400, - 343, - 395, - 397, - 396, - 425, - 428, - 664, - 137, - 424, - 427, - 8, - 272, - 273, - 910, - 909, - 926, - 927, - 974, - 975, - 756, - 790, - 792, - 432, - 433, - 976, - 977, - 978, - 423, - 429, - 344, - 347, - 346, - 345, - 352, - 349, - 350, - 351, - 931, - 932, - 933, - 934, - 981, - 982, - 381, - 1084, - 1085, - 375, - 1066, - 1067, - 102, - 649, - 650, - 651, - 342, - 227, - 915, - 1087, - 1088, - 1089, - 1092, - 1093, - 611, - 757, - 758, - 568, - 1119, - 1120, - 1121, - 548, - 550, - 551, - 549, - 263, - 264, - 552, - 554, - 555, - 553, - 267, - 1042, - 238, - 652, - 653, - 654, - 655, - 855, - 856, - 857, - 858, - 507, - 510, - 509, - 508, - 511, - 514, - 513, - 512, - 498, - 499, - 48, - 190, - 531, - 402, - 955, - 956, - 1077, - 1078, - 257, - 426, - 202, - 1047, - 1046, - 1079, - 1080, - 541, - 543, - 544, - 542, - 121, - 951, - 953, - 753, - 120, - 947, - 949, - 950, - 948, - 348, - 869, - 545, - 547, - 546, - 911, - 946, - 1081, - 1082, - 641, - 642, - 643, - 644, - 645, - 646, - 647, - 648, - 9, - 1034, - 1036, - 1037, - 1035, - 745, - 746, - 747, - 748, - 1033, - 1038, - 1032, - 600, - 262, - 259, - 260, - 171, - 170, - 293, - 261, - 168, - 169, - 477, - 562, - 563, - 447, - 16, - 564, - 15, - 196, - 212, - 539, - 444, - 14, - 445, - 13 -] - -# with open('cams.json', 'w') as out: -# out.write('[') -# for id in ids: -# r = requests.get(f'https://images.drivebc.ca/webcam/api/v1/webcams/{id}') -# data = r.json() -# # if data['dbcMark'] != 'DriveBC.ca' or data['credit']: -# # pprint(f"{data['dbcMark']} {data['credit']}") -# # break -# out.write(json.dumps(data)) -# out.write(',') -# out.write(']') - -cams = json.load(open('cams.json')) -credits = [] -for cam in cams: - # if cam['dbcMark'] != 'DriveBC.ca' or cam['credit']: - # pprint({ - # 'id': cam['id'], - # 'dbcMark': cam['dbcMark'], - # 'credit': cam['credit'], - # }) - if cam['credit']: - credit = cam['credit'] - # credit = re.sub(NEWLINES, ' ', credit, re.M) - credit = re.sub(HTML, '', credit) - credit = credit.replace(' ', ' ') - if credit not in credits: - credits.append(credit) -for credit in credits: - print(credit) -