Example #1
0
class OldRedirectTests(TestCase):
    def setUp(self):
        self.topic = Topic(name='topic', grant=Grant.objects.create(full_name='g', short_name='g'))
        self.topic.save()
        self.ticket = Ticket(summary='foo', requested_text='req', topic=self.topic, description='foo foo')
        self.ticket.save()
    
    def assert301(self, *args, **kwargs):
        kwargs['status_code'] = 301
        self.assertRedirects(*args, **kwargs)
    
    def test_old_index(self):
        response = Client().get('/old/')
        self.assert301(response, '/', target_status_code=302) # 302 = now index is a non-permanent redirect
    
    def test_topic_index(self):
        response = Client().get('/old/topics/')
        self.assert301(response, reverse('topic_list'))
    
    def test_ticket(self):
        response = Client().get('/old/ticket/%s/' % self.ticket.id)
        self.assert301(response, self.ticket.get_absolute_url())
    
    def test_new_ticket(self):
        response = Client().get('/old/ticket/new/')
        self.assert301(response, reverse('create_ticket'), target_status_code=302) # 302 = redirect to login
    
    def test_topic(self):
        response = Client().get('/old/topic/%s/' % self.topic.id)
        self.assert301(response, self.topic.get_absolute_url())
Example #2
0
class OldRedirectTests(TestCase):
    def setUp(self):
        self.topic = Topic(name='topic', grant=Grant.objects.create(full_name='g', short_name='g', slug='g'))
        self.topic.save()
        self.ticket = Ticket(name='foo', requested_text='req', topic=self.topic, description='foo foo')
        self.ticket.save()

    def assert301(self, *args, **kwargs):
        kwargs['status_code'] = 301
        self.assertRedirects(*args, **kwargs)

    def test_old_index(self):
        response = Client().get('/old/')
        self.assert301(response, '/', target_status_code=302)  # 302 = now index is a non-permanent redirect

    def test_topic_index(self):
        response = Client().get('/old/topics/')
        self.assert301(response, reverse('topic_list'))

    def test_ticket(self):
        response = Client().get('/old/ticket/%s/' % self.ticket.id)
        self.assert301(response, self.ticket.get_absolute_url())

    def test_new_ticket(self):
        response = Client().get('/old/ticket/new/')
        self.assert301(response, reverse('create_ticket'), target_status_code=302)  # 302 = redirect to login

    def test_topic(self):
        response = Client().get('/old/topic/%s/' % self.topic.id)
        self.assert301(response, self.topic.get_absolute_url())
Example #3
0
 def test_empty_ticket(self):
     empty_ticket = Ticket(topic=self.topic, requested_text='someone', summary='empty ticket')
     empty_ticket.save()
     
     self.assertEqual(0, empty_ticket.media_count()['objects'])
     self.assertEqual(0, empty_ticket.expeditures()['count'])
     self.assertEqual(0, self.topic.media_count()['objects'])
     self.assertEqual(0, self.topic.expeditures()['count'])
Example #4
0
 def setUp(self):
     self.topic = Topic(name='topic1', grant=Grant.objects.create(full_name='g', short_name='g'))
     self.topic.save()
     
     self.ticket1 = Ticket(summary='foo', requested_text='req1', topic=self.topic, description='foo foo')
     self.ticket1.save()
     
     self.ticket2 = Ticket(summary='bar', requested_text='req2', topic=self.topic, description='bar bar')
     self.ticket2.save()
Example #5
0
    def setUp(self):
        self.topic = Topic(name='test_topic', open_for_tickets=True, ticket_media=True, grant=Grant.objects.create(full_name='g', short_name='g', slug='g'))
        self.topic.save()

        self.user = User(username='******')
        self.user.save()

        self.ticket = Ticket(name='foo', requested_user=self.user, topic=self.topic, description='foo foo')
        self.ticket.save()
Example #6
0
    def setUp(self):
        self.topic = Topic(name='topic1', grant=Grant.objects.create(full_name='g', short_name='g', slug='g'))
        self.topic.save()

        self.ticket1 = Ticket(name='foo', requested_text='req1', topic=self.topic, description='foo foo')
        self.ticket1.save()

        self.ticket2 = Ticket(name='bar', requested_text='req2', topic=self.topic, description='bar bar')
        self.ticket2.save()
Example #7
0
    def setUp(self):
        self.topic = Topic(name='topic', grant=Grant.objects.create(full_name='g', short_name='g', slug='g'))
        self.topic.save()

        self.password = '******'
        self.user = User(username='******')
        self.user.set_password(self.password)
        self.user.save()

        self.ticket = Ticket(name='ticket', topic=self.topic, requested_user=None, requested_text='foo')
        self.ticket.save()
Example #8
0
 def test_full_ticket(self):
     full_ticket = Ticket(topic=self.topic, requested_text='someone', summary='full ticket')
     full_ticket.save()
     full_ticket.mediainfo_set.create(description='Vague pictures')
     full_ticket.mediainfo_set.create(description='Counted pictures', count=15)
     full_ticket.mediainfo_set.create(description='Even more pictures', count=16)
     full_ticket.expediture_set.create(description='Some expense', amount=99)
     full_ticket.expediture_set.create(description='Some other expense', amount=101)
     
     self.assertEqual({'objects': 3, 'media': 31}, full_ticket.media_count())
     self.assertEqual({'count': 2, 'amount': 200}, full_ticket.expeditures())
     self.assertEqual({'objects': 3, 'media': 31}, self.topic.media_count())
     self.assertEqual({'count': 2, 'amount': 200}, self.topic.expeditures())
Example #9
0
def add(request):
    if (request.user.is_authenticated()):
        user_id = request.user.id
    else:
        user_id = 0
    t = Ticket(project_id=request.POST['ticket_project'],
               status_id=1,
               author_id=user_id,
               assigned_user_id=request.POST['ticket_user'],
               dt_created=timezone.now(),
               text=request.POST['ticket_text'])
    t.save()
    return HttpResponseRedirect(reverse('ticket', args=(t.id,)))
Example #10
0
class UserDetailsTest(TestCase):
    def setUp(self):
        self.topic = Topic(name='test_topic', open_for_tickets=True, ticket_media=True, grant=Grant.objects.create(full_name='g', short_name='g', slug='g'))
        self.topic.save()

        self.user = User(username='******')
        self.user.save()

        self.ticket = Ticket(name='foo', requested_user=self.user, topic=self.topic, description='foo foo')
        self.ticket.save()

    def test_user_details(self):
        c = Client()
        response = c.get(UserWrapper(self.user).get_absolute_url())
        self.assertEqual(200, response.status_code)
        self.assertEqual(self.ticket, response.context['ticket_list'][0])
