当前位置: 首页>>代码示例>>Python>>正文


Python Commons.load_time_delta方法代码示例

本文整理汇总了Python中inc.Commons.Commons.load_time_delta方法的典型用法代码示例。如果您正苦于以下问题:Python Commons.load_time_delta方法的具体用法?Python Commons.load_time_delta怎么用?Python Commons.load_time_delta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inc.Commons.Commons的用法示例。


在下文中一共展示了Commons.load_time_delta方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def run(self, line, user_obj, destination_obj):
     # See if last argument is check period.
     try:
         try_period = line.split()[-1]
         search_delta = Commons.load_time_delta(try_period)
         search = line[:-len(try_period)]
     except ISO8601ParseError:
         search = line
         search_delta = Commons.load_time_delta("PT300S")
     search = search.strip()
     # Get current RSS feed list
     function_dispatcher = user_obj.server.hallo.function_dispatcher
     sub_check_class = function_dispatcher.get_function_by_name("e621 sub check")
     sub_check_obj = function_dispatcher.get_function_object(sub_check_class)  # type: SubE621Check
     e621_sub_list = sub_check_obj.e621_sub_list  # type: E621SubList
     # Create new e621 search subscription
     e621_sub = E621Sub()
     e621_sub.server_name = user_obj.server.name
     e621_sub.search = search
     e621_sub.update_frequency = search_delta
     if destination_obj.is_channel():
         e621_sub.channel_name = destination_obj.name
     else:
         e621_sub.user_name = destination_obj.name
     # Update feed
     first_results = e621_sub.check_subscription()
     # If no results, this is an invalid search subscription
     if len(first_results) == 0:
         return "Error, this does not appear to be a valid search, or does not have results."
     # Add new rss feed to list
     e621_sub_list.add_sub(e621_sub)
     # Save list
     e621_sub_list.to_xml()
     # Return output
     return "I have added new e621 subscription for the search \"" + e621_sub.search + "\""
开发者ID:,项目名称:,代码行数:37,代码来源:

示例2: test_remove_no_match

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_remove_no_match(self):
     # Get subscription list
     e621_check_class = self.function_dispatcher.get_function_by_name("e621 sub check")
     e621_check_obj = self.function_dispatcher.get_function_object(e621_check_class)  # type: SubE621Check
     rfl = e621_check_obj.e621_sub_list
     # Add E621 searches to subscription list
     rf1 = E621Sub()
     rf1.search = "butt"
     rf1.server_name = self.server.name
     rf1.channel_name = self.test_chan.name
     rf1.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf1)
     rf2 = E621Sub()
     rf2.search = "deer"
     rf2.server_name = self.server.name
     rf2.channel_name = "another_channel"
     rf2.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf2)
     rf3 = E621Sub()
     rf3.search = "dragon"
     rf3.server_name = self.server.name
     rf3.channel_name = self.test_chan.name
     rf3.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf3)
     # Try to remove invalid search
     self.function_dispatcher.dispatch("e621 sub remove not_a_search", self.test_user, self.test_chan)
     data = self.server.get_send_data(1, self.test_chan, Server.MSG_MSG)
     assert "error" in data[0][0].lower()
     assert rf1 in rfl.sub_list
     assert rf2 in rfl.sub_list
     assert rf3 in rfl.sub_list
开发者ID:,项目名称:,代码行数:33,代码来源:

