Пример #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()
Пример #2
0
 def test_import_csv_categories_clean(self, requests_post,
                                      utils_get_landowner):
     """Check if clean removes existing objects"""
     cat = Category(name='Testcategory')
     cat.save()
     cmd = BaseCommand()
     cati = CategoryImporter(cmd, './legacy/tests/basic-cat.csv')
     self.assertEqual(Category.objects.count(), 11)
Пример #3
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)
Пример #4
0
 def test_import_csv_issues_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()
     for x in range(1, 8):
         cat = Category(id=x, name='A' + str(x), parent=catA)
         cat.save()
     requests_post.json.return_value = {'features': []}
     utils_get_landowner.return_value = 'TEST landowner'
     ii = IssueImporter(cmd, './legacy/tests/basic.csv')
     self.assertEqual(Issue.objects.count(), 8)
Пример #5
0
 def parseRow(self, row):
     id = row['id']
     name = row['name']
     typeClass = row['typ']
     parent_id = row['parent']
     if parent_id == '':
         # a Maincategory
         parent = self.typeMap[typeClass]
         cat = Category(id=id, name=name, parent=parent)
     else:
         # a Subcategory
         parent = Category.objects.get(id=parent_id)
         cat = Category(id=id, name=name, parent=parent)
     cat.save()
Пример #6
0
def insert(request):
    """
    执行添加商品类别页面
    """
    try:
        category_info = Category()
        category_info.name = request.POST['name']
        category_info.pid = request.POST['pid']
        category_info.path = request.POST['path']
        category_info.save()
        context = {'info': '会员信息添加成功'}
    except Exception as err:
        context = {'info': '会员信息添加失败: %s' % str(err)}
    return render(request, 'myadmin/info.html', context)
Пример #7
0
 def setUp(self):
     # Create a 3 level cat hierachy
     ideen = Category(name=Category.IDEA)
     ideen.save()
     mainCat = Category(name='main cat', parent=ideen)
     mainCat.save()
     catA = Category(name='test sub cat A', parent=mainCat)
     catA.save()
     catB = Category(name='test sub cat B', parent=mainCat)
     catB.save()
Пример #8
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)
Пример #9
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)
Пример #10
0
 def eraseObjects(self):
     Category.objects.all().delete()
     problem = Category(id=200, name=Category.PROBLEM)
     problem.save()
     idea = Category(id=201, name=Category.IDEA)
     idea.save()
     tip = Category(id=202, name=Category.TIP)
     tip.save()
     self.typeMap = {"problem": problem, "idee": idea, "tipp": tip}
Пример #11
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)