Example #11
0
 def test_correct_choices(self):
     grant = Grant.objects.create(full_name='g', short_name='g')
     t_closed = Topic(name='t1', open_for_tickets=False, grant=grant)
     t_closed.save()
     t_open = Topic(name='t2', open_for_tickets=True, grant=grant)
     t_open.save()
     t_assigned = Topic(name='t3', open_for_tickets=False, grant=grant)
     t_assigned.save()
     ticket = Ticket(summary='ticket', topic=t_assigned)
     ticket.save()
     
     from tracker.views import get_edit_ticket_form_class
     EditForm = get_edit_ticket_form_class(ticket)
     choices = {t.id for t in EditForm().fields['topic'].queryset.all()}
     wanted_choices = {t_open.id, t_assigned.id}
     self.assertEqual(wanted_choices, choices)
Example #12
0
    def test_correct_choices(self):
        grant = Grant.objects.create(full_name='g', short_name='g', slug='g')
        t_closed = Topic(name='t1', open_for_tickets=False, grant=grant)
        t_closed.save()
        t_open = Topic(name='t2', open_for_tickets=True, grant=grant)
        t_open.save()
        t_assigned = Topic(name='t3', open_for_tickets=False, grant=grant)
        t_assigned.save()
        ticket = Ticket(name='ticket', topic=t_assigned)
        ticket.save()

        from tracker.views import get_edit_ticket_form_class
        EditForm = get_edit_ticket_form_class(ticket)
        choices = {t.id for t in EditForm().fields['topic'].queryset.all()}
        wanted_choices = {t_open.id, t_assigned.id}
        self.assertEqual(wanted_choices, choices)
Example #13
0
class UserDetailsTest(TestCase):
    def setUp(self):
        self.topic = Topic(name='test_topic', open_for_tickets=True, ticket_media=True, grant=Grant.objects.create(full_name='g', short_name='g'))
        self.topic.save()
        
        self.user = User(username='******')
        self.user.save()
        
        self.ticket = Ticket(summary='foo', requested_user=self.user, topic=self.topic, description='foo foo')
        self.ticket.save()
    
    def test_user_details(self):
        c = Client()
        response = c.get(self.user.get_absolute_url())
        self.assertEqual(200, response.status_code)
        self.assertEqual(self.ticket, response.context['ticket_list'][0])
Example #14
0
 def setUp(self):
     self.topic = Topic(name='test_topic', open_for_tickets=True, ticket_media=True, grant=Grant.objects.create(full_name='g', short_name='g'))
     self.topic.save()
     
     self.user = User(username='******')
     self.user.save()
     
     self.ticket = Ticket(summary='foo', requested_user=self.user, topic=self.topic, description='foo foo')
     self.ticket.save()
Example #15
0
 def setUp(self):
     self.topic = Topic(name='topic', grant=Grant.objects.create(full_name='g', short_name='g'))
     self.topic.save()
     
     self.password = '******'
     self.user = User(username='******')
     self.user.set_password(self.password)
     self.user.save()
     
     self.ticket = Ticket(summary='ticket', topic=self.topic, requested_user=None, requested_text='foo')
     self.ticket.save()
Example #16
0
	def save(self):
		t = Ticket(title=self.cleaned_data['title'], submitter_email=self.cleaned_data['submitter_email'], status=Ticket.NEW_STATUS, queue=self.cleaned_data['queue'], description=self.cleaned_data['description'], priority=self.cleaned_data['priority'])
		t.save()
		
		f = FollowUp(ticket=t, title='Ticket opened via web', public=True, comment='Ticket opened via the web.')
		f.save()
		
		# files = []
		if self.cleaned_data['attachment']:
			import mimetypes
			
			file = self.cleaned_data['attachment']
			filename = file.name.replace(' ', '_')
			
			a = Attachment(followup=f, filename=filename, mime_type=mimetypes.guess_type(filename)[0] or 'application/octet-stream', size=file.size)
			a.file.save(file.name, file)
			
			# if file.size < getattr(settings, 'MAX_EMAIL_ATTACHMENT_SIZE', 1024000):
			# 	files.append(a.file.path)
			
		return t
Example #17
0
 def setUp(self):
     self.user = User(username='******')
     self.user.save()
     
     self.topic = Topic(name='test_topic', ticket_expenses=True, grant=Grant.objects.create(full_name='g', short_name='g'))
     self.topic.save()
     
     self.ticket = Ticket(summary='foo', requested_user=self.user, topic=self.topic, rating_percentage=50)
     self.ticket.save()
     self.ticket.add_acks('content', 'docs', 'archive')
     self.ticket.expediture_set.create(description='foo', amount=200)
     self.ticket.expediture_set.create(description='foo', amount=100)
     self.ticket.mediainfo_set.create(description='foo', count=5)
     
     self.ticket2 = Ticket(summary='foo', requested_user=self.user, topic=self.topic, rating_percentage=100)
     self.ticket2.save()
     self.ticket2.add_acks('content', 'docs', 'archive')
     self.ticket2.expediture_set.create(description='foo', amount=600)
     self.ticket2.expediture_set.create(description='foo', amount=10)
     self.ticket2.mediainfo_set.create(description='foo', count=5)
     self.ticket2.mediainfo_set.create(description='foo', count=3)