示例3: create_from_input

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def create_from_input(input_evt, sub_repo):
     # Get event data
     server = input_evt.server
     destination = input_evt.channel if input_evt.channel is not None else input_evt.user
     clean_text = input_evt.command_args.strip().lower()
     text_split = clean_text.split()
     # Subreddit regex
     sub_regex = re.compile(r"r/([^\s]*)/?")
     if len(text_split) == 1:
         sub_name = clean_text if sub_regex.search(clean_text) is None else sub_regex.search(clean_text).group(1)
         reddit_sub = RedditSub(server, destination, sub_name)
         reddit_sub.check()
         return reddit_sub
     if len(text_split) > 2:
         raise SubscriptionException("Too many arguments. Please give a subreddit, and optionally, a check period.")
     try:
         search_delta = Commons.load_time_delta(text_split[0])
         subreddit = text_split[1]
     except ISO8601ParseError:
         subreddit = text_split[0]
         search_delta = Commons.load_time_delta(text_split[1])
     sub_name = clean_text if sub_regex.search(subreddit) is None else sub_regex.search(subreddit).group(1)
     reddit_sub = RedditSub(server, destination, sub_name, update_frequency=search_delta)
     reddit_sub.check()
     return reddit_sub
开发者ID:joshcoales,项目名称:Hallo,代码行数:27,代码来源:Subscriptions.py

示例4: test_run_by_title

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_run_by_title(self):
     # Set up test servers and channels
     serv1 = ServerMock(self.hallo)
     serv1.name = "test_serv1"
     chan1 = serv1.get_channel_by_name("test_chan1")
     chan2 = serv1.get_channel_by_name("test_chan2")
     serv2 = ServerMock(self.hallo)
     serv2.name = "test_serv2"
     chan3 = serv2.get_channel_by_name("test_chan1")
     try:
         self.hallo.add_server(serv1)
         self.hallo.add_server(serv2)
         # Set up rss feeds
         rfl = RssFeedList()
         rf1 = RssFeed()
         rf1.url = "http://spangle.org.uk/hallo/test_rss.xml?1"
         rf1.title = "test_feed1"
         rf1.server_name = chan1.server.name
         rf1.channel_name = chan1.name
         rf1.update_frequency = Commons.load_time_delta("PT3600S")
         rfl.add_feed(rf1)
         rf2 = RssFeed()
         rf2.url = "http://spangle.org.uk/hallo/test_rss.xml?2"
         rf2.title = "test_feed2"
         rf2.server_name = chan2.server.name
         rf2.channel_name = chan2.name
         rf2.update_frequency = Commons.load_time_delta("PT3600S")
         rfl.add_feed(rf2)
         rf3 = RssFeed()
         rf3.url = "http://spangle.org.uk/hallo/test_rss.xml?3"
         rf3.title = "test_feed1"
         rf3.server_name = chan3.server.name
         rf3.channel_name = chan3.name
         rf3.update_frequency = Commons.load_time_delta("PT3600S")
         rfl.add_feed(rf3)
         # Splice this rss feed list into the function dispatcher's rss check object
         rss_check_class = self.function_dispatcher.get_function_by_name("rss check")
         rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: FeedCheck
         rss_check_obj.rss_feed_list = rfl
         # Invalid title
         self.function_dispatcher.dispatch("rss check Not a valid feed", self.test_user, self.test_chan)
         data = self.server.get_send_data(1, self.test_chan, Server.MSG_MSG)
         assert "error" in data[0][0].lower()
         # Correct title but wrong channel
         self.function_dispatcher.dispatch("rss check test_feed2", self.test_user, chan1)
         data = serv1.get_send_data(1, chan1, Server.MSG_MSG)
         assert "error" in data[0][0].lower()
         # Correct title check update
         self.function_dispatcher.dispatch("rss check test_feed2", self.test_user, chan2)
         data = serv1.get_send_data(1, chan2, Server.MSG_MSG)
         assert "feed updates were found" in data[0][0].lower()
         assert len(data[0][0].lower().split("\n")) == 4
         # No updates
         rf2.title = "test_feed2"
         self.function_dispatcher.dispatch("rss check test_feed2", self.test_user, chan2)
         data = serv1.get_send_data(1, chan2, Server.MSG_MSG)
         assert "no updates" in data[0][0], "No further updates should be found."
     finally:
         self.hallo.remove_server(serv2)
         self.hallo.remove_server(serv1)
开发者ID:,项目名称:,代码行数:62,代码来源:

