コード例 #1
0
ファイル: tests.py プロジェクト: TheProjecter/metarho
class WordPressExportParserTest(TestCase):
    '''Tests the blog import scripts interaction with the sitemeta app only'''

    fixtures = ['loremauth.json',]

    def setUp(self):
        self.owner = User.objects.get(username='******')
        self.site = Site(domain='greatblogsite.com', name='Great Blog Site')
        self.site.save()
        file = 'blog/fixtures/wordpress.loremtest.xml'
        self.wp = WordPressExportParser(file, self.owner.username)

    def test_import_site_information(self):
        '''
        Not part of the blog app but is part of the parser this will fail if
        sitemeta is not in installed apps.

        '''
        self.wp.import_site_information()
        si = SiteInformation.objects.get(slug='streamweavers-blog')
        expected = 'Just another WordPress.com weblog'
        self.failUnlessEqual(expected, si.description, 'Expected description to read %s but returned %s' % (expected, si.description))
コード例 #2
0
ファイル: blogimport.py プロジェクト: TheProjecter/metarho
 def handle(self, *args, **options):
     # Throws an error if not a valid user.
     user = self._get_user(options["username"]) 
     for file in args:
         wp = WordPressExportParser(file, user.username)
         wp.parse()
コード例 #3
0
ファイル: tests.py プロジェクト: TheProjecter/metarho
 def setUp(self):
     self.owner = User.objects.get(pk=1)
     file = 'blog/fixtures/wordpress.test.xml'
     self.wp = WordPressExportParser(file, self.owner.username)
コード例 #4
0
ファイル: tests.py プロジェクト: TheProjecter/metarho
class WordPressExportParserTest(TestCase):
    '''Tests the import scripts as it relates to interation with blog app.'''

    fixtures = ['loremauth.json',]

    def setUp(self):
        self.owner = User.objects.get(pk=1)
        file = 'blog/fixtures/wordpress.test.xml'
        self.wp = WordPressExportParser(file, self.owner.username)

    def test_import_tags(self):
        '''Tests the Tag Import'''
        self.wp.import_tags()
        expected = 30
        actual = Tag.objects.all().count()
        self.failUnlessEqual(expected, actual, 'Expected %s and return %s Tags.' % (expected, actual))
  
    def test_import_topics(self):
        '''Test the import of Topics.'''
        self.wp.import_catagories()
        expected = 2
        actual = Topic.objects.all().count()
        self.failUnlessEqual(expected, actual, 'Expected %s and returned %s Topics.' % (expected, actual))
  
    def test_import_posts(self):
        '''Tests the Import of posts.'''
        
        # Make a user to assign as an author.
        user = User(username='******', password='******', email='*****@*****.**')
        user.save()
        
        # Start with zero posts.
        posts = Post.objects.published()
        expected = 0
        actual = posts.count()
        self.failUnlessEqual(expected, actual, 'Expected %s posts and parsed %s.' % (expected, actual))
        
        # Import the blog entries.
        self.wp.import_catagories()
        self.wp.import_tags()
        self.wp.import_posts()
        posts = Post.objects.all()
        expected = 4
        actual = posts.count()
        self.failUnlessEqual(expected, actual, 'Imported %s posts but expected %s.' % (actual, expected))
        
        # Test creation of post meta and 
        testpost  = Post.objects.get(slug='here-we-go')
        
        # Test PostMeta being created correctly.
        postmeta = testpost.postmeta_set.all()
        expected = 13
        actual = postmeta.count()
        self.failUnlessEqual(expected, actual, 'Expected %s and returned %s Post Meta attributes.' % (expected, actual))
    
        # Test Tags being created and related correctly.
        tagcount = testpost.tags.count()

        expected = 1
        self.failUnlessEqual(expected, tagcount, 'Expected %s and returned %s tags.' % (expected, tagcount))
        
        # Test Topics being created and related correctly.
        topiccount = testpost.topics.all().count()
        expected = 1
        self.failUnlessEqual(expected, topiccount, 'Expected %s and returned %s topics.' % (expected, topiccount))
コード例 #5
0
ファイル: tests.py プロジェクト: TheProjecter/metarho
 def setUp(self):
     self.owner = User.objects.get(username='******')
     self.site = Site(domain='greatblogsite.com', name='Great Blog Site')
     self.site.save()
     file = 'blog/fixtures/wordpress.loremtest.xml'
     self.wp = WordPressExportParser(file, self.owner.username)