Example #18
0
    def generate_and_add_tickets(self, amount=60):
        name_prefix = "Example ticket number "
        try:
            last_example_ticket = Ticket.objects.filter(name__startswith=name_prefix).order_by('pk').reverse()[0]
        except IndexError:
            start_num = 1
        else:
            start_num = int(search(r'(\d+)$', last_example_ticket.name).group(0)) + 1

        def generate_random_date():
            year_today = datetime.today().year
            # probably shouldn't matter, but preventing future dates.
            year = randint(year_today - 3, year_today - 1)
            month = randint(1, 12)
            # february only has 28 days, making this harder by
            # including 29-31 is unnecessary
            day = randint(1, 28)
            hour = randint(1, 23)
            minute = randint(1, 59)
            return datetime(year, month, day, hour, minute, tzinfo=UTC)

        user_objects = User.objects.filter(username__startswith=USERNAME_PREFIX)
        if not user_objects.exists():
            raise DataError('To create example tickets, at least one example user has to be created.')
        topic_objects = Topic.objects.all()
        subtopic_objects = Subtopic.objects.all()
        ticket_query_list = []
        for n in range(start_num, start_num + amount):
            created_and_updated = generate_random_date()
            topic = choice(topic_objects)
            try:
                subtopic = choice(subtopic_objects.filter(topic=topic))
            except IndexError:
                # topic has no subtopics
                subtopic = None

            ticket_query_list.append(Ticket(
                created=created_and_updated,
                updated=created_and_updated,
                event_date=generate_random_date(),
                requested_user=choice(user_objects),
                name="{}{}".format(name_prefix, n),
                topic=topic,
                subtopic=subtopic,
                rating_percentage=randint(0, 100),
                mandatory_report=choice([True, False]),
                description=("Space for further notes. If you're entering a trip "
                             "tell us where did you go and what you did there."),
                supervisor_notes=("This space is for notes of project "
                                  "supervisors and accounting staff."),
            ))
        Ticket.objects.bulk_create(ticket_query_list)
Example #19
0
    def test_empty_ticket(self):
        empty_ticket = Ticket(topic=self.topic, requested_text='someone', name='empty ticket')
        empty_ticket.save()

        self.assertEqual(0, empty_ticket.media_count())
        self.assertEqual(0, empty_ticket.expeditures()['count'])
        self.assertEqual(0, self.topic.media_count())
        self.assertEqual(0, self.topic.expeditures()['count'])
Example #20
0
    def handle(self, *args, **options):
        # if Ticket.objects.exists():
        #     print('Already loaded exiting')
        #     return
        print('Loading data...')

        for row in DictReader(open('incidentseed.csv')):
            ticket = Ticket()
            ticket.status = row['status']
            ticket.number = row['number']
            ticket.assigned = row['assigned']
            ticket.save()
Example #21
0
    def setUp(self):
        self.user = User(username='******')
        self.user.save()

        self.topic = Topic(name='test_topic', ticket_expenses=True, grant=Grant.objects.create(full_name='g', short_name='g', slug='g'))
        self.topic.save()

        self.ticket = Ticket(name='foo', requested_user=self.user, topic=self.topic, rating_percentage=50)
        self.ticket.save()
        self.ticket.add_acks('content', 'docs', 'archive')
        self.ticket.expediture_set.create(description='foo', amount=200)
        self.ticket.expediture_set.create(description='foo', amount=100)
        self.ticket.mediainfoold_set.create(description='foo', count=5)
        self.ticket.mediainfo_set.create(name='test.jpg')
        self.ticket.mediainfo_set.create(name='test2.jpg')

        self.ticket2 = Ticket(name='foo', requested_user=self.user, topic=self.topic, rating_percentage=100)
        self.ticket2.save()
        self.ticket2.add_acks('content', 'docs', 'archive')
        self.ticket2.expediture_set.create(description='foo', amount=600)
        self.ticket2.expediture_set.create(description='foo', amount=10)
        self.ticket2.mediainfoold_set.create(description='foo', count=5)
        self.ticket2.mediainfoold_set.create(description='foo', count=3)
        self.ticket2.mediainfo_set.create(name='test.jpg')
Example #22
0
def insert(request):
    if request.method == 'POST':
        bll = request.POST['bll']
        il = request.POST['il']
        ilpath = request.POST['ilpath']
        recipient_email = request.POST['recipient_email']
        shelved_changelist= request.POST['shelved_changelist']
        workspace_checksum= request.POST['workspace_checksum']
        targetsys= request.POST['targetsys']
        testsets = request.POST['testsets']
        try:
            t = Ticket(bll=bll, il=il,ilpath=ilpath, recipient_email=recipient_email,shelved_changelist=shelved_changelist,workspace_checksum=workspace_checksum, targetsys=targetsys, testsets=testsets)
            t.save()
        except Exception as e:
            if 'fk_sys' in str(e):
                err_msg = 'Bad system name from input. Contact admin to register ' + targetsys + ' system before use'
                return HttpResponseBadRequest(err_msg)
            return HttpResponseBadRequest(str(e))
        response_data = {}
        response_data['confirmation_number'] = t.id
        response_data['error_reason']=''
    else: 
        return HttpResponse('Not a valid request')
    return HttpResponse(json.dumps(response_data), content_type='application/json')
Example #23
0
    def test_full_ticket(self):
        full_ticket = Ticket(topic=self.topic, requested_text='someone', name='full ticket')
        full_ticket.save()
        full_ticket.mediainfoold_set.create(description='Vague pictures')
        full_ticket.mediainfoold_set.create(description='Counted pictures', count=15)
        full_ticket.mediainfoold_set.create(description='Even more pictures', count=16)
        full_ticket.mediainfo_set.create(name='test.jpg')
        full_ticket.expediture_set.create(description='Some expense', amount=99)
        full_ticket.expediture_set.create(description='Some other expense', amount=101)

        self.assertEqual(32, full_ticket.media_count())
        self.assertEqual({'count': 2, 'amount': 200}, full_ticket.expeditures())
        self.assertEqual(32, self.topic.media_count())
        self.assertEqual({'count': 2, 'amount': 200}, self.topic.expeditures())
