Example #1
0
def generate_news(topic):
    topic_obj = Topics_model.db_get_one_topic_by_name(topic)
    news_date = timezone.now()
    news_url = "https://www.google.ie/"
    img_url = "http://lorempixel.com/400/250/"
    if topic_obj is not None:
        for i in range(3):
            news_title = topic + " - news - " + str(i)
            summary = topic + " - news summary - " + str(i)
            News_model.db_insert_one_news(news_title, news_date, summary,
                                          news_url, topic_obj, img_url)


for name in topic_name:
    Topics_model.db_insert_one_topic(name)
    generate_news(name)


def generate_ori_news(topic):
    topic_obj = Topics_model.db_get_one_topic_by_name(topic)
    current_date = timezone.now()
    news_url = "https://www.google.ie/"
    img_url = "http://lorempixel.com/400/250/"
    if topic_obj is not None:
        for day in range(1, 5):
            news_date = current_date - timedelta(days=day)
            for i in range(randint(0, 6)):
                news_title = topic + " - day - " + str(
                    day) + " - news - " + str(i)
                summary = topic + " - day - " + str(
Example #2
0
import django

django.setup()
import datetime
# inmport models from your model application
from dataCollector.models import Topics_model, News_model, Medium_model
from dataCollector.model_interfaces import Model_Interfaces

# test for Topic_model
# test 1 -- test 4.1.2.1
# Test Name: Insert one new topic
# Expect Output: topic's str
print("\ntest 1 -- test 4.1.2.1")
print("Test Name: Insert one new topic")
print("Expect Output: topic's id, name, date")
topic = Topics_model.db_insert_one_topic("Technology")
temp_id = topic.id
temp_name = topic.topic_name
print("Actual Output:")
print(topic.id)
print(topic.topic_name)
print(topic.create_date)
topic.delete()

Topics_model.db_insert_one_topic("Science")
Topics_model.db_insert_one_topic("Mathematic")
Topics_model.db_insert_one_topic("Trump election")
Topics_model.db_insert_one_topic("Presentent Putin")
Topics_model.db_insert_one_topic("ISIS")
Topics_model.db_insert_one_topic("Sourth China Sea")
Topics_model.db_insert_one_topic("North Korea Nuclear Weapon")