コード例 #1
0
    def test_update_field(self):
        self.add_message()
        self.add_usage()
        aa = MUsage.query_recent(self.userid, '1')
        tf = False
        for i in aa:
            if i.user_id == self.userid:
                self.uid = i.uid
                assert i.post_id == self.postid
                tf = True

        assert tf

        p = {'post_id': self.postid2}
        self.add_message(**p)
        a = MPost.get_by_uid(self.postid2)
        MUsage.update_field(self.uid, post_id=self.postid2)
        aa = MUsage.query_recent(self.userid, '1')
        tf = False
        for i in aa:
            if i.user_id == self.userid:
                assert i.post_id == self.postid2
                tf = True
        assert tf
        MUsage.update_field(self.uid, self.postid)
        aa = MUsage.query_recent(self.userid, '1')
        tf = False
        for i in aa:
            if i.user_id == self.userid:
                assert i.post_id == self.postid
                tf = True
        assert tf
        MPost.delete(self.postid2)
        self.tearDown()
コード例 #2
0
ファイル: test_usage.py プロジェクト: brucehe3/TorCMS
 def test_update_field(self):
     MUsage.update_field(self.uid, self.postid)
     assert True
コード例 #3
0
ファイル: script_migrate.py プロジェクト: wwwK/maplet
from torcms.handlers.post_handler import MPost
from torcms.model.post2catalog_model import MPost2Catalog
from torcms.model.evaluation_model import MEvaluation

from torcms.model.usage_model import MUsage

from torcms.model.json_model import MPost2Gson

all_apps = MPost.query_all(kind='m', limit=100000)
for app in all_apps:
    print('=' * 20)
    print(app.uid)

    if len(app.uid) == 4:
        MPost.update_field(app.uid, post_id='m' + app.uid)
    for post2tag in MPost2Catalog.query_by_post(app.uid):
        if len(post2tag.post_id) == 4:
            MPost2Catalog.update_field(post2tag.uid,
                                       post_id='m' + post2tag.post_id)

    for post2tag in MUsage.query_by_post(app.uid):
        if len(post2tag.post_id) == 4:
            MUsage.update_field(post2tag.uid, post_id='m' + post2tag.post_id)

    for post2tag in MPost2Gson.query_by_post(app.uid):
        if len(post2tag.post_id) == 4:
            MPost2Gson.update_field(post2tag.uid,
                                    post_id='m' + post2tag.post_id)