Example #24
0
class SummaryTest(TestCase):
    def setUp(self):
        self.user = User(username='******')
        self.user.save()
        
        self.topic = Topic(name='test_topic', ticket_expenses=True, grant=Grant.objects.create(full_name='g', short_name='g'))
        self.topic.save()
        
        self.ticket = Ticket(summary='foo', requested_user=self.user, topic=self.topic, rating_percentage=50)
        self.ticket.save()
        self.ticket.add_acks('content', 'docs', 'archive')
        self.ticket.expediture_set.create(description='foo', amount=200)
        self.ticket.expediture_set.create(description='foo', amount=100)
        self.ticket.mediainfo_set.create(description='foo', count=5)
        
        self.ticket2 = Ticket(summary='foo', requested_user=self.user, topic=self.topic, rating_percentage=100)
        self.ticket2.save()
        self.ticket2.add_acks('content', 'docs', 'archive')
        self.ticket2.expediture_set.create(description='foo', amount=600)
        self.ticket2.expediture_set.create(description='foo', amount=10)
        self.ticket2.mediainfo_set.create(description='foo', count=5)
        self.ticket2.mediainfo_set.create(description='foo', count=3)
    
    def test_topic_ticket_counts(self):
        self.assertEqual({'unpaid':2}, self.topic.tickets_per_payment_status())
        trans = Transaction.objects.create(date=datetime.date.today(), other=self.user, amount=150)
        trans.tickets.add(self.ticket)
        self.assertEqual({'unpaid':1, 'paid':1}, self.topic.tickets_per_payment_status())

    def test_ticket_summary(self):
        self.ticket.ticketack_set.filter(ack_type='archive').delete()
        self.ticket.rating_percentage = None
        self.ticket.save()
        
        self.assertEqual({'objects':1, 'media':5}, self.ticket.media_count())
        self.assertEqual({'count':2, 'amount':300}, self.ticket.expeditures())
        self.assertEqual(0, self.ticket.accepted_expeditures())
        
        self.ticket.rating_percentage = 50
        self.ticket.save()
        self.assertEqual(0, self.ticket.accepted_expeditures())
        
        self.ticket.add_acks('archive')
        self.assertEqual(150, self.ticket.accepted_expeditures())

    def test_topic_summary(self):
        self.assertEqual({'objects':3, 'media':13}, self.topic.media_count())
        self.assertEqual({'count':4, 'amount':910}, self.topic.expeditures())
        self.assertEqual(150 + 610, self.topic.accepted_expeditures())
    
    def test_user_summary(self):
        profile = self.user.get_profile()
        self.assertEqual({'objects':3, 'media':13}, profile.media_count())
        self.assertEqual(150 + 610, profile.accepted_expeditures())
        self.assertEqual({'count':0, 'amount':None}, profile.transactions())
    
    def test_transaction_summary(self):
        def add_trans(amount):
            self.user.transaction_set.create(date=datetime.date.today(), amount=amount, description='foo')
        
        add_trans(500)
        self.assertEqual({'count':1, 'amount':500}, self.user.get_profile().transactions())
Example #25
0
class SimpleTicketTest(TestCase):
    def setUp(self):
        self.topic = Topic(name='topic1', grant=Grant.objects.create(full_name='g', short_name='g', slug='g'))
        self.topic.save()

        self.ticket1 = Ticket(name='foo', requested_text='req1', topic=self.topic, description='foo foo')
        self.ticket1.save()

        self.ticket2 = Ticket(name='bar', requested_text='req2', topic=self.topic, description='bar bar')
        self.ticket2.save()

    def test_ticket_timestamps(self):
        self.assertTrue(self.ticket2.created > self.ticket1.created)  # check ticket 2 is newer

        # check new update of ticket changed updated ts
        old_updated = self.ticket1.updated
        self.ticket1.description = 'updated description'
        self.ticket1.save()
        self.assertTrue(self.ticket1.updated > old_updated)

    def test_ticket_list(self):
        response = Client().get(reverse('ticket_list'))
        self.assertEqual(response.status_code, 200)

    def test_ticket_json(self):
        for langcode, langname in settings.LANGUAGES:
            response = Client().get(reverse('tickets', kwargs={'lang': langcode}))
            self.assertEqual(response.status_code, 200)

    def test_ticket_detail(self):
        response = Client().get(reverse('ticket_detail', kwargs={'pk': self.ticket1.id}))
        self.assertEqual(response.status_code, 200)

    def test_ticket_absolute_url(self):
        t = self.ticket1
        self.assertEqual(reverse('ticket_detail', kwargs={'pk': t.id}), t.get_absolute_url())

    def test_topic_list(self):
        response = Client().get(reverse('topic_list'))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context['topic_list']), 1)

    def test_topic_detail(self):
        response = Client().get(reverse('topic_detail', kwargs={'pk': self.topic.id}))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context['topic'].ticket_set.all()), 2)

    def test_topic_absolute_url(self):
        t = self.topic
        self.assertEqual(reverse('topic_detail', kwargs={'pk': t.id}), t.get_absolute_url())

    def _test_one_feed(self, url_name, topic_id, expected_ticket_count):
        url_kwargs = {'pk': topic_id} if topic_id is not None else {}
        response = Client().get(reverse(url_name, kwargs=url_kwargs))
        self.assertEqual(response.status_code, 200)
        items_in_response = re.findall(r'<item>', response.content.decode('utf-8'))  # ugly, mostly works
        self.assertEqual(expected_ticket_count, len(items_in_response))

    def test_feeds(self):
        self.ticket1.add_acks('user_content')
        self._test_one_feed('ticket_list_feed', None, 2)
        self._test_one_feed('ticket_submitted_feed', None, 1)
        self._test_one_feed('topic_ticket_feed', self.topic.id, 2)
        self._test_one_feed('topic_submitted_ticket_feed', self.topic.id, 1)

    def test_historical(self):
        self.ticket1.imported = True
        self.ticket1.save()
        self.assertEqual(self.ticket1.state_str(), 'historical')

    def test_is_completed(self):
        self.assertFalse(self.ticket1.is_completed)
        self.ticket1.add_acks('archive')
        self.assertTrue(self.ticket1.is_completed)
        self.ticket1.ticketack_set.filter(ack_type='archive').delete()
        self.assertFalse(self.ticket1.is_completed)

        self.ticket1.add_acks('close')
        self.assertTrue(self.ticket1.is_completed)
        self.ticket1.ticketack_set.filter(ack_type='close').delete()
        self.assertFalse(self.ticket1.is_completed)