示例5: test_remove_by_title

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_remove_by_title(self):
     another_chan = self.server.get_channel_by_address("another_channel")
     # Get feed list
     rss_check_class = self.function_dispatcher.get_function_by_name("check subscription")
     rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: SubscriptionCheck
     rfl = rss_check_obj.get_sub_repo(self.hallo)
     # Add RSS feeds to feed list
     rf1 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?1",
                  title="test_feed1", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf1)
     rf2 = RssSub(self.server, another_chan, "http://spangle.org.uk/hallo/test_rss.xml?2",
                  title="test_feed1", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf2)
     rf3 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?3",
                  title="test_feed3", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf3)
     # Remove test feed
     self.function_dispatcher.dispatch(EventMessage(self.server, self.test_chan, self.test_user,
                                                    "rss remove test_feed1"))
     data = self.server.get_send_data(1, self.test_chan, EventMessage)
     assert "removed rss subscription to test_feed1" in data[0].text.lower(), \
         "Response did not contain expected string. Response was: {}".format(data[0].text)
     assert rf1 not in rfl.sub_list
     assert rf2 in rfl.sub_list
     assert rf3 in rfl.sub_list
开发者ID:joshcoales,项目名称:Hallo,代码行数:27,代码来源:testSubscriptionRemoveRss.py

示例6: test_remove_multiple_matching_titles

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_remove_multiple_matching_titles(self):
     # Get feed list
     rss_check_class = self.function_dispatcher.get_function_by_name("rss check")
     rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: FeedCheck
     rfl = rss_check_obj.rss_feed_list
     # Add RSS feeds to feed list
     rf1 = RssFeed()
     rf1.url = "http://spangle.org.uk/hallo/test_rss.xml?1"
     rf1.title = "test_feed1"
     rf1.server_name = self.server.name
     rf1.channel_name = self.test_chan.name
     rf1.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_feed(rf1)
     rf2 = RssFeed()
     rf2.url = "http://spangle.org.uk/hallo/test_rss.xml?2"
     rf2.title = "test_feed1"
     rf2.server_name = self.server.name
     rf2.channel_name = "another_channel"
     rf2.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_feed(rf2)
     rf3 = RssFeed()
     rf3.url = "http://spangle.org.uk/hallo/test_rss.xml?3"
     rf3.title = "test_feed1"
     rf3.server_name = self.server.name
     rf3.channel_name = self.test_chan.name
     rf3.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_feed(rf3)
     # Remove test feed
     self.function_dispatcher.dispatch("rss remove test_feed1", self.test_user, self.test_chan)
     data = self.server.get_send_data(1, self.test_chan, Server.MSG_MSG)
     assert "error" in data[0][0].lower()
     assert rf1 in rfl.feed_list
     assert rf2 in rfl.feed_list
     assert rf3 in rfl.feed_list
开发者ID:,项目名称:,代码行数:36,代码来源:

示例7: test_list_feeds

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_list_feeds(self):
     another_chan = self.server.get_channel_by_address("another_channel")
     # Get feed list
     rss_check_class = self.function_dispatcher.get_function_by_name("check subscription")
     rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: SubscriptionCheck
     rfl = rss_check_obj.get_sub_repo(self.hallo)
     # Add RSS feeds to feed list
     rf1 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?1",
                  title="test_feed1", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf1)
     rf2 = RssSub(self.server, another_chan, "http://spangle.org.uk/hallo/test_rss.xml?2",
                  title="test_feed2", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf2)
     rf3 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?3",
                  title="test_feed3", update_frequency=Commons.load_time_delta("PT3600S"))
     rfl.add_sub(rf3)
     # Run FeedList and check output
     self.function_dispatcher.dispatch(EventMessage(self.server, self.test_chan, self.test_user, "rss list"))
     data = self.server.get_send_data(1, self.test_chan, EventMessage)
     data_split = data[0].text.split("\n")
     assert "subscriptions posting" in data_split[0].lower(), "Actual message: {}".format(data[0].text)
     assert "test_feed1" in data_split[1].lower() or "test_feed1" in data_split[2].lower()
     assert "test_feed3" in data_split[1].lower() or "test_feed3" in data_split[2].lower()
     assert "http://spangle.org.uk/hallo/test_rss.xml?1" in data_split[1].lower() or \
            "http://spangle.org.uk/hallo/test_rss.xml?1" in data_split[2].lower()
     assert "http://spangle.org.uk/hallo/test_rss.xml?3" in data_split[1].lower() or \
            "http://spangle.org.uk/hallo/test_rss.xml?3" in data_split[2].lower()
     assert "test_feed2" not in data_split[1].lower() and "test_feed2" not in data_split[2].lower()
     assert "http://spangle.org.uk/hallo/test_rss.xml?2" not in data_split[1].lower() and \
            "http://spangle.org.uk/hallo/test_rss.xml?2" not in data_split[2].lower()
