def test_routine_serialization(self): routine = Routine("My routine") task1 = Task("Task 1") task1.register_argument("arg1", arg_type.integer(minimum=0)) task2 = Task("Task 2") task2.register_argument("arg1", arg_type.choice("Yes", "No")) task2.register_argument("arg2", arg_type.integer(maximum=909)) routine.add_task(task1, {"arg1": 10}) routine.add_task(task2, {"arg1": "Yes", "arg2": 700}) serialized = serial.serialize_routine(routine) self.assertDictEqual( serialized, { "name": "My routine", "tasks": [{ "name": "Task 1", "values": { "arg1": 10 }, }, { "name": "Task 2", "values": { "arg1": "Yes", "arg2": 700 } }] })
def test_override_argument(self): arg_type_1 = {"type": "the argument type"} arg_type_2 = {"type": "an other argument type", "other": "value"} task = Task("o") task.register_argument("name", arg_type_1) task.register_argument("name", arg_type_2) self.assertEqual(len(task.arguments), 1) self.assertDictEqual(task.arguments["name"], arg_type_2)
def test_add_multiple_correct_arguments(self): arg_type_1 = {"type": "the argument type"} arg_type_2 = {"type": "an other argument type", "other": "value"} task = Task("a") self.assertEqual(len(task.arguments), 0) task.register_argument("firstArg", arg_type_1) self.assertEqual(len(task.arguments), 1) self.assertDictEqual(task.arguments["firstArg"], arg_type_1) task.register_argument("secondArg", arg_type_2) self.assertEqual(len(task.arguments), 2) self.assertDictEqual(task.arguments["secondArg"], arg_type_2)
def test_empty_name(self): with self.assertRaises(AssertionError): Task("")
def test_non_empty_name(self): task = Task("Test task") self.assertEqual(task.name, "Test task")
def test_add_malformed_argument(self): task = Task("a") with self.assertRaises(AssertionError): task.register_argument("arg1", {})
def setUp(self): self.manager = Manager() self.task = Task("the task") self.routine = Routine("the routine") self.card = Card("the card id", "the card name")
def test_override_task(self): other_task = Task("the task") self.manager.register_task(self.task) self.manager.register_task(other_task) self.assertEqual(len(self.manager.tasks), 1) self.assertIs(other_task, self.manager.tasks["the task"])
#from api.resources import Resource from api.task import Task from api.user import User #from api.advice import Advice import falcon def generic_error_handler(ex, req, resp, params): if isinstance(ex, falcon.HTTPNotFound): raise falcon.HTTPNotFound(description='Not Found') elif isinstance(ex, falcon.HTTPMethodNotAllowed): raise falcon.HTTPMethodNotAllowed(falcon.HTTP_405, description='Method Not Allowed') else: raise app = falcon.API( # middleware=[ # AuthMiddleware() # ] ) #app.add_route('/example', Resource()) app.add_route('/task',Task()) app.add_route('/user',User()) #app.add_route('/advice",Advice()) app.add_error_handler(Exception, generic_error_handler)
def setUp(self) -> None: self.manager = Manager() self.t = Task("a task") self.t.register_argument("first arg", string(min_length=4)) self.manager.register_task(self.t)
def setup(self): # 实例化接口,供case层使用 self.get_code = GetCode() self.login = LogIn() self.logout = LogOut() self.old_user_login = OldUserLogin() self.update_user_info = UpdateUserInfo() self.user_authorize = UserAuthorize() self.user_center = UserCenter() self.book_details = BookDetails() self.chapter = Chapter() self.last_chapter = LastChapter() self.recommended_books = RecommendedBooks() self.send_book = SendBook() self.shelf_clouds = ShelfClouds() self.recharge_list = RechargeList() self.order = Order() self.order_inform = OrderInform() self.recharge_record = RechargeRecord() self.spend_list = SpendList() self.add_desktop = AddDesktop() self.read_time = ReadTime() self.task = Task() self.read_begin = ReadBegin() self.chapter_pay = ChapterPay() self.prestrain = PresTrain() self.read_hold = ReadHold() self.app_start = AppStart() self.book_home = BookHome() self.cate_gory = CateGory() self.cate_gory_second = CateGorySecond() self.free = Free() self.free_second = FreeSecond() self.rank = Rank() self.push = Push() self.feedback = FeedBack() self.app_start_api = AppStartApi() self.front_error = FrontError() self.local_push = LocalPush() self.coupon = Coupon() self.get_coupon = GetCoupon() self.user_coupon = UserCoupon() self.position = Position() self.recharge_activity = RechargeActivity() self.sign = Sign() self.sign_in = SignIn() self.vip_activity = VipActivity() self.share_count = ShareCount() self.turntable_activity = TurntableActivity() self.get_turntable_activity = GetTruntableActivity() self.lottery = Lottery() self.manjian_activity = ManJianActivity() self.get_manjian_activity = GetManJianActivity() self.more_recharge_activity = MoreRechargeActivity() self.collect_cards = CollectCards() self.getcollect_cards = GetCollectCards() self.look = Look() self.play_up = PlayUp() self.search = Search() self.search_think = SearchThink() self.search_keywords = SearchKeyWords() self.user_system = UserSystem() self.user_system_rule = UserSystemRule() self.vivom_essage = VivoMessage() self.vivo_sub = VivoSub()