Example #26
0
    def test_ticket_edit(self):
        topic = Topic(name='topic', grant=Grant.objects.create(full_name='g', short_name='g', slug='g'))
        topic.save()

        statutory_topic = Topic(name='statutory_topic', ticket_statutory_declaration=True, grant=Grant.objects.get(short_name='g'))
        statutory_topic.save()

        subtopic = Subtopic(name='subtopic', topic=topic)
        subtopic2 = Subtopic(name='subtopic2', topic=statutory_topic)
        subtopic.save()
        subtopic2.save()

        password = '******'
        user = User(username='******')
        user.set_password(password)
        user.save()

        ticket = Ticket(name='ticket', topic=topic, requested_user=None, requested_text='foo')
        ticket.save()
        ticket.add_acks('close')

        c = Client()
        response = c.get(reverse('edit_ticket', kwargs={'pk': ticket.id}))
        self.assertEqual(302, response.status_code)  # should be redirect to login page

        c.login(username=user.username, password=password)
        response = c.get(reverse('edit_ticket', kwargs={'pk': ticket.id}))
        self.assertEqual(403, response.status_code)  # denies edit of non-own ticket

        ticket.requested_user = user
        ticket.requested_text = ''
        ticket.save()
        response = c.get(reverse('edit_ticket', kwargs={'pk': ticket.id}))
        self.assertEqual(403, response.status_code)  # still deny edit, ticket locked

        ticket.ticketack_set.filter(ack_type='close').delete()
        response = c.get(reverse('edit_ticket', kwargs={'pk': ticket.id}))
        self.assertEqual(200, response.status_code)  # now it should pass

        # try to submit the form
        response = c.post(reverse('edit_ticket', kwargs={'pk': ticket.id}), {
            'name': 'new name',
            'topic': ticket.topic.id,
            'description': 'new desc',
            'deposit': '0',
            'expediture-INITIAL_FORMS': '0',
            'expediture-TOTAL_FORMS': '0',
            'preexpediture-INITIAL_FORMS': '0',
            'preexpediture-TOTAL_FORMS': '0',
        })
        self.assertRedirects(response, reverse('ticket_detail', kwargs={'pk': ticket.id}))

        # check changed ticket data
        ticket = Ticket.objects.get(id=ticket.id)
        self.assertEqual(user, ticket.requested_user)
        self.assertEqual('new name', ticket.name)
        self.assertEqual('new desc', ticket.description)

        # b0rked expediture items aborts the submit
        response = c.post(reverse('edit_ticket', kwargs={'pk': ticket.id}), {
            'name': 'ticket',
            'topic': ticket.topic.id,
            'description': 'some desc',
            'deposit': '0',
            'expediture-INITIAL_FORMS': '0',
            'expediture-TOTAL_FORMS': '1',
            'expediture-0-description': 'foo',
            'expediture-0-amount': '',
            'preexpediture-INITIAL_FORMS': '0',
            'preexpediture-TOTAL_FORMS': '0',
        })
        self.assertEqual(200, response.status_code)
        self.assertEqual('This field is required.', response.context['expeditures'].forms[0].errors['amount'][0])

        # add some inline items
        response = c.post(reverse('edit_ticket', kwargs={'pk': ticket.id}), {
            'name': 'new name',
            'topic': ticket.topic.id,
            'description': 'new desc',
            'deposit': '0',
            'expediture-INITIAL_FORMS': '0',
            'expediture-TOTAL_FORMS': '2',
            'expediture-0-description': 'ten fifty',
            'expediture-0-amount': '10.50',
            'expediture-1-description': 'hundred',
            'expediture-1-amount': '100',
            'preexpediture-INITIAL_FORMS': '0',
            'preexpediture-TOTAL_FORMS': '0',
        })
        self.assertRedirects(response, reverse('ticket_detail', kwargs={'pk': ticket.id}))
        expeditures = ticket.expediture_set.order_by('amount')
        self.assertEqual(2, len(expeditures))
        self.assertEqual('ten fifty', expeditures[0].description)
        self.assertEqual(10.5, expeditures[0].amount)
        self.assertEqual('hundred', expeditures[1].description)
        self.assertEqual(100, expeditures[1].amount)

        # edit inline items
        response = c.post(reverse('edit_ticket', kwargs={'pk': ticket.id}), {
            'name': 'new name',
            'topic': ticket.topic.id,
            'description': 'new desc',
            'deposit': '0',
            'expediture-INITIAL_FORMS': '2',
            'expediture-TOTAL_FORMS': '3',
            'expediture-0-id': expeditures[0].id,
            'expediture-0-description': 'ten fifty',
            'expediture-0-amount': '10.50',
            'expediture-0-DELETE': 'on',
            'expediture-1-id': expeditures[1].id,
            'expediture-1-description': 'hundred+1',
            'expediture-1-amount': '101',
            'expediture-2-description': '',
            'expediture-2-amount': '',
            'preexpediture-INITIAL_FORMS': '0',
            'preexpediture-TOTAL_FORMS': '0',
        })
        self.assertRedirects(response, reverse('ticket_detail', kwargs={'pk': ticket.id}))
        expeditures = ticket.expediture_set.order_by('amount')
        self.assertEqual(1, len(expeditures))
        self.assertEqual('hundred+1', expeditures[0].description)
        self.assertEqual(101, expeditures[0].amount)

        # add preexpeditures, and amount flag preack
        deposit_amount = Decimal('12324.37')
        ticket = Ticket.objects.get(id=ticket.id)
        ticket.deposit = deposit_amount
        ticket.preexpediture_set.create(description='some preexp', amount=15)
        ticket.save()
        ticket.add_acks('precontent')

        # edit should work and ignore new data
        response = c.post(reverse('edit_ticket', kwargs={'pk': ticket.id}), {
            'name': 'new name',
            'topic': ticket.topic.id,
            'description': 'new desc',
            'deposit': '333',
            'expediture-INITIAL_FORMS': '0',
            'expediture-TOTAL_FORMS': '0',
            'preexpediture-INITIAL_FORMS': '0',
            'preexpediture-TOTAL_FORMS': '0',
        })
        self.assertRedirects(response, reverse('ticket_detail', kwargs={'pk': ticket.id}))
        ticket = Ticket.objects.get(id=ticket.id)
        self.assertEqual(deposit_amount, ticket.deposit)
        self.assertEqual(1, ticket.preexpediture_set.count())

        # also, edit should work and not fail on missing preack-ignored fields
        response = c.post(reverse('edit_ticket', kwargs={'pk': ticket.id}), {
            'name': 'new name',
            'topic': ticket.topic.id,
            'description': 'new desc',
            'expediture-INITIAL_FORMS': '0',
            'expediture-TOTAL_FORMS': '0',
        })
        self.assertRedirects(response, reverse('ticket_detail', kwargs={'pk': ticket.id}))
        ticket = Ticket.objects.get(id=ticket.id)
        self.assertEqual(deposit_amount, ticket.deposit)
        self.assertEqual(1, ticket.preexpediture_set.count())
