Example #1
0
    def test_add_admin(self):
        """
        添加一个管理员

        :author: lishanZheng
        :date: 2020/01/06
        """
        privilege_data = get_privilege_data()
        administrator_data = get_administrator_data()
        res = self.client.post('/administrator/administrator',
                               data={
                                   'privilege': privilege_data,
                                   **administrator_data
                               },
                               content_type='application/json')
        self.assertEqual(res.json()['code'], SUCCESS)
    def test_modify_administrator(self):
        """
        修改管理员信息包括权限

        :author: lishanZheng
        :date: 2020/01/06
        """
        admin = get_administrator()
        privilege_data = get_privilege_data()
        administrator_data = get_administrator_data()
        res = self.client.put('/administrator/administrator/' + str(admin.id),
                              data=({
                                  'privilege': privilege_data,
                                  **administrator_data
                              }),
                              content_type='application/json')
        self.assertEqual(res.json()['code'], SUCCESS)
Example #3
0
    def test_add_admin_exist(self):
        """
        管理员账户已经存在

        :author: lishanZheng
        :date: 2020/01/06
        """
        privilege_data = get_privilege_data()
        privilege = Privilege.objects.create(**privilege_data)
        administrator_data = get_administrator_data()
        Administrator.objects.create(**administrator_data, privilege=privilege)
        res = self.client.post('/administrator/administrator',
                               data={
                                   'privilege': privilege_data,
                                   **administrator_data
                               },
                               content_type='application/json')
        self.assertEqual(res.json()['code'], ADMIN_EXIST)
Example #4
0
 def setUp(self):
     privilege_data = get_privilege_data()
     administrator_data = get_administrator_data()
     privilege = Privilege.objects.create(**privilege_data)
     Administrator.objects.create(**administrator_data,
                                  privilege_id=privilege.id)
Example #5
0
 def setUp(self):
     privilege = get_privilege()
     administrator_data_delete = get_administrator_data()
     admin = Administrator.objects.create(**administrator_data_delete,
                                          privilege_id=privilege.id)
     self.admin = admin