开发者ID:joshcoales,项目名称:Hallo,代码行数:32,代码来源:testSubscriptionListRss.py

示例8: test_xml

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_xml(self):
     # Setup a feed list
     rfl = SubscriptionRepo()
     rf1 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?1",
                  title="test_feed1", update_frequency=Commons.load_time_delta("P0T3600S"))
     rfl.add_sub(rf1)
     rf2 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?2",
                  title="test_feed2", update_frequency=Commons.load_time_delta("P1TS"))
     rfl.add_sub(rf2)
     rf3 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml?3",
                  title="test_feed3", update_frequency=Commons.load_time_delta("PT60S"))
     rfl.add_sub(rf3)
     # Save to XML and load
     try:
         try:
             os.rename("store/subscriptions.json", "store/subscriptions.json.tmp")
         except OSError:
             pass
         rfl.save_json()
         new_rfl = SubscriptionRepo.load_json(self.hallo)
         assert len(new_rfl.sub_list) == 3
     finally:
         try:
             os.remove("store/subscriptions.json")
         except OSError:
             pass
         try:
             os.rename("store/subscriptions.json.tmp", "store/subscriptions.json")
         except OSError:
             pass
开发者ID:joshcoales,项目名称:Hallo,代码行数:32,代码来源:testSubscriptionRepo.py

示例9: test_list_feeds

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_list_feeds(self):
     # Get feed list
     rss_check_class = self.function_dispatcher.get_function_by_name("e621 sub check")
     rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: SubE621Check
     rfl = rss_check_obj.e621_sub_list
     # Add RSS feeds to feed list
     rf1 = E621Sub()
     rf1.search = "butt"
     rf1.server_name = self.server.name
     rf1.channel_name = self.test_chan.name
     rf1.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf1)
     rf2 = E621Sub()
     rf2.search = "deer"
     rf2.server_name = self.server.name
     rf2.channel_name = "another_channel"
     rf2.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf2)
     rf3 = E621Sub()
     rf3.search = "dragon"
     rf3.server_name = self.server.name
     rf3.channel_name = self.test_chan.name
     rf3.update_frequency = Commons.load_time_delta("PT3600S")
     rfl.add_sub(rf3)
     # Run FeedList and check output
     self.function_dispatcher.dispatch("e621 sub list", self.test_user, self.test_chan)
     data = self.server.get_send_data(1, self.test_chan, Server.MSG_MSG)
     data_split = data[0][0].split("\n")
     assert "e621 search subscriptions posting" in data_split[0].lower()
     assert "butt" in data_split[1].lower() or "butt" in data_split[2].lower()
     assert "deer" not in data_split[1].lower() and "deer" not in data_split[2].lower()
     assert "dragon" in data_split[1].lower() or "dragon" in data_split[2].lower()
开发者ID:,项目名称:,代码行数:34,代码来源:

