mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
build WIP tests for duplicate_feeds
This commit is contained in:
parent
546c95a54f
commit
c636a78b10
3 changed files with 40 additions and 92 deletions
|
@ -1,58 +0,0 @@
|
||||||
[{
|
|
||||||
"pk": 1,
|
|
||||||
"premium_subscribers": 0,
|
|
||||||
"creation": "2011-07-18",
|
|
||||||
"exception_code": 500,
|
|
||||||
"last_load_time": 1,
|
|
||||||
"active_subscribers": 1,
|
|
||||||
"feed_address": "http://blog.newsblur.com/rss",
|
|
||||||
"feed_link": "http://blog.newsblur.com/",
|
|
||||||
"last_update": "2011-07-18 04:27:26",
|
|
||||||
"etag": "",
|
|
||||||
"average_stories_per_month": 0,
|
|
||||||
"hash_address_and_link": "17",
|
|
||||||
"feed_title": "The NewsBlur Blog",
|
|
||||||
"last_modified": null,
|
|
||||||
"next_scheduled_update": "2011-07-18 16:43:25",
|
|
||||||
"favicon_color": "de9b3c",
|
|
||||||
"stories_last_month": 0,
|
|
||||||
"active": true,
|
|
||||||
"favicon_not_found": false,
|
|
||||||
"has_page_exception": false,
|
|
||||||
"fetched_once": true,
|
|
||||||
"days_to_trim": 90,
|
|
||||||
"num_subscribers": 1,
|
|
||||||
"last_story_date": "2011-07-18 04:10:01",
|
|
||||||
"min_to_decay": 720,
|
|
||||||
"has_feed_exception": false
|
|
||||||
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pk": 2,
|
|
||||||
"premium_subscribers": 0,
|
|
||||||
"creation": "2011-07-18",
|
|
||||||
"exception_code": 500,
|
|
||||||
"last_load_time": 1,
|
|
||||||
"active_subscribers": 1,
|
|
||||||
"feed_address": "https://blog.newsblur.com/rss",
|
|
||||||
"feed_link": "https://blog.newsblur.com/",
|
|
||||||
"last_update": "2011-07-18 04:27:26",
|
|
||||||
"etag": "",
|
|
||||||
"average_stories_per_month": 0,
|
|
||||||
"hash_address_and_link": "18",
|
|
||||||
"feed_title": "The NewsBlur Blog",
|
|
||||||
"last_modified": null,
|
|
||||||
"next_scheduled_update": "2011-07-18 16:43:25",
|
|
||||||
"favicon_color": "de9b3c",
|
|
||||||
"stories_last_month": 0,
|
|
||||||
"active": true,
|
|
||||||
"favicon_not_found": false,
|
|
||||||
"has_page_exception": false,
|
|
||||||
"fetched_once": true,
|
|
||||||
"days_to_trim": 90,
|
|
||||||
"num_subscribers": 1,
|
|
||||||
"last_story_date": "2011-07-18 04:10:01",
|
|
||||||
"min_to_decay": 720,
|
|
||||||
"has_feed_exception": false
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -1,28 +0,0 @@
|
||||||
[{
|
|
||||||
"pk": 1,
|
|
||||||
"model": "reader.usersubscription",
|
|
||||||
"fields": {
|
|
||||||
"feed": 1,
|
|
||||||
"unread_count_updated": "2009-08-01 00:23:42",
|
|
||||||
"mark_read_date": "2009-07-28 23:17:27",
|
|
||||||
"unread_count_neutral": 0,
|
|
||||||
"unread_count_positive": 0,
|
|
||||||
"unread_count_negative": 0,
|
|
||||||
"user": 1,
|
|
||||||
"last_read_date": "2009-07-28 23:17:27"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pk": 2,
|
|
||||||
"model": "reader.usersubscription",
|
|
||||||
"fields": {
|
|
||||||
"feed": 2,
|
|
||||||
"unread_count_updated": "2009-08-01 00:23:42",
|
|
||||||
"mark_read_date": "2009-07-28 23:17:27",
|
|
||||||
"unread_count_neutral": 0,
|
|
||||||
"unread_count_positive": 0,
|
|
||||||
"unread_count_negative": 0,
|
|
||||||
"user": 2,
|
|
||||||
"last_read_date": "2009-07-28 23:17:27"
|
|
||||||
}
|
|
||||||
}]
|
|
|
@ -4,10 +4,15 @@ from django.test import TestCase
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from apps.reader.models import UserSubscription, UserSubscriptionFolders
|
from apps.reader.models import UserSubscription, UserSubscriptionFolders
|
||||||
from utils import json_functions as json
|
from apps.rss_feeds.models import merge_feeds, DuplicateFeed, Feed
|
||||||
|
from utils import json_functions as json_functions
|
||||||
|
import json
|
||||||
|
from django.core.management import call_command
|
||||||
class Test_Import(TestCase):
|
class Test_Import(TestCase):
|
||||||
fixtures = ['opml_import.json']
|
fixtures = [
|
||||||
|
'apps/rss_feeds/fixtures/initial_data.json',
|
||||||
|
'opml_import.json'
|
||||||
|
]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.client = Client()
|
self.client = Client()
|
||||||
|
@ -29,8 +34,8 @@ class Test_Import(TestCase):
|
||||||
self.assertEqual(subs.count(), 54)
|
self.assertEqual(subs.count(), 54)
|
||||||
|
|
||||||
usf = UserSubscriptionFolders.objects.get(user=user)
|
usf = UserSubscriptionFolders.objects.get(user=user)
|
||||||
print(json.decode(usf.folders))
|
print(json_functions.decode(usf.folders))
|
||||||
self.assertEqual(json.decode(usf.folders), [{'Tech': [4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]}, 1, 2, 3, 6, {'New York': [1, 2, 3, 4, 5, 6, 7, 8, 9]}, {'tech': []}, {'Blogs': [29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, {'The Bloglets': [45, 46, 47, 48, 49]}]}, {'Cooking': [50, 51, 52, 53]}, 54])
|
self.assertEqual(json_functions.decode(usf.folders), [{'Tech': [4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]}, 1, 2, 3, 6, {'New York': [1, 2, 3, 4, 5, 6, 7, 8, 9]}, {'tech': []}, {'Blogs': [29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, {'The Bloglets': [45, 46, 47, 48, 49]}]}, {'Cooking': [50, 51, 52, 53]}, 54])
|
||||||
|
|
||||||
def test_opml_import__empty(self):
|
def test_opml_import__empty(self):
|
||||||
self.client.login(username='conesus', password='test')
|
self.client.login(username='conesus', password='test')
|
||||||
|
@ -49,4 +54,33 @@ class Test_Import(TestCase):
|
||||||
self.assertEquals(subs.count(), 0)
|
self.assertEquals(subs.count(), 0)
|
||||||
|
|
||||||
class Test_Duplicate_Feeds(TestCase):
|
class Test_Duplicate_Feeds(TestCase):
|
||||||
pass
|
fixtures = [
|
||||||
|
'apps/rss_feeds/fixtures/initial_data.json',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_duplicate_feeds(self):
|
||||||
|
# had to load the feed data this way to hit the save() override.
|
||||||
|
# it wouldn't work with loaddata or fixures
|
||||||
|
|
||||||
|
with open('apps/feed_import/fixtures/duplicate_feeds.json') as json_file:
|
||||||
|
feed_data = json.loads(json_file.read())
|
||||||
|
feed_data_1 = feed_data[0]
|
||||||
|
feed_data_2 = feed_data[1]
|
||||||
|
feed_1 = Feed(**feed_data_1)
|
||||||
|
feed_2 = Feed(**feed_data_2)
|
||||||
|
feed_1.save()
|
||||||
|
feed_2.save()
|
||||||
|
|
||||||
|
call_command('loaddata', 'apps/feed_import/fixtures/subscriptions.json')
|
||||||
|
|
||||||
|
user_1_feed_subscription = UserSubscription.objects.filter(user__id=1)[0].feed_id
|
||||||
|
user_2_feed_subscription = UserSubscription.objects.filter(user__id=2)[0].feed_id
|
||||||
|
|
||||||
|
self.assertNotEqual(user_1_feed_subscription, user_2_feed_subscription)
|
||||||
|
|
||||||
|
original_feed_id = merge_feeds(user_1_feed_subscription, user_2_feed_subscription)
|
||||||
|
|
||||||
|
user_1_feed_subscription = UserSubscription.objects.filter(user__id=1)[0].feed_id
|
||||||
|
user_2_feed_subscription = UserSubscription.objects.filter(user__id=2)[0].feed_id
|
||||||
|
self.assertEqual(user_1_feed_subscription, user_2_feed_subscription)
|
||||||
|
|
Loading…
Add table
Reference in a new issue