Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove filter for news articles and add delete functionality to manager/worker architecture #29

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove outdated test
adeveloper-wq committed Aug 6, 2024
commit 6973955e2b785ab922ce4c4e6720bdf82ec569a5
38 changes: 1 addition & 37 deletions backend/news/tests/test_article.py
Original file line number Diff line number Diff line change
@@ -81,42 +81,6 @@ def test_only_return_news_articles_that_are_not_in_future(self):
response = self.client.get(get_news_articles_relative_url())
self.assertEqual(len(response.json()), 2)

def test_only_return_news_articles_up_to_specific_date(self):
""" Test whether only articles with a release date newer like given date get returned. """

# Article 1:
pub_date = timezone.now()- timedelta(days=1)
article1 = create_category_and_article(article_title=self.article_titles[0], article_text=self.article_texts[0], category_title=self.category_names[0], pub_date=pub_date)

# Article 2:
pub_date = timezone.now() - timedelta(days=3)
article2 = create_category_and_article(article_title=self.article_titles[1], article_text=self.article_texts[1], category_title=self.category_names[1], pub_date=pub_date)

# Article 3:
pub_date = timezone.now() - timedelta(days=4)
create_category_and_article(article_title=self.article_titles[2], article_text=self.article_texts[2], category_title=self.category_names[2], pub_date=pub_date)
test_date = pub_date
# Article 4:
pub_date = timezone.now() - timedelta(days=5)
create_category_and_article(article_title=self.article_titles[3], article_text=self.article_texts[3], category_title=self.category_names[3], pub_date=pub_date)

# Create hash for the articles that got released before or on the test_date
articles = [article1, article2]
articles_serialized = [serialize_article_to_dict(article) for article in articles]

# Get articles:
base_url = get_news_articles_relative_url()
response = self.client.get('{base_url}?{querystring}'.format(base_url=base_url, querystring=urlencode({'from': f'{test_date.strftime("%Y-%m-%dT%H:%M:%S.%f")}Z'})))

self.assertEqual(response.json(), articles_serialized)

# Get articles:
test_date = timezone.now() - timedelta(days=4)
base_url = get_news_articles_relative_url()
response = self.client.get('{base_url}?{querystring}'.format(base_url=base_url, querystring=urlencode({'from': f'{test_date.strftime("%Y-%m-%dT%H:%M:%S.%f")}Z'})))

self.assertEqual(response.json(), articles_serialized)

def test_sql_injection_attack(self):
""" Test whether sql injections don't have any impact. """
days_in_past = [1,3,4,5]
@@ -137,4 +101,4 @@ def test_sql_injection_attack(self):

# Check that four articles get returned
response = self.client.get(get_news_articles_relative_url())
self.assertEqual(len(response.json()), 4)
self.assertEqual(len(response.json()), 4)