예제 #1
0
 def test_get(self):
     model = KMBlogInfo.get(None)
     # id = Noneの場合は新規モデルが取得できること
     eq_(model.id, None)
     model = KMBlogInfo.get(1)
     # id = 1の場合は登録済みのモデルが取得できること
     eq_(model.id, 1)
예제 #2
0
 def test_get(self):
     model = KMBlogInfo.get(None)
     # id = Noneの場合は新規モデルが取得できること
     eq_(model.id, None)
     model = KMBlogInfo.get(1)
     # id = 1の場合は登録済みのモデルが取得できること
     eq_(model.id, 1)
예제 #3
0
 def blog_admin_info(self):
     '''
     blog admin page
     :return: template
     '''
     id = self.data.get_request_parameter('id', default=None)
     self.result['info'] = KMBlogInfo.get(id=id)
     self.result['type'] = 'info'
     self.result['menu_list'] = get_menu_list()
예제 #4
0
 def blog_admin_info(self):
     '''
     blog admin page
     :return: template
     '''
     id = self.data.get_request_parameter('id', default=None)
     self.result['info'] = KMBlogInfo.get(id=id)
     self.result['type'] = 'info'
     self.result['menu_list'] = get_menu_list()
예제 #5
0
 def blog_admin_article(self):
     '''
     blog admin page
     :return: template
     '''
     id = self.data.get_request_parameter('id', default=None)
     info_id = self.data.get_request_parameter('info_id')
     self.result['info'] = KMBlogInfo.get(id=info_id)
     self.result['category'] = KMBlogCategory.find(info_id=info_id)
     self.result['article'] = KMBlogArticle.get(id=id)
     self.result['type'] = 'article'
     self.result['menu_list'] = get_menu_list()
예제 #6
0
 def blog_admin_create_article(self):
     '''
     Create Blog Article.
     :return:
     '''
     values = {}
     id = self.data.get_request_parameter('id', default=None)
     info_id = self.data.get_request_parameter('info_id')
     self.result['info'] = KMBlogInfo.get(info_id)
     self.result['article'] = KMBlogArticle.save_data(id, self.data)
     self.result['type'] = 'article'
     self.result['menu_list'] = get_menu_list()
예제 #7
0
 def blog_admin_article(self):
     '''
     blog admin page
     :return: template
     '''
     id = self.data.get_request_parameter('id', default=None)
     info_id = self.data.get_request_parameter('info_id')
     self.result['info'] = KMBlogInfo.get(id=info_id)
     self.result['category'] = KMBlogCategory.find(info_id=info_id)
     self.result['article'] = KMBlogArticle.get(id=id)
     self.result['type'] = 'article'
     self.result['menu_list'] = get_menu_list()
예제 #8
0
 def blog_admin_create_article(self):
     '''
     Create Blog Article.
     :return:
     '''
     values = {}
     id = self.data.get_request_parameter('id', default=None)
     info_id = self.data.get_request_parameter('info_id')
     self.result['info'] = KMBlogInfo.get(info_id);
     self.result['article'] = KMBlogArticle.save_data(id, self.data);
     self.result['type'] = 'article'
     self.result['menu_list'] = get_menu_list()
예제 #9
0
    def test_save_data(self):

        model = KMBlogInfo.get(1)
        eq_(model.id, 1)
        eq_(model.name, '')
        eq_(model.url, '')
        eq_(model.description, '')
        data = self.mocker.CreateMock(KMData)
        data.get_request_parameter('name', default='', decode=True).AndReturn(self.test_name)
        data.get_request_parameter('url', default='').AndReturn(self.test_url)
        data.get_request_parameter('description', default='', decode=True).AndReturn(self.test_description)
        self.mocker.ReplayAll()
        model = KMBlogInfo.save_data(1, data)
        # 既存データのidが指定された場合は値が上書きされること
        eq_(model.error.size(), 0)
        eq_(model.id, 1)
        eq_(model.name, self.test_name)
        eq_(model.url, self.test_url)
        eq_(model.description, self.test_description)
        self.mocker.VerifyAll()
예제 #10
0
    def test_save_data(self):

        model = KMBlogInfo.get(1)
        eq_(model.id, 1)
        eq_(model.name, '')
        eq_(model.url, '')
        eq_(model.description, '')
        data = self.mocker.CreateMock(KMData)
        data.get_request_parameter('name', default='',
                                   decode=True).AndReturn(self.test_name)
        data.get_request_parameter('url', default='').AndReturn(self.test_url)
        data.get_request_parameter('description', default='',
                                   decode=True).AndReturn(
                                       self.test_description)
        self.mocker.ReplayAll()
        model = KMBlogInfo.save_data(1, data)
        # 既存データのidが指定された場合は値が上書きされること
        eq_(model.error.size(), 0)
        eq_(model.id, 1)
        eq_(model.name, self.test_name)
        eq_(model.url, self.test_url)
        eq_(model.description, self.test_description)
        self.mocker.VerifyAll()