Esempio n. 1
0
 def setUp(self):
     self.border_station = BorderStationFactory.create()
     self.budget_calc_sheet = BorderStationBudgetCalculationFactory.create(
         border_station=self.border_station)
     self.superuser = SuperUserFactory.create()
     self.client = APIClient()
     self.client.force_authenticate(user=self.superuser)
Esempio n. 2
0
 def setUp(self):
     self.factory = APIRequestFactory()
     self.user = GenericUserWithPermissions.create([
         {
             'group': 'BUDGETS',
             'action': 'VIEW',
             'country': None,
             'station': None
         },
         {
             'group': 'BUDGETS',
             'action': 'ADD',
             'country': None,
             'station': None
         },
         {
             'group': 'BUDGETS',
             'action': 'EDIT',
             'country': None,
             'station': None
         },
         {
             'group': 'BUDGETS',
             'action': 'DELETE',
             'country': None,
             'station': None
         },
     ])
     self.client = APIClient()
     self.client.force_authenticate(user=self.user)
     self.border_station = BorderStationFactory()
Esempio n. 3
0
    def testRemoveBudgetSheetStationNoPermission(self):
        border_station = BorderStationFactory()
        user = GenericUserWithPermissions.create([
            {
                'group': 'BUDGETS',
                'action': 'VIEW',
                'country': None,
                'station': None
            },
            {
                'group': 'BUDGETS',
                'action': 'ADD',
                'country': None,
                'station': None
            },
            {
                'group': 'BUDGETS',
                'action': 'DELETE',
                'country': None,
                'station': border_station
            },
        ])
        client = APIClient()
        client.force_authenticate(user=user)

        response = client.get('/api/budget/')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.data['results']), 0)

        response = client.post(
            '/api/budget/', {
                "border_station": self.border_station.pk,
                "month_year": "2017-04-15T23:53:08.996000Z"
            })
        budget_id = response.data.get('id')
        self.assertEqual(response.status_code, 201)

        response = client.get('/api/budget/')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.data['results']), 1)

        # delete the form
        response = client.delete('/api/budget/' + str(budget_id) + '/')
        self.assertEqual(response.status_code, 403)

        # count the remaining forms
        response = client.get('/api/budget/')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.data['results']), 1)
Esempio n. 4
0
    def testUpdateBudgetSheetStationNoPermission(self):
        border_station = BorderStationFactory()
        user = GenericUserWithPermissions.create([
            {
                'group': 'BUDGETS',
                'action': 'VIEW',
                'country': None,
                'station': None
            },
            {
                'group': 'BUDGETS',
                'action': 'ADD',
                'country': None,
                'station': None
            },
            {
                'group': 'BUDGETS',
                'action': 'EDIT',
                'country': None,
                'station': border_station
            },
        ])
        client = APIClient()
        client.force_authenticate(user=user)

        response = client.post(
            '/api/budget/', {
                "border_station": self.border_station.pk,
                "month_year": "2017-04-15T23:53:08.996000Z"
            })
        budget_id = response.data.get('id')
        self.assertEqual(response.status_code, 201)

        response = client.get('/api/budget/' + str(budget_id) + '/')
        budget_id = response.data.get('id')
        self.assertEqual(response.status_code, 200)

        response = client.put(
            '/api/budget/' + str(budget_id) + '/', {
                "border_station": self.border_station.pk,
                "shelter_water_amount": 2,
                "month_year": "2017-04-15T23:53:08.996000Z"
            })
        budget_id = response.data.get('id')
        self.assertEqual(response.status_code, 403)
Esempio n. 5
0
 def testCreateBudgetSheetStationNoPermission(self):
     border_station = BorderStationFactory()
     user = GenericUserWithPermissions.create([
         {
             'group': 'BUDGETS',
             'action': 'VIEW',
             'country': None,
             'station': None
         },
         {
             'group': 'BUDGETS',
             'action': 'ADD',
             'country': None,
             'station': border_station
         },
     ])
     client = APIClient()
     client.force_authenticate(user=user)
     response = client.post(
         '/api/budget/', {
             "border_station": self.border_station.pk,
             "month_year": "2017-06-15T23:53:08.996000Z"
         })
     self.assertEqual(response.status_code, 201)
Esempio n. 6
0
 def setUp(self):
     self.superuser = SuperUserFactory.create()
     BorderStationFactory.create()
     url = reverse("victiminterview_create")
     self.response = self.app.get(url, user=self.superuser)
     self.form = self.response.form