예제 #1
0
    def test_resend_multiple(self):
        schedule.clear()

        user = MyUser('authorized_2')
        user.create(True, False, 'pass', 'fist', 'last')
        user.manage_access(['control'])

        ticket1 = Tickets(issuer_nickname='test',
                          server='server',
                          email='*****@*****.**',
                          ip_address='127.0.0.2', )

        ticket1.create()

        ticket2 = Tickets(issuer_nickname='test',
                          server='server',
                          email='*****@*****.**',
                          ip_address='127.0.0.2', )

        ticket2.create()

        ticket_2_current_time = ticket2.datetime

        schedule.jobs[0].tag('TICKET 1')
        schedule.jobs[1].tag('TICKET 2')

        sleep(2)

        schedule.jobs[0].run()
        schedule.clear('TICKET 1')

        self.assertEquals(dt.strftime(dt.now(), '%Y-%m-%d %H:%M:%S'), ticket1.datetime)
        self.assertEquals(ticket_2_current_time, ticket2.datetime)

        self.assertEquals(len(schedule.jobs), 2)
예제 #2
0
파일: test_views.py 프로젝트: osx11/MSCaBAS
    def create_test_ticket():
        ticket = Tickets(issuer_nickname='test_user',
                         server='server',
                         email='*****@*****.**',
                         ip_address='127.0.0.1',
                         files=None)
        ticket.create()

        return ticket
예제 #3
0
    def test_create_complaint_forbidden_issuer(self):
        user = MyUser('osx11')
        user.create(True, False, 'pass', 'fist', 'last')
        user.manage_access(['staff'])

        ticket = Tickets(issuer_nickname='osx11',
                         server='server',
                         email='*****@*****.**',
                         ip_address='127.0.0.3',
                         files=None)

        with self.assertRaises(FieldContainsForbiddenException):
            ticket.create_complaint(violator_nickname='test', description='desc', evidence=None)
예제 #4
0
    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))
예제 #5
0
    def setUp(self):
        user = MyUser('test')
        user.create(True, False, 'pass', 'fist', 'last')
        user.manage_access(['control'])

        self.ticket = Tickets(
            issuer_nickname='test',
            server='test_server',
            email='*****@*****.**',
            ip_address='127.0.0.1',
            files=None
        )

        self.ticket.create()
예제 #6
0
    def test_should_be_resend_at(self):
        schedule.clear()

        ticket = Tickets(issuer_nickname='test',
                         server='server',
                         email='*****@*****.**',
                         ip_address='127.0.0.2',)

        ticket.create()

        self.assertEquals(dt.strptime(ticket.datetime, '%Y-%m-%d %H:%M:%S') + timedelta(days=1),
                          ticket.should_be_resend_at())
        self.assertEquals(len(schedule.jobs), 1)

        ticket.add_comment('test answer', [], user='******')

        self.assertEquals(dt.strptime(ticket.datetime, '%Y-%m-%d %H:%M:%S') + timedelta(days=3),
                          ticket.should_be_resend_at())
        self.assertEquals(len(schedule.jobs), 1)
예제 #7
0
파일: views.py 프로젝트: osx11/MSCaBAS
def create(request):
    issuer_nickname = request.POST['issuer_nickname']

    # get files below. 'if not files' is necessary, because there are 2 drop zones with different names on one page
    files = request.FILES.getlist('dropZone_complaint', None)
    if not files:
        files = request.FILES.getlist('dropZone_appeal', None)

    server = request.POST['select_server']
    email = request.POST['email']
    ip_address = '127.0.0.1' if settings.DEBUG or settings.TEST_IN_PROGRESS else get_ip(request.META)

    ticket = Tickets(issuer_nickname=issuer_nickname,
                     server=server,
                     email=email,
                     ip_address=ip_address,
                     files=files)

    return ticket
예제 #8
0
    def test_resend(self):
        ticket = Tickets(issuer_nickname='test',
                         server='server',
                         email='*****@*****.**',
                         ip_address='127.0.0.2',)

        ticket.create()
        schedule.clear()

        user = MyUser('authorized_2')
        user.create(True, False, 'pass', 'fist', 'last')
        user.manage_access(['control'])

        current_pinned_admin = ticket.pinned_admin

        ticket.resend()

        self.assertNotEquals(current_pinned_admin, ticket.pinned_admin)
        self.assertTrue(MyUser(ticket.pinned_admin.split(' ')[0]).has_access('control'))
        self.assertEquals(dt.strftime(dt.now(), '%Y-%m-%d %H:%M:%S'), ticket.datetime)
        self.assertEquals(len(schedule.jobs), 1)
        self.assertTrue(ticket.secret_key in schedule.jobs[0].tags)