-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zeeland
committed
Nov 20, 2022
1 parent
6158480
commit 97f1b83
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
# @Time : 2022/11/20 09:24 | ||
# @Author : Zeeland | ||
# @File : func_test.py | ||
# @Software: PyCharm | ||
|
||
from broadcast_service import broadcast_service | ||
import time | ||
|
||
position = ['home', 'company'] | ||
|
||
class Leader: | ||
def __init__(self, name): | ||
self.current_position = position[1] | ||
self.name = name | ||
|
||
def notice_meeting(self): | ||
print('[leader] {0} notice meeting now.'.format(self.name)) | ||
meeting_info = 'our company will go bankrupt soon' | ||
broadcast_service.broadcast('meeting', meeting_info) | ||
|
||
class Staff: | ||
def __init__(self, name): | ||
self.current_position = position[0] | ||
self.name = name | ||
self.rec_msg() | ||
|
||
def rec_msg(self): | ||
broadcast_service.listen('meeting', self.go_meeting) | ||
|
||
def go_meeting(self, info): | ||
if self.current_position == position[0]: | ||
self.current_position = position[1] | ||
print('[staff] {0} go meeting now.'.format(self.name)) | ||
time.sleep(1) | ||
print('[staff] {0} rec msg: {1}'.format(self.name, info)) | ||
|
||
class FuncTest: | ||
def run(self): | ||
self.init_test() | ||
self.go_meeting_test() | ||
|
||
def init_test(self): | ||
self.leader = Leader('Tom') | ||
self.staff1 = Staff('Jack') | ||
self.staff2 = Staff('Jasmine') | ||
self.staff3 = Staff('Jane') | ||
|
||
def go_meeting_test(self): | ||
self.leader.notice_meeting() | ||
|
||
if __name__ == '__main__': | ||
app = FuncTest() | ||
app.run() |