示例10: test_run_by_search

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_run_by_search(self):
     # Set up test servers and channels
     serv1 = ServerMock(self.hallo)
     serv1.name = "test_serv1"
     chan1 = serv1.get_channel_by_name("test_chan1")
     chan2 = serv1.get_channel_by_name("test_chan2")
     serv2 = ServerMock(self.hallo)
     serv2.name = "test_serv2"
     chan3 = serv2.get_channel_by_name("test_chan1")
     try:
         self.hallo.add_server(serv1)
         self.hallo.add_server(serv2)
         # Set up rss feeds
         rfl = E621SubList()
         rf1 = E621Sub()
         rf1.search = "butt"
         rf1.server_name = chan1.server.name
         rf1.channel_name = chan1.name
         rf1.update_frequency = Commons.load_time_delta("PT3600S")
         rfl.add_sub(rf1)
         rf2 = E621Sub()
         rf2.search = "deer"
         rf2.server_name = chan2.server.name
         rf2.channel_name = chan2.name
         rf2.update_frequency = Commons.load_time_delta("PT3600S")
         rfl.add_sub(rf2)
         rf3 = E621Sub()
         rf3.search = "dragon"
         rf3.server_name = chan3.server.name
         rf3.channel_name = chan3.name
         rf3.update_frequency = Commons.load_time_delta("PT3600S")
         rfl.add_sub(rf3)
         # Splice this rss feed list into the function dispatcher's rss check object
         rss_check_class = self.function_dispatcher.get_function_by_name("e621 sub check")
         rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: SubE621Check
         rss_check_obj.e621_sub_list = rfl
         # Invalid title
         self.function_dispatcher.dispatch("e621 sub check Not a valid search", self.test_user, self.test_chan)
         data = self.server.get_send_data(1, self.test_chan, Server.MSG_MSG)
         assert "error" in data[0][0].lower()
         # Correct title but wrong channel
         self.function_dispatcher.dispatch("e621 sub check deer", self.test_user, chan1)
         data = serv1.get_send_data(1, chan1, Server.MSG_MSG)
         assert "error" in data[0][0].lower()
         # Correct title check update
         self.function_dispatcher.dispatch("e621 sub check deer", self.test_user, chan2)
         data = serv1.get_send_data(1, chan2, Server.MSG_MSG)
         assert "search updates were found" in data[0][0].lower()
         assert len(data[0][0].lower().split("\n")) == 51
         # No updates
         self.function_dispatcher.dispatch("e621 sub check deer", self.test_user, chan2)
         data = serv1.get_send_data(1, chan2, Server.MSG_MSG)
         assert "no updates" in data[0][0], "No further updates should be found."
     finally:
         self.hallo.remove_server(serv2)
         self.hallo.remove_server(serv1)
开发者ID:,项目名称:,代码行数:58,代码来源:

示例11: test_load_time_delta

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_load_time_delta(self):
     string1 = "20S"
     try:
         Commons.load_time_delta(string1)
         assert False, "String 1 should have failed to parse."
     except ISO8601ParseError:
         pass
     string2 = "P20"
     try:
         Commons.load_time_delta(string2)
         assert False, "String 2 should have failed to parse."
     except ISO8601ParseError:
         pass
     string3 = "P20S"
     try:
         Commons.load_time_delta(string3)
         assert False, "String 3 should have failed to parse."
     except ISO8601ParseError:
         pass
     string4 = "PTS"
     delta4 = Commons.load_time_delta(string4)
     assert delta4.seconds == 0, "delta4 seconds set incorrectly."
     assert delta4.days == 0, "delta4 days set incorrectly."
     string5 = "P1T1S"
     delta5 = Commons.load_time_delta(string5)
     assert delta5.seconds == 1, "delta5 seconds set incorrectly."
     assert delta5.days == 1, "delta5 days set incorrectly."
     string6 = "P10T3600S"
     delta6 = Commons.load_time_delta(string6)
     assert delta6.seconds == 3600, "delta6 seconds set incorrectly."
     assert delta6.days == 10, "delta6 days set incorrectly."
开发者ID:,项目名称:,代码行数:33,代码来源:

示例12: test_run_all

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_run_all(self):
     # Set up test servers and channels
     serv1 = ServerMock(self.hallo)
     serv1.name = "test_serv1"
     chan1 = serv1.get_channel_by_address("test_chan1".lower(), "test_chan1")
     chan2 = serv1.get_channel_by_address("test_chan2".lower(), "test_chan2")
     serv2 = ServerMock(self.hallo)
     serv2.name = "test_serv2"
     chan3 = serv2.get_channel_by_address("test_chan1".lower(), "test_chan1")
     try:
         self.hallo.add_server(serv1)
         self.hallo.add_server(serv2)
         # Set up rss feeds
         rfl = SubscriptionRepo()
         rf1 = RssSub(chan1.server, chan1, "http://spangle.org.uk/hallo/test_rss.xml?1",
                      title="test_feed1", update_frequency=Commons.load_time_delta("PT3600S"))
         rfl.add_sub(rf1)
         rf2 = RssSub(chan2.server, chan2, "http://spangle.org.uk/hallo/test_rss.xml?2",
                      title="test_feed2", update_frequency=Commons.load_time_delta("PT3600S"))
         rfl.add_sub(rf2)
         rf3 = RssSub(chan3.server, chan3, "http://spangle.org.uk/hallo/test_rss.xml?3",
                      title="test_feed1", update_frequency=Commons.load_time_delta("PT3600S"))
         rfl.add_sub(rf3)
         # Splice this rss feed list into the function dispatcher's rss check object
         rss_check_class = self.function_dispatcher.get_function_by_name("check subscription")
         rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: SubscriptionCheck
         rss_check_obj.subscription_repo = rfl
         # Test running all feed updates
         self.function_dispatcher.dispatch(EventMessage(self.server, self.test_chan, self.test_user,
                                                        "rss check all"))
         # Check original calling channel data
         serv0_data = self.server.get_send_data(1, self.test_chan, EventMessage)
         assert "subscription updates were found" in serv0_data[0].text
         # Check test server 1 data
         serv1_data = serv1.get_send_data(6)
         chan1_count = 0
         chan2_count = 0
         for data_line in serv1_data:
             if data_line.channel == chan1:
                 chan1_count += 1
             if data_line.channel == chan2:
                 chan2_count += 1
         assert chan1_count == 3
         assert chan2_count == 3
         # Check test server 2 data
         serv2.get_send_data(3, chan3, EventMessage)
         # Test running with no new updates.
         self.function_dispatcher.dispatch(EventMessage(self.server, self.test_chan, self.test_user,
                                                        "rss check all"))
         data = self.server.get_send_data(1, self.test_chan, EventMessage)
         assert "no updates" in data[0].text, "No further updates should be found."
     finally:
         self.hallo.remove_server(serv2)
         self.hallo.remove_server(serv1)
开发者ID:joshcoales,项目名称:Hallo,代码行数:56,代码来源:testSubscriptionCheckRss.py

示例13: test_run_by_title

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_run_by_title(self):
     # Set up test servers and channels
     serv1 = ServerMock(self.hallo)
     serv1.name = "test_serv1"
     chan1 = serv1.get_channel_by_address("test_chan1")
     chan2 = serv1.get_channel_by_address("test_chan2")
     user1 = serv1.get_user_by_address("test_user1")
     serv2 = ServerMock(self.hallo)
     serv2.name = "test_serv2"
     chan3 = serv2.get_channel_by_address("test_chan1")
     try:
         self.hallo.add_server(serv1)
         self.hallo.add_server(serv2)
         # Set up rss feeds
         rfl = SubscriptionRepo()
         rf1 = RssSub(chan1.server, chan1, "http://spangle.org.uk/hallo/test_rss.xml?1",
                      title="test_feed1", update_frequency=Commons.load_time_delta("PT3600S"))
         rfl.add_sub(rf1)
         rf2 = RssSub(chan2.server, chan2, "http://spangle.org.uk/hallo/test_rss.xml?2",
                      title="test_feed2", update_frequency=Commons.load_time_delta("PT3600S"))
         rfl.add_sub(rf2)
         rf3 = RssSub(chan3.server, chan3, "http://spangle.org.uk/hallo/test_rss.xml?3",
                      title="test_feed1", update_frequency=Commons.load_time_delta("PT3600S"))
         rfl.add_sub(rf3)
         # Splice this rss feed list into the function dispatcher's rss check object
         rss_check_class = self.function_dispatcher.get_function_by_name("check subscription")
         rss_check_obj = self.function_dispatcher.get_function_object(rss_check_class)  # type: SubscriptionCheck
         rss_check_obj.subscription_repo = rfl
         # Invalid title
         self.function_dispatcher.dispatch(EventMessage(self.server, self.test_chan, self.test_user,
                                                        "rss check Not a valid feed"))
         data = self.server.get_send_data(1, self.test_chan, EventMessage)
         assert "error" in data[0].text.lower()
         # Correct title but wrong channel
         self.function_dispatcher.dispatch(EventMessage(serv1, chan1, user1, "rss check test_feed2"))
         data = serv1.get_send_data(1, chan1, EventMessage)
         assert "error" in data[0].text.lower()
         # Correct title check update
         self.function_dispatcher.dispatch(EventMessage(serv1, chan2, user1, "rss check test_feed2"))
         data = serv1.get_send_data(4, chan2, EventMessage)
         for x in range(3):
             assert "update on" in data[x].text.lower()
             assert "rss feed" in data[x].text.lower()
         assert "updates were found" in data[3].text.lower(), "Actual message: {}".format(data[0].text)
         # No updates
         rf2.title = "test_feed2"
         self.function_dispatcher.dispatch(EventMessage(serv1, chan2, user1, "rss check test_feed2"))
         data = serv1.get_send_data(1, chan2, EventMessage)
         assert "no updates" in data[0].text, "No further updates should be found."
     finally:
         self.hallo.remove_server(serv2)
         self.hallo.remove_server(serv1)
开发者ID:joshcoales,项目名称:Hallo,代码行数:54,代码来源:testSubscriptionCheckRss.py

示例14: test_needs_check

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_needs_check(self):
     rf1 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml",
                  last_check=datetime.now(), update_frequency=Commons.load_time_delta("P1TS"))
     assert not rf1.needs_check()
     rf1.last_check = datetime.now() - Commons.load_time_delta("P2TS")
     assert rf1.needs_check()
     rf1.update_frequency = Commons.load_time_delta("P7TS")
     assert not rf1.needs_check()
     rf2 = RssSub(self.server, self.test_chan, "http://spangle.org.uk/hallo/test_rss.xml",
                  last_check=datetime.now(), update_frequency=Commons.load_time_delta("PT5S"))
     assert not rf2.needs_check()
     time.sleep(10)
     assert rf2.needs_check()
开发者ID:joshcoales,项目名称:Hallo,代码行数:15,代码来源:testRssSub.py

示例15: test_needs_check

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import load_time_delta [as 别名]
 def test_needs_check(self):
     rf1 = E621Sub()
     rf1.last_check = datetime.now()
     rf1.update_frequency = Commons.load_time_delta("P1TS")
     assert not rf1.needs_check()
     rf1.last_check = datetime.now() - Commons.load_time_delta("P2TS")
     assert rf1.needs_check()
     rf1.update_frequency = Commons.load_time_delta("P7TS")
     assert not rf1.needs_check()
     rf2 = E621Sub()
     rf2.last_check = datetime.now()
     rf2.update_frequency = Commons.load_time_delta("PT5S")
     assert not rf2.needs_check()
     time.sleep(10)
     assert rf2.needs_check()
开发者ID:,项目名称:,代码行数:17,代码来源:


注:本文中的inc.Commons.Commons.load_time_delta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。