Exemplo n.º 1
0
    def test_0003(self):
        """this is a test of user download
        """
        school = SchoolHelper.get_school_by_name('测试大学')
        school_id = school.get('id')
        theme = SubjectHelper.get_subject_by_name('计算机科学与技术')
        theme_id = theme.get('id')

        response = self.client.post(
            '/program/user/submit', {
                'token': self.token,
                'code_name': 'TestProgram',
                'code_content': 'print("Hello World")',
                'code_readme': 'Hello World',
                'school_id': school_id,
                'theme_id': theme_id
            })
        data = analyse_response(response)
        self.assertEqual(data.get('status'), 1)

        program = ProgramHelper.get_program_by_name('TestProgram')
        code_id = program.get('id')

        response = self.client.get('/program/user/download', {
            'token': self.token,
            'code_id': code_id
        })

        data = analyse_response(response)
        self.assertEqual(data.get('status'), 1)
Exemplo n.º 2
0
 def test_0001(self):
     """this is a test for admin download
     """
     code_id = ProgramHelper.get_program_by_name('测试代码').get('id')
     response = self.client.get('/program/admin/download', {
         'token': self.token,
         'code_id': code_id
     })
     data = analyse_response(response)
     self.assertEqual(data.get('msg'), 'Success')
Exemplo n.º 3
0
 def test0002(self):
     """this is a test for admin status
     """
     code_id = ProgramHelper.get_program_by_name('测试代码').get('id')
     source = 0
     target = 1
     response = self.client.post(
         '/program/admin/status', {
             'token': self.token,
             'code_id': code_id,
             'source': source,
             'target': target
         })
     data = analyse_response(response)
     self.assertEqual(data.get('msg'), 'Status Changed Successful')
Exemplo n.º 4
0
 def test0007(self):
     """test for some errors
     """
     code_id = ProgramHelper.get_program_by_name('测试代码').get('id')
     source = 0
     target = 2
     response = self.client.post(
         '/program/admin/status', {
             'token': self.token,
             'code_id': code_id,
             'source': source,
             'target': target
         })
     data = analyse_response(response)
     self.assertEqual(data.get('status'), 0)
Exemplo n.º 5
0
 def test0004(self):
     """this a test for admin status
     """
     Initialization.disconnect(self)
     self.token, self.ip_addr = Initialization.start_session(self)
     Initialization.register(self, 'testadmin', 'Test666', '11011011011')
     Initialization.login(self, 'testadmin', 'Test666')
     Initialization.promote_user(self, 4)
     code_id = ProgramHelper.get_program_by_name('在野代码').get('id')
     source = 0
     target = 1
     response = self.client.post(
         '/program/admin/status', {
             'token': self.token,
             'code_id': code_id,
             'source': source,
             'target': target
         })
     data = analyse_response(response)
     self.assertEqual(data.get('msg'), 'Status Changed Successful')