Exemplo n.º 1
0
 def setUp(self, requests_post, get_landowner):
     group = Group(name='testers')
     group.save()
     cat = Category(name='test cat')
     cat.save()
     # we fake some 3rd party API calls
     requests_post.json.return_value = {'features': []}
     get_landowner.return_value = 'TEST landowner'
     # our test issues
     Issue(id=0,
           description='A wip issue',
           position=Point(54.1, 12.1, srid=4326),
           category=cat,
           created_at=timezone.now(),
           status=StatusTypes.WIP,
           published=True,
           assigned=group).save()
     Issue(description='A very fresh issue',
           position=Point(54.1, 12.1, srid=4326),
           category=cat,
           created_at=timezone.now(),
           status=StatusTypes.SUBMITTED,
           published=True,
           assigned=group).save()
     Issue(description='A old finished issue',
           position=Point(54.1, 12.1, srid=4326),
           category=cat,
           created_at=timezone.now(),
           status=StatusTypes.SOLVED,
           published=False,
           assigned=group,
           photo='testphoto.jpg').save()
Exemplo n.º 2
0
 def test_start_qa(self, requests_post, get_landowner):
     """Do we find all QA critical issues?"""
     tester = User(username='******', password=make_password('test'))
     tester.save()
     group = Group(name='testers')
     group.save()
     group.user_set.add(tester)
     group.save()
     cat = Category(name='test cat')
     cat.save()
     requests_post.json.return_value = {'features': []}
     get_landowner.return_value = 'TEST landowner'
     Issue(description='A old issue',
           position=Point(54.1, 12.1, srid=4326),
           category=cat,
           created_at=timezone.now() - timedelta(days=30),
           status=StatusTypes.WIP,
           published=False,
           assigned=group).save()
     Issue(description='Old assigned but unreviewed issue',
           position=Point(54.1, 12.1, srid=4326),
           category=cat,
           created_at=timezone.now() - timedelta(days=30),
           status=StatusTypes.REVIEW,
           published=False,
           assigned=group).save()
     Issue(description='Another Old assigned but unreviewed issue',
           position=Point(54.1, 12.1, srid=4326),
           category=cat,
           created_at=timezone.now() - timedelta(days=20),
           status=StatusTypes.REVIEW,
           published=False,
           assigned=group).save()
     Issue(description='Assigned very new issue',
           position=Point(54.1, 12.1, srid=4326),
           category=cat,
           created_at=timezone.now(),
           status=StatusTypes.REVIEW,
           published=False,
           assigned=group).save()
     Issue(description='Unupdated issue',
           position=Point(54.1, 12.1, srid=4326),
           category=cat,
           created_at=timezone.now() - timedelta(days=35),
           status=StatusTypes.WIP,
           status_created_at=timezone.now() - timedelta(days=35),
           published=True,
           assigned=group).save()
     # Check if we get only old unreviewed issues back
     self.client.login(username='******', password='******')
     response = self.client.get(reverse('office:start'))
     qs = response.context['issues3dunchecked']
     self.assertEqual(len(qs), 2)
     qs = response.context['issues30dunupdated']
     self.assertEqual(len(qs), 1)
