示例#1
0
class TestLabel():
    def setup(self):
        print('setup 方法执行于本类中每条用例之前')
        self.uu = MLabel()
        self.name = 'name'
        self.tmpl_uid = ''
        self.uid = tools.get_uu4d()

    def test_insert(self):
        post_data = {
            'name': 'titlesdf',
        }
        newid = MLabel.create_tag(post_data['name'])

        tt = MLabel.get_id_by_name(post_data['name'])
        # assert tt.uid == suid
        self.tmpl_uid = tt
        assert tt == newid

    def test_insert_2(self):
        '''Wiki insert: Test invalid title'''
        post_data = {
            'name': self.name,
        }
        uu = self.uu.create_tag(post_data['name'])
        # assert uu == False

        post_data = {
            'name': '',
        }
        uu = self.uu.create_tag(post_data['name'])
        # assert uu == False

    def test_create_tag_with_uid(self):
        '''Wiki insert: Test invalid title'''
        post_data = {
            'name': self.name,
        }

        self.uu.create_tag_with_uid(self.uid, post_data['name'])
        assert True

    def test_get_id_by_name(self):
        MLabel.get_id_by_name(self.name)
        assert True

    def test_get_by_slug(self):
        MLabel.get_by_slug(self.name)
        assert True

    def test_delete(self):
        MLabel.delete(self.uid)
        assert True

    def tearDown(self):
        print("function teardown")
        tt = self.uu.get_id_by_name(self.name)
        self.uu.delete(self.tmpl_uid)
示例#2
0
    def tearDown(self):
        print("function teardown")

        self.uu.delete(self.uid)
        MCategory.delete(self.tag_id)
        self.uu.delete(self.post_id2)
        self.uu.delete(self.post_id)
        MPost2Catalog.remove_relation(self.post_id, self.tag_id)
        tt = MLabel.get_by_slug(self.slug)
        if tt:
            MLabel.delete(tt.uid)
示例#3
0
    def tearDown(self):
        print("function teardown")

        tt = MPost.get_by_uid(self.post_id)
        if tt:
            print('777777777777')
            MPost.delete(self.post_id)

        tt = MLabel.get_by_slug(self.tag_id)
        if tt:
            print('8888888888')
            MLabel.delete(tt.uid)
示例#4
0
    def tearDown(self):
        print("function teardown")

        tt = self.uu.get_by_uid(self.app_f)
        if tt:
            MPost2Catalog.remove_relation(self.app_t, self.tag_id)
            MPost2Catalog.remove_relation(self.app_f, self.tag_id)
            MCategory.delete(self.tag_id)

            MPost.delete(self.app_f)
            MPost.delete(self.app_t)

        MRelation.delete(self.uid)
        tt = MLabel.get_by_slug(self.slug)
        if tt:
            MLabel.delete(tt.uid)
示例#5
0
    def tearDown(self):
        print("function teardown")
        tt = MCategory.get_by_uid(self.tag_id)
        if tt:
            MCategory.delete(self.tag_id)
        tt = MPost.get_by_uid(self.post_id)
        if tt:
            MPost.delete(self.post_id)

            MPost2Catalog.remove_relation(self.post_id, self.tag_id)
        tt = MPost.get_by_uid(self.post_id2)
        if tt:
            MPost.delete(self.post_id2)

            MPost2Catalog.remove_relation(self.post_id2, self.tag_id)

        tt = MLabel.get_by_slug(self.slug)
        if tt:
            print('8888888888')
            MLabel.delete(self.slug)
示例#6
0
    def tearDown(self):
        print("function teardown")
        tt = self.uu.get_by_uid(self.uid)

        if tt:
            print('翻翻翻翻翻翻翻翻翻翻翻翻翻翻翻翻翻翻3')
            self.uu.delete(self.uid)
        tt = MCategory.get_by_uid(self.tag_id)
        if tt:
            MCategory.delete(self.tag_id)
        tt = self.uu.get_by_uid(self.post_id)
        if tt:
            MCategory.delete(self.tag_id)

            MPost.delete(self.post_id2)
            MPost.delete(self.post_id)

            MPost2Catalog.remove_relation(self.post_id, self.tag_id)
            print('545456365635653')

        tt = MLabel.get_by_slug(self.slug)
        if tt:
            print('8888888888')
            MLabel.delete(tt.uid)
示例#7
0
 def test_delete(self):
     MLabel.delete(self.uid)
     assert True
示例#8
0
class TestMLabel():
    def setup(self):
        print('setup 方法执行于本类中每条用例之前')
        self.uu = MLabel()
        self.name = 'name'
        self.tmpl_uid = ''
        self.uid = tools.get_uu4d()
        self.post_id = '2222'

    def test_create_tag(self):
        post_data = {
            'name': self.name,
        }
        newid = MLabel.create_tag(post_data['name'])

        tt = MLabel.get_id_by_name(post_data['name'])

        self.tmpl_uid = tt
        assert tt == newid
        self.tearDown()

    def test_create_tag_with_uid(self):
        '''Wiki insert: Test invalid title'''
        post_data = {
            'name': self.name,
        }
        self.uu.create_tag_with_uid(self.uid, post_data['name'])
        a = self.uu.get_id_by_name(post_data['name'])
        assert a == self.uid
        self.tearDown()

    def add_message(self, **kwargs):
        p_d = {
            'title': kwargs.get('title', 'iiiii'),
            'cnt_md': kwargs.get('cnt_md', 'grgr'),
            'time_create': kwargs.get('time_create', '1992'),
            'time_update': kwargs.get('time_update', '1996070600'),
            'user_name': kwargs.get('user_name', 'yuanyuan'),
            'view_count': kwargs.get('view_count', 1),
            'logo': kwargs.get('logo', 'prprprprpr'),
            'memo': kwargs.get('memo', ''),
            'order': kwargs.get('order', '1'),
            'keywords': kwargs.get('keywords', ''),
            'extinfo': kwargs.get('extinfo', {}),
            'kind': kwargs.get('kind2', '1'),
            'valid': kwargs.get('valid', 1),
        }
        post_id = kwargs.get('post_id', self.post_id)

        MPost.create_post(post_id, p_d)
        self.uu.create_tag_with_uid(self.uid, self.name)
        MPost2Label.add_record(self.post_id, self.name)

    def test_get_id_by_name(self):
        self.add_message()
        a = self.uu.get_id_by_name(self.name)
        print(a)
        print(self.uid)
        assert a == self.uid
        self.tearDown()

    def test_get_by_slug(self):
        self.add_message()
        a = self.uu.get_by_slug(self.uid)
        assert a.name == self.name
        self.tearDown()

    def test_delete(self):
        self.add_message()
        a = self.uu.get_by_slug(self.uid)
        assert a.name == self.name
        self.uu.delete(self.uid)
        a = self.uu.get_by_slug(self.uid)
        print(a)
        assert a == False
        self.tearDown()

    def tearDown(self):
        print("function teardown")
        tt = self.uu.get_by_slug(self.tmpl_uid)
        if tt:
            print('99999999')
            self.uu.delete(self.tmpl_uid)
        tt = self.uu.get_by_slug(self.uid)
        if tt:
            print('444444444')
            self.uu.delete(self.uid)

        tt = MPost.get_by_uid(self.post_id)
        if tt:
            print('0000000000')
            MPost.delete(self.post_id)