def make_article(new_article_date):
    article = Article(
        new_article_date,
        'Coronavirus travel restrictions: Self-isolation deadline pushed back to give airlines breathing room',
        'The self-isolation deadline has been pushed back',
        'https://www.nzherald.co.nz/business/news/article.cfm?c_id=3&objectid=12316800',
        'https://th.bing.com/th/id/OIP.0lCxLKfDnOyswQCF9rcv7AHaCz?w=344&h=132&c=7&o=5&pid=1.7'
    )
    return article
def article():
    return Article(
        'Guardians of the Galaxy',
        '2014',
        '8.1',
        '757074',
        '333.13',
        '76',
    )
def test_article_less_than_operator():
    article_1 = Article(
        'Guardians of the Galaxy',
        '2014',
        '8.1',
        '757074',
        '333.13',
        '76',
    )

    article_2 = Article(
        'Guardians of the Galaxy',
        '2017',
        '8.1',
        '757074',
        '333.13',
        '76',
    )
    assert article_1 < article_2
Exemple #4
0
def test_loading_of_article(empty_session):
    article_key = insert_article(empty_session)
    expected_article = Article(
        "Passengers", "Adventure,Drama,Romance",
        "A spacecraft traveling to a distant colony planet and transporting thousands of people has a malfunction in its sleep chambers. As a result, two passengers are awakened 90 years early.",
        "Morten Tyldum",
        "Jennifer Lawrence, Chris Pratt, Michael Sheen,Laurence Fishburne",
        "2016")
    fetched_article = empty_session.query(Article).filter(
        Article.id == 10).one()

    assert article_key == fetched_article.id
Exemple #5
0
def make_article():
    article = Article('Movie', '2013', '10', '23434', '32', '8.8')
    article.title = 'Movie'
    article.runtime = 50
    article.description = "In a world"
    article.genres = "Comedy, Horror"
    article.director = "Mr Man"
    article.actors = "Actor 1, Actor 2"
    article.release_year = 2013
    article.rating = 4
    article.votes = 23434
    article.revenue = 32
    article.metascore = 8.8

    return article
def test_repository_can_add_article(session_factory):
    repo = SqlAlchemyRepository(session_factory)

    number_of_articles = repo.get_number_of_articles()

    new_article_id = number_of_articles + 1

    article = Article('Movie', '2013', '10', '23434', '32', '8.8')
    article.title = 'Movie'
    article.runtime = 50
    article.description = "In a world"
    article.genres = "Comedy, Horror"
    article.director = "Mr Man"
    article.actors = "Actor 1, Actor 2"
    article.release_year = 2013
    article.rating = 4
    article.votes = 23434
    article.revenue = 32
    article.metascore = 8.8
    repo.add_article(article)

    assert repo.get_article(new_article_id) == article
Exemple #7
0
def dict_to_article(dict):
    article = Article(dict['title'], dict['release_year'], dict['rating'],
                      dict['votes'], dict['revenue'], dict['metascore'])
    # Note there's no comments or tags.
    return article