Exemplo n.º 3
0
 def parseRow(self, row):
     # TODO: Exception handling and malformed fields?
     id = row['id']
     logger.debug('parsing {}'.format(id))
     descr = row['beschreibung']
     email = row['autor_email']
     trust = row['trust']
     positionEwkb = row['ovi']
     categoryId = row['kategorie']
     photoFilename = row['foto_gross']
     created = row['datum']
     location = row['adresse']
     priority = row['prioritaet']
     landowner = row['flurstueckseigentum']
     assigned = row['zustaendigkeit']
     assigned_state = row['zustaendigkeit_status']
     delegated = row['delegiert_an']
     status = row['status']
     status_text = row['status_kommentar']
     status_created_at = row['status_datum']
     archive = row['archiviert']
     public_photo = row['foto_freigabe_status']
     public_descr = row['beschreibung_freigabe_status']
     if email == self.EMAIL_HIDDEN:
         email = None
     trust = self.MAP_TRUST[trust]
     cat = Category.objects.get(id=categoryId)
     if cat is None:
         self.cmd.stdout.write(self.cmd.style.ERROR('Error - No category found (Issue {}, Cat.Id. {})'.format(id, categoryId)))
     if photoFilename == '':
         photoFilename = None
     created = dateparse.parse_datetime(created)
     created=created.replace(tzinfo=timezone(timedelta(hours=1)))
     if location == self.LOCATION_UNKOWN:
         location = None
     priority = self.MAP_PRIORITY[priority]
     if assigned_state == self.ASSIGNED_OK:
         group_assigned, was_created = Group.objects.get_or_create(name=assigned)
     else:
         group_assigned = None
     if delegated == '':
         group_delegated = None
     else:
         group_delegated, was_created = Group.objects.get_or_create(name=delegated)
     status = self.MAP_STATUS[status]
     status_created_at = dateparse.parse_datetime(status_created_at)
     status_created_at = status_created_at.replace(tzinfo=timezone(timedelta(hours=1)))
     published = self.MAP_ARCHIVE[archive]
     if published == True:
         # Check if all content is published
         if self.MAP_PUBLIC[public_photo] and self.MAP_PUBLIC[public_descr]:
             published = True
         else:
             published = False
     issue = Issue(id=id, description=descr, author_email=email, author_trust=trust, position=positionEwkb, category=cat, photo=photoFilename, created_at=created, location=location, priority=priority, landowner=landowner, assigned=group_assigned, delegated=group_delegated, status=status, status_text=status_text, status_created_at=status_created_at, published=published)
     return issue
Exemplo n.º 4
0
 def test_import_csv_feedback_basic(self, requests_post,
                                    utils_get_landowner):
     """Check if parsing a wellformed CSV works fine"""
     cmd = BaseCommand()
     catA = Category(id=0, name='Category A')
     catA.save()
     requests_post.json.return_value = {'features': []}
     utils_get_landowner.return_value = 'TEST landowner'
     issue = Issue(id=1,
                   description="test issue with defined id",
                   position=Point(5, 23),
                   category=catA)
     issue.save()
     issue = Issue(id=2,
                   description="test issue with defined id",
                   position=Point(5, 23),
                   category=catA)
     issue.save()
     fbi = FeedbackImporter(cmd, './legacy/tests/basic-feedback.csv')
     self.assertEqual(Feedback.objects.count(), 2)
Exemplo n.º 5
0
 def test_new_Issue(self, requests_post, get_landowner):
     """
     Can we create specific issues?
     """
     #requests_post.status_code.return_value = 200
     requests_post.json.return_value = {'features': []}
     get_landowner.return_value = 'TEST landowner'
     cat = Category(name="test category")
     cat.save()
     issue = Issue(description="test issue",
                   position=Point(5, 23),
                   category=cat)
     issue.save()
     self.assertEqual(len(Issue.objects.all()), 1)
     issue = Issue(id=666,
                   description="test issue with defined id",
                   position=Point(5, 23),
                   category=cat)
     issue.save()
     self.assertEqual(issue.id, 666)
Exemplo n.º 6
0
 def test_detail_assigned(self, requests_post, get_landowner):
     tester = User(username='******', password=make_password('test'))
     tester.save()
     self.client.login(username='******', password='******')
     group = Group(name='testers')
     group.save()
     group.user_set.add(tester)
     group.save()
     cat = Category(name='test cat')
     cat.save()
     requests_post.json.return_value = {'features': []}
     get_landowner.return_value = 'TEST landowner'
     myIssue = Issue(description='My issue',
                     position=Point(54.1, 12.1, srid=4326),
                     category=cat,
                     created_at=timezone.now(),
                     status=StatusTypes.WIP,
                     published=False,
                     assigned=group)
     myIssue.save()
     response = self.client.get(
         reverse('office:issue', kwargs={'pk': myIssue.id}))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.context['issue'], myIssue)
     # Everybody should at least read
     otherIssue = Issue(description='Not mine',
                        position=Point(54.1, 12.1, srid=4326),
                        category=cat,
                        created_at=timezone.now(),
                        status=StatusTypes.WIP,
                        published=False,
                        assigned=group)
     otherIssue.save()
     response = self.client.get(
         reverse('office:issue', kwargs={'pk': otherIssue.id}))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.context['issue'], otherIssue)