예제 #1
0
    def test_dep_station_events(self):
        dep = Factory.DepFactory()
        set = models.SetStationEventCode.objects.get(pk=1)

        self.assertEquals(dep.station_events.count(), 0)

        ste = Factory.SteFactory(dep=dep, set_type=set)

        self.assertEquals(dep.station_events.count(), 1)
        self.assertEquals(dep.station_events.first().dep, dep)
        self.assertEquals(dep.station_events.first().set_type, set)
예제 #2
0
    def test_update_dep_test_func_denied(self):
        dep = Factory.DepFactory()

        self.login_whale_user()
        response = self.client.get(reverse_lazy('whalesdb:update_dep', args=(dep.pk,)))

        self.assertTrue(response.context['editable'])

        # create a deployment event
        set_type = models.SetStationEventCode.objects.get(pk=1)  # 1 == Deployment event
        dep_evt = Factory.SteFactory(dep=dep, set_type=set_type)

        response = self.client.get(reverse_lazy('whalesdb:update_dep', args=(dep.pk,)))

        # deployment should no longer be editable
        self.assertFalse(response.context['editable'])
예제 #3
0
    def test_update_dep_test_func_denied(self):
        dep = Factory.DepFactory()

        # have to create the request and setup the view
        req_factory = RequestFactory()
        request = req_factory.get(reverse_lazy("whalesdb:update_dep", kwargs={'pk': dep.pk, 'pop': 'pop'}))
        request.user = self.login_whale_user()
        view = setup_view(views.DepUpdate(), request, pk=dep.pk)

        # check to see if a deployment that's not been deployed can be edited
        self.assertTrue(view.test_func())

        # create a deployment event
        set_type = models.SetStationEventCode.objects.get(pk=1)  # 1 == Deployment event
        dep_evt = Factory.SteFactory(dep=dep, set_type=set_type)

        # deployment should no longer be editable
        self.assertFalse(view.test_func())
예제 #4
0
    def setUp(self):
        super().setUp()

        self.data = Factory.SteFactory.get_valid_data()

        obj = Factory.SteFactory()

        self.data['dep'] = obj.dep_id

        self.test_url = reverse_lazy('whalesdb:update_ste', args=(obj.dep_id, obj.pk, 'pop',))

        self.test_expected_template = 'shared_models/shared_entry_form.html'

        self.expected_view = views.SteUpdate

        self.expected_form = forms.SteForm

        self.expected_success_url = reverse_lazy("shared_models:close_me_no_refresh")
예제 #5
0
    def test_details_dep_context_auth_denied(self):
        activate('en')

        dep = Factory.DepFactory()
        test_url = reverse_lazy("whalesdb:details_dep", kwargs={'pk': dep.pk})

        self.login_whale_user()
        response = self.client.get(test_url)

        self.assertIn("editable", response.context)
        self.assertTrue(response.context['editable'])

        # create a deployment event
        set_type = models.SetStationEventCode.objects.get(
            pk=1)  # 1 == Deployment event
        dep_evt = Factory.SteFactory(dep=dep, set_type=set_type)

        response = self.client.get(test_url)

        self.assertIn("editable", response.context)
        self.assertTrue(response.context['auth'])
        self.assertFalse(response.context['editable'])