Example #27
0
class TicketEditLinkTests(TestCase):
    def setUp(self):
        self.topic = Topic(name='topic', grant=Grant.objects.create(full_name='g', short_name='g'))
        self.topic.save()
        
        self.password = '******'
        self.user = User(username='******')
        self.user.set_password(self.password)
        self.user.save()
        
        self.ticket = Ticket(summary='ticket', topic=self.topic, requested_user=None, requested_text='foo')
        self.ticket.save()
    
    def get_ticket_response(self):
        c = Client()
        c.login(username=self.user.username, password=self.password)
        response = c.get(reverse('ticket_detail', kwargs={'pk':self.ticket.id}))
        self.assertEqual(response.status_code, 200)
        return response
    
    def test_clear_ticket(self):
        response = self.get_ticket_response()
        self.assertEqual(False, response.context['user_can_edit_ticket'])
        self.assertEqual(False, response.context['user_can_edit_ticket_in_admin'])
        
    def test_own_ticket(self):
        self.ticket.requested_user = self.user
        self.ticket.save()
        response = self.get_ticket_response()
        self.assertEqual(True, response.context['user_can_edit_ticket'])
        self.assertEqual(False, response.context['user_can_edit_ticket_in_admin'])
    
    def test_bare_admin(self):
        self.user.is_staff = True
        self.user.save()
        response = self.get_ticket_response()
        self.assertEqual(False, response.context['user_can_edit_ticket'])
        self.assertEqual(False, response.context['user_can_edit_ticket_in_admin'])
    
    def test_tracker_supervisor(self):
        self.user.is_staff = True
        topic_content = ContentType.objects.get(app_label='tracker', model='Topic')
        self.user.user_permissions.add(Permission.objects.get(content_type=topic_content, codename='supervisor'))
        self.user.save()
        
        response = self.get_ticket_response()
        self.assertEqual(False, response.context['user_can_edit_ticket'])
        self.assertEqual(True, response.context['user_can_edit_ticket_in_admin'])
        
    def test_total_supervisor(self):
        self.user.is_staff = True
        self.user.is_superuser = True
        self.user.save()
        
        response = self.get_ticket_response()
        self.assertEqual(False, response.context['user_can_edit_ticket'])
        self.assertEqual(True, response.context['user_can_edit_ticket_in_admin'])
    
    def test_own_topic(self):
        self.user.is_staff = True
        self.user.topic_set.add(self.topic)
        self.user.save()
        
        response = self.get_ticket_response()
        self.assertEqual(False, response.context['user_can_edit_ticket'])
        self.assertEqual(True, response.context['user_can_edit_ticket_in_admin'])
Example #28
0
class TicketEditLinkTests(TestCase):
    def setUp(self):
        self.topic = Topic(name='topic', grant=Grant.objects.create(full_name='g', short_name='g', slug='g'))
        self.topic.save()

        self.password = '******'
        self.user = User(username='******')
        self.user.set_password(self.password)
        self.user.save()

        self.ticket = Ticket(name='ticket', topic=self.topic, requested_user=None, requested_text='foo')
        self.ticket.save()

    def get_ticket_response(self):
        c = Client()
        c.login(username=self.user.username, password=self.password)
        response = c.get(reverse('ticket_detail', kwargs={'pk': self.ticket.id}))
        self.assertEqual(response.status_code, 200)
        return response

    def test_clear_ticket(self):
        response = self.get_ticket_response()
        self.assertEqual(False, response.context['user_can_edit_ticket'])
        self.assertEqual(False, response.context['user_can_edit_ticket_in_admin'])

    def test_own_ticket(self):
        self.ticket.requested_user = self.user
        self.ticket.save()
        response = self.get_ticket_response()
        self.assertEqual(True, response.context['user_can_edit_ticket'])
        self.assertEqual(False, response.context['user_can_edit_ticket_in_admin'])

    def test_bare_admin(self):
        self.user.is_staff = True
        self.user.save()
        response = self.get_ticket_response()
        self.assertEqual(False, response.context['user_can_edit_ticket'])
        self.assertEqual(False, response.context['user_can_edit_ticket_in_admin'])

    def test_tracker_supervisor(self):
        self.user.is_staff = True
        topic_content = ContentType.objects.get(app_label='tracker', model='Topic')
        self.user.user_permissions.add(Permission.objects.get(content_type=topic_content, codename='supervisor'))
        self.user.save()

        response = self.get_ticket_response()
        self.assertEqual(False, response.context['user_can_edit_ticket'])
        self.assertEqual(True, response.context['user_can_edit_ticket_in_admin'])

    def test_total_supervisor(self):
        self.user.is_staff = True
        self.user.is_superuser = True
        self.user.save()

        response = self.get_ticket_response()
        self.assertEqual(False, response.context['user_can_edit_ticket'])
        self.assertEqual(True, response.context['user_can_edit_ticket_in_admin'])

    def test_own_topic(self):
        self.user.is_staff = True
        self.user.topic_set.add(self.topic)
        self.user.save()

        response = self.get_ticket_response()
        self.assertEqual(False, response.context['user_can_edit_ticket'])
        self.assertEqual(True, response.context['user_can_edit_ticket_in_admin'])
