def test_add_comment_form_is_valid(self): form = AddCommentForm(data={ 'comment': 'lalala', 'dropZone': load_test_files() }) self.assertTrue(form.is_valid())
def test_ticket_add_comment(self): self.__create_authorized_user() client = Client() client.login(username='******', password='******') ticket = self.create_test_ticket() response = client.post( reverse('ticket_add_comment', args=[ticket.secret_key]), { 'csrfmiddlewaretoken': '', 'staff_answer': 'test_answer', 'willClose': 'on', 'dropZone': load_test_files() }) self.assertEquals(response.status_code, 302) self.assertTrue('/tickets/' in response.url) ticket.refresh_from_db() conversation = loads(ticket.staff_answer)['comments'][0] self.assertEquals(conversation['text'], 'test_answer') for file in conversation['files']: self.assertTrue(path.exists(settings.SAVING_FILES_DIR + file)) self.assertTrue(ticket.isClosed)
def test_add_comment_with_files(self): self.ticket.add_comment(answer='test', files=load_test_files()) conversation = loads(self.ticket.staff_answer)['comments'][0] self.assertEquals(conversation['text'], 'test') for file in conversation['files']: self.assertTrue(path.exists(settings.SAVING_FILES_DIR + file))
def test_handle_uploaded_file(self): files_to_upload = dict() for file in load_test_files(): files_to_upload[file] = generate_file_name() uploaded = handle_uploaded_file(files_to_upload) for file in uploaded: self.assertTrue(path.exists(settings.SAVING_FILES_DIR + file))
def test_add_comment_form_is_valid(self): form = AddCommentForm( data={ 'staff_answer': 'test_answer', 'dropZone': load_test_files()[0], 'showName': True, 'willClose': True }) self.assertTrue(form.is_valid())
def test_complaint_form_is_valid(self): form = ComplaintForm( data={ 'issuer_nickname': 'issuer', 'violator_nickname': 'violator', 'description': 'description', 'email': '*****@*****.**', 'files': load_test_files() }) self.assertTrue(form.is_valid())
def test_appeal_form_is_valid(self): form = AppealForm( data={ 'issuer_nickname': 'issuer_nickname', 'issuer_donate': 'issuer_donate', 'reason': 'reason', 'why_pardon': 'why_pardon', 'email': '*****@*****.**', 'files': load_test_files() }) self.assertTrue(form.is_valid())
def test_create_ticket_with_files(self): ticket = Tickets(issuer_nickname='test', server='server', email='*****@*****.**', ip_address='127.0.0.2', files=load_test_files()) ticket.create() ticket_files = loads(ticket.files)['files'] for file in ticket_files: self.assertTrue(path.exists(settings.SAVING_FILES_DIR + file))
def test_add_comment(self): self.report.create() self.report.add_comment(load_test_files(), 'test_answer', self.osx11.user) self.report.refresh_from_db() comment_files = loads(self.report.dialogue)['comments'][0]['files'] for file in comment_files: self.assertTrue(path.exists(settings.SAVING_FILES_DIR + file)) notification = self.__get_user_notifications(self.moderator.user) self.assertEquals( notification.verb, '%s добавил комментарий к вашему отчету (#%d)' % ('osx11', self.report.id))
def test_report_form_is_valid(self): form = ReportForm( data={ 'violator_nickname': 'test_violator', 'violator_donate': 'test_donate', 'violation': 'test_violation', 'comment': 'test_comment', 'server': 'test_server', 'evidence_text': 'test_logs', 'files': load_test_files(), 'isImportant': 'on', 'isWarning': 'off' }) self.assertTrue(form.is_valid())
def setUp(self): self.username = '******' self.moderator = MyUser(self.username) self.moderator.create(True, False, 'pass', 'first', 'last') self.osx11 = MyUser('osx11') self.osx11.create(False, False, 'pass', 'Grigory', 'Albertov') self.report = Reports(violator_nickname='test_violator', violator_donate='test_donate', violation='test_violation', comment='test_comment', server='test_server', evidence_text='test_evidence', pinned_admin=self.username, isImportant=True, isWarning=False, files=load_test_files())
def test_create_appeal(self): client = Client() response = client.post(reverse('submit_appeal'), data={ 'csrfmiddlewaretoken': '', 'issuer_nickname': 'test_issuer', 'issuer_donate': 'test_donate', 'reason': 'test_reason', 'why_pardon': 'test_why_pardon', 'dropZone_appeal': load_test_files(), 'select_server': 'test_server', 'email': '*****@*****.**' }) self.assertEquals(response.status_code, 302) self.assertTrue('/tickets/' in response.url) ticket = Appeals.objects.get(id=1).ticket self.assertEquals(ticket.issuer_nickname, 'test_issuer')
def test_create_complaint(self): client = Client() response = client.post(reverse('submit_complaint'), data={ 'csrfmiddlewaretoken': '', 'issuer_nickname': 'test_issuer', 'violator_nickname': 'test_violator', 'description': 'test_description', 'evidence': 'test_evidence', 'dropZone_complaint': load_test_files(), 'select_server': 'test_server', 'email': '*****@*****.**' }) self.assertEquals(response.status_code, 302) self.assertTrue('/tickets/' in response.url) ticket = Complaints.objects.get(id=1).ticket self.assertEquals(ticket.issuer_nickname, 'test_issuer')