Ejemplo n.º 1
0
 def db2_add_one_filter_news(news_date, news_title, news_summary,
                             news_topic_id, news_url, image_rul):
     if len(news_summary) < 200:
         return None
     if len(image_rul) < 3:
         return None
     flag = -1
     topic = Topics_model.db_get_one_topic_by_id(news_topic_id)
     if topic is not None:
         news = News_model.db_insert_one_news(news_title, news_date,
                                              news_summary, news_url, topic,
                                              image_rul)
         if news is not None:
             flag = 1
             topic.latest_filter_time = timezone.now()
             topic2 = Topics_model.db_update_one_topic(topic)
     else:
         news = None
         topic = None
     return flag, news, topic
Ejemplo n.º 2
0
name = "Technology"
topic = Topics_model.db_get_one_topic_by_name(name)
print(topic)

# test 7 -- test 4.1.2.4
# Test Name: successfully update
# Expect Output: topic's name
print("\ntest 7 -- test 4.1.2.4")
print("Test Name : successfully update")
print("Expect Output: topic's name-- Presentent Putin")
print("Actual Output:")
c_date = datetime.datetime.now()
name = "Presentent Putin"
topic = Topics_model.db_get_one_topic_by_name(name)
topic.latest_news_date = c_date
topic = Topics_model.db_update_one_topic(topic)
print(topic)

# test 8 -- test 4.1.2.4
# Test Name: update failed
# Expect Output: None
print("\ntest 8 -- test 4.1.2.4")
print("Test Name : update failed")
print("Expect Output: None")
print("Actual Output")
topic = Topics_model.db_update_one_topic("")
print(topic)

# test for news model
# test 9 -- test 4.1.3.1
# Test Name: insert new news