Example #29
0
class SummaryTest(TestCase):
    def setUp(self):
        self.user = User(username='******')
        self.user.save()

        self.topic = Topic(name='test_topic', ticket_expenses=True, grant=Grant.objects.create(full_name='g', short_name='g', slug='g'))
        self.topic.save()

        self.ticket = Ticket(name='foo', requested_user=self.user, topic=self.topic, rating_percentage=50)
        self.ticket.save()
        self.ticket.add_acks('content', 'docs', 'archive')
        self.ticket.expediture_set.create(description='foo', amount=200)
        self.ticket.expediture_set.create(description='foo', amount=100)
        self.ticket.mediainfoold_set.create(description='foo', count=5)
        self.ticket.mediainfo_set.create(name='test.jpg')
        self.ticket.mediainfo_set.create(name='test2.jpg')

        self.ticket2 = Ticket(name='foo', requested_user=self.user, topic=self.topic, rating_percentage=100)
        self.ticket2.save()
        self.ticket2.add_acks('content', 'docs', 'archive')
        self.ticket2.expediture_set.create(description='foo', amount=600)
        self.ticket2.expediture_set.create(description='foo', amount=10)
        self.ticket2.mediainfoold_set.create(description='foo', count=5)
        self.ticket2.mediainfoold_set.create(description='foo', count=3)
        self.ticket2.mediainfo_set.create(name='test.jpg')

    def test_topic_ticket_counts(self):
        self.assertEqual({'unpaid': 2}, self.topic.tickets_per_payment_status())
        for e in self.ticket.expediture_set.all():
            e.paid = True
            e.save()
        self.assertEqual({'unpaid': 1, 'paid': 1}, self.topic.tickets_per_payment_status())

    def test_topic_ticket_counts2(self):
        """ change event_date (and thus sort_date) of one ticket, make sure it
            does not break grouping
        """
        self.ticket.event_date = datetime.date(2016, 1, 1)
        self.ticket.save()
        self.assertEqual({'unpaid': 2}, self.topic.tickets_per_payment_status())

    def test_ticket_name(self):
        self.ticket.ticketack_set.filter(ack_type='content').delete()
        self.ticket.rating_percentage = None
        self.ticket.save()

        self.assertEqual(7, self.ticket.media_count())
        self.assertEqual({'objects': 1, 'media': 5}, self.ticket.media_old_count())
        self.assertEqual({'count': 2, 'amount': 300}, self.ticket.expeditures())
        self.assertEqual(0, self.ticket.accepted_expeditures())

        self.ticket.rating_percentage = 50
        self.ticket.save()
        self.assertEqual(0, self.ticket.accepted_expeditures())

        self.ticket.add_acks('content')
        self.assertEqual(150, self.ticket.accepted_expeditures())

    def test_topic_name(self):
        self.assertEqual(16, self.topic.media_count())
        self.assertEqual({'count': 4, 'amount': 910}, self.topic.expeditures())
        self.assertEqual(150 + 610, self.topic.accepted_expeditures())

    def test_user_name(self):
        profile = self.user.trackerprofile
        self.assertEqual(16, profile.media_count())
        self.assertEqual(150 + 610, profile.accepted_expeditures())

    def test_topic_finance(self):
        response = Client().get(reverse('topic_finance'))
        self.assertEqual(response.status_code, 200)
Example #30
0
class SimpleTicketTest(TestCase):
    def setUp(self):
        self.topic = Topic(name='topic1', grant=Grant.objects.create(full_name='g', short_name='g'))
        self.topic.save()
        
        self.ticket1 = Ticket(summary='foo', requested_text='req1', topic=self.topic, description='foo foo')
        self.ticket1.save()
        
        self.ticket2 = Ticket(summary='bar', requested_text='req2', topic=self.topic, description='bar bar')
        self.ticket2.save()
    
    def test_ticket_sort_date(self):
        # sort date is equal to event date (when applicable) and default to creation date
        self.assertEqual(self.ticket1.created.date(), self.ticket1.sort_date)
        
        self.ticket1.event_date = datetime.date(2011, 10, 13)
        self.ticket1.save()
        self.assertEqual(datetime.date(2011, 10, 13), self.ticket1.sort_date)
        
        self.ticket1.event_date = None
        self.ticket1.save()
        self.assertEqual(self.ticket1.created.date(), self.ticket1.sort_date)
    
    def test_ticket_timestamps(self):
        self.assertTrue(self.ticket2.created > self.ticket1.created) # check ticket 2 is newer
        
        # check new update of ticket changed updated ts
        old_updated = self.ticket1.updated
        self.ticket1.description = 'updated description'
        self.ticket1.save()
        self.assertTrue(self.ticket1.updated > old_updated)
    
    def test_ticket_list(self):
        response = Client().get(reverse('ticket_list'))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context['ticket_list']), 2)

    def test_ticket_detail(self):
        response = Client().get(reverse('ticket_detail', kwargs={'pk':self.ticket1.id}))
        self.assertEqual(response.status_code, 200)
    
    def test_ticket_url_escape(self):
        url = 'http://meta.wikimedia.org/wiki/Mediagrant/Fotografie_um%C4%9Bleck%C3%BDch_pam%C3%A1tek_v_%C4%8Cesk%C3%A9m_Krumlov%C4%9B'
        self.ticket1.description = '<a href="%s">foo link</a>' % url
        self.ticket1.save()
        response = Client().get(reverse('ticket_detail', kwargs={'pk':self.ticket1.id}))
        self.assertContains(response, 'href="%s"' % url, 1)
    
    def test_ticket_absolute_url(self):
        t = self.ticket1
        self.assertEqual(reverse('ticket_detail', kwargs={'pk':t.id}), t.get_absolute_url())
    
    def test_topic_list(self):
        response = Client().get(reverse('topic_list'))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context['topic_list']), 1)
    
    def test_javascript_topic_list(self):
        response = Client().get(reverse('topics_js'))
        self.assertEqual(response.status_code, 200)
    
    def test_topic_detail(self):
        response = Client().get(reverse('topic_detail', kwargs={'pk':self.topic.id}))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context['topic'].ticket_set.all()), 2)
    
    def test_topic_absolute_url(self):
        t = self.topic
        self.assertEqual(reverse('topic_detail', kwargs={'pk':t.id}), t.get_absolute_url())
Example #31
0
 def setUp(self):
     self.topic = Topic(name='topic', grant=Grant.objects.create(full_name='g', short_name='g', slug='g'))
     self.topic.save()
     self.ticket = Ticket(summary='foo', requested_text='req', topic=self.topic, description='foo foo')
     self.ticket.save()
Example #32
0
 def test_ticket_edit(self):
     topic = Topic(name='topic', grant=Grant.objects.create(full_name='g', short_name='g'))
     topic.save()
     
     password = '******'
     user = User(username='******')
     user.set_password(password)
     user.save()
     
     ticket = Ticket(summary='ticket', topic=topic, requested_user=None, requested_text='foo')
     ticket.save()
     ticket.add_acks('close')
     
     c = Client()
     response = c.get(reverse('edit_ticket', kwargs={'pk':ticket.id}))
     self.assertEqual(302, response.status_code) # should be redirect to login page
     
     c.login(username=user.username, password=password)
     response = c.get(reverse('edit_ticket', kwargs={'pk':ticket.id}))
     self.assertEqual(403, response.status_code) # denies edit of non-own ticket
     
     ticket.requested_user = user
     ticket.requested_text = ''
     ticket.save()
     response = c.get(reverse('edit_ticket', kwargs={'pk':ticket.id}))
     self.assertEqual(403, response.status_code) # still deny edit, ticket locked
     
     ticket.ticketack_set.filter(ack_type='close').delete()
     response = c.get(reverse('edit_ticket', kwargs={'pk':ticket.id}))
     self.assertEqual(200, response.status_code) # now it should pass
     
     # try to submit the form
     response = c.post(reverse('edit_ticket', kwargs={'pk':ticket.id}), {
             'summary': 'new summary',
             'topic': ticket.topic.id,
             'description': 'new desc',
             'mediainfo-INITIAL_FORMS': '0',
             'mediainfo-TOTAL_FORMS': '0',
             'expediture-INITIAL_FORMS': '0',
             'expediture-TOTAL_FORMS': '0',
         })
     self.assertRedirects(response, reverse('ticket_detail', kwargs={'pk':ticket.id}))
     
     # check changed ticket data
     ticket = Ticket.objects.get(id=ticket.id)
     self.assertEqual(user, ticket.requested_user)
     self.assertEqual('new summary', ticket.summary)
     self.assertEqual('new desc', ticket.description)
     
     # b0rked media item aborts the submit
     response = c.post(reverse('edit_ticket', kwargs={'pk':ticket.id}), {
             'summary': 'ticket',
             'topic': ticket.topic.id,
             'description': 'some desc',
             'mediainfo-INITIAL_FORMS': '0',
             'mediainfo-TOTAL_FORMS': '1',
             'mediainfo-0-count': 'foo',
             'mediainfo-0-description': 'image 1',
             'mediainfo-0-url': 'http://www.example.com/image1.jpg',
             'expediture-INITIAL_FORMS': '0',
             'expediture-TOTAL_FORMS': '0',
         })
     self.assertEqual(200, response.status_code)
     self.assertEqual('Enter a whole number.', response.context['mediainfo'].forms[0].errors['count'][0])
     
     # b0rked expediture items aborts the submit
     response = c.post(reverse('edit_ticket', kwargs={'pk':ticket.id}), {
             'summary': 'ticket',
             'topic': ticket.topic.id,
             'description': 'some desc',
             'mediainfo-INITIAL_FORMS': '0',
             'mediainfo-TOTAL_FORMS': '0',
             'expediture-INITIAL_FORMS': '0',
             'expediture-TOTAL_FORMS': '1',
             'expediture-0-description': 'foo',
             'expediture-0-amount': '',
         })
     self.assertEqual(200, response.status_code)
     self.assertEqual('This field is required.', response.context['expeditures'].forms[0].errors['amount'][0])
     
     # add some inline items
     response = c.post(reverse('edit_ticket', kwargs={'pk':ticket.id}), {
             'summary': 'new summary',
             'topic': ticket.topic.id,
             'description': 'new desc',
             'mediainfo-INITIAL_FORMS': '0',
             'mediainfo-TOTAL_FORMS': '3',
             'mediainfo-0-count': '',
             'mediainfo-0-description': 'image 1',
             'mediainfo-0-url': 'http://www.example.com/image1.jpg',
             'mediainfo-1-count': '',
             'mediainfo-1-description': '', 
             'mediainfo-1-url': '',
             'mediainfo-2-count': '3',
             'mediainfo-2-description': 'image 2 - group',
             'mediainfo-2-url': 'http://www.example.com/imagegroup/',
             'expediture-INITIAL_FORMS': '0',
             'expediture-TOTAL_FORMS': '2',
             'expediture-0-description': 'ten fifty',
             'expediture-0-amount': '10.50',
             'expediture-1-description': 'hundred',
             'expediture-1-amount': '100',
         })
     self.assertRedirects(response, reverse('ticket_detail', kwargs={'pk':ticket.id}))
     media = ticket.mediainfo_set.order_by('description')
     self.assertEqual(2, len(media))
     self.assertEqual('image 1', media[0].description)
     self.assertEqual('http://www.example.com/image1.jpg', media[0].url)
     self.assertEqual(None, media[0].count)
     self.assertEqual('image 2 - group', media[1].description)
     self.assertEqual('http://www.example.com/imagegroup/', media[1].url)
     self.assertEqual(3, media[1].count)
     expeditures = ticket.expediture_set.order_by('amount')
     self.assertEqual(2, len(expeditures))
     self.assertEqual('ten fifty', expeditures[0].description)
     self.assertEqual(10.5, expeditures[0].amount)
     self.assertEqual('hundred', expeditures[1].description)
     self.assertEqual(100, expeditures[1].amount)
     
     # edit inline items
     response = c.post(reverse('edit_ticket', kwargs={'pk':ticket.id}), {
             'summary': 'new summary',
             'topic': ticket.topic.id,
             'description': 'new desc',
             'mediainfo-INITIAL_FORMS': '2',
             'mediainfo-TOTAL_FORMS': '3',
             'mediainfo-0-id': media[0].id,
             'mediainfo-0-count': '1',
             'mediainfo-0-description': 'image 1 - edited',
             'mediainfo-0-url': 'http://www.example.com/second.jpg',
             'mediainfo-1-id': media[1].id,
             'mediainfo-1-DELETE': 'on',
             'mediainfo-1-count': '3',
             'mediainfo-1-description': 'image 2 - group',
             'mediainfo-1-url': 'http://www.example.com/imagegroup/',
             'mediainfo-2-count': '',
             'mediainfo-2-description': '', 
             'mediainfo-2-url': '',
             'expediture-INITIAL_FORMS': '2',
             'expediture-TOTAL_FORMS': '3',
             'expediture-0-id': expeditures[0].id,
             'expediture-0-description': 'ten fifty',
             'expediture-0-amount': '10.50',
             'expediture-0-DELETE': 'on',
             'expediture-1-id': expeditures[1].id,
             'expediture-1-description': 'hundred+1',
             'expediture-1-amount': '101',
             'expediture-2-description': '',
             'expediture-2-amount': '',
         })
     self.assertRedirects(response, reverse('ticket_detail', kwargs={'pk':ticket.id}))
     media = ticket.mediainfo_set.all()
     self.assertEqual(1, len(media))
     self.assertEqual('image 1 - edited', media[0].description)
     self.assertEqual('http://www.example.com/second.jpg', media[0].url)
     self.assertEqual(1, media[0].count)
     expeditures = ticket.expediture_set.order_by('amount')
     self.assertEqual(1, len(expeditures))
     self.assertEqual('hundred+1', expeditures[0].description)
     self.assertEqual(101, expeditures[0].amount)
 def handle(self, *args, **options):
     for ticket in Ticket.objects.all():
         acks = ticket.ack_set()
         if 'archive' not in acks and 'close' not in acks and ticket.mediainfo_set.all(
         ).count() > 0:
             Ticket.update_media(ticket.id)