示例#1
0
    def test_create_eda_eqp_filter(self):
        activate('en')

        dep = Factory.DepFactory()
        emm = Factory.EmmFactory(eqt=models.EqtEquipmentTypeCode.objects.get(
            pk=1))
        eqp1 = Factory.EqpFactory(emm=emm)
        eqp2 = Factory.EqpFactory(emm=emm)
        eqp3 = Factory.EqpFactory(emm=emm)

        models.EdaEquipmentAttachment(dep=dep, eqp=eqp1).save()

        models.EdaEquipmentAttachment(dep=dep, eqp=eqp2).save()

        test_url = reverse_lazy('whalesdb:create_eda', args=(dep.pk, ))

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

        eqp_field = response.context_data["form"].fields['eqp']

        # Confusing, but there are four pieces of equipment at this point, one is created in the setup function.
        # Two of the four have been attached to the deployment created in this test case, so only two pieces of
        # equipment should be returned in the queryset.

        self.assertEqual(2, eqp_field.queryset.count())
示例#2
0
    def setUp(self):
        super().setUp()
        eqt = models.EqtEquipmentTypeCode.objects.get(pk=4)
        emm = Factory.EmmFactory(eqt=eqt)
        eca_hydrophone = Factory.EqpFactory(emm=emm)

        self.eca = Factory.EcaFactory(eca_hydrophone=eca_hydrophone)

        self.test_url = reverse_lazy('whalesdb:details_eca', args=(self.eca.pk,))
        self.test_expected_template = 'whalesdb/details_eca.html'
        self.fields = []
示例#3
0
    def createDict(self):
        if self._details_dict:
            return self._details_dict

        self._details_dict = {}

        obj = Factory.EqpFactory()

        self._details_dict['eqp_1'] = obj

        return self._details_dict
示例#4
0
    def test_ehe_field_filter(self):
        recorder = factory.EmmFactory()
        recorder.eqt = models.EqtEquipmentTypeCode.objects.get(pk=1)
        recorder.save()

        hydrophone = factory.EmmFactory()
        hydrophone.eqt = models.EqtEquipmentTypeCode.objects.get(pk=4)
        hydrophone.save()

        rec_1 = factory.EqpFactory(emm=recorder)
        rec_2 = factory.EqpFactory(emm=recorder)

        hydro_1 = factory.EqpFactory(emm=hydrophone)

        form = self.form_class()

        self.assertIn("hyd", form.fields)
        self.assertNotIn(rec_1, form.fields['hyd'].queryset)
        self.assertNotIn(rec_2, form.fields['hyd'].queryset)
        self.assertIn(hydro_1, form.fields['hyd'].queryset)
示例#5
0
    def setUp(self):
        super().setUp()

        eqt = models.EqtEquipmentTypeCode.objects.get(pk=4)
        emm = Factory.EmmFactory(eqt=eqt)
        eca_hydrophone = Factory.EqpFactory(emm=emm)

        self.etr = Factory.EtrFactory(hyd=eca_hydrophone)

        self.test_url = reverse_lazy('whalesdb:details_etr', args=(self.etr.pk,))
        self.test_expected_template = 'whalesdb/whales_details.html'
        self.fields = ['eqp', 'etr_date', 'etr_issue_desc', 'etr_repair_desc', 'etr_repaired_by', 'etr_dep_affe',
                       'etr_rec_affe']
示例#6
0
    def test_eda_field_filter(self):
        recorder = factory.EmmFactory(pk=1)
        hydrophone = factory.EmmFactory(pk=4)

        rec_1 = factory.EqpFactory.create(emm=recorder)
        rec_2 = factory.EqpFactory.create(emm=recorder)

        hydro_1 = factory.EqpFactory(emm=hydrophone)

        form = self.form_class()

        self.assertIn("eqp", form.fields)
        self.assertIn(rec_1, form.fields['eqp'].queryset)
        self.assertIn(rec_2, form.fields['eqp'].queryset)
        self.assertNotIn(hydro_1, form.fields['eqp'].queryset)
示例#7
0
    def test_eda_relationship(self):
        emm = Factory.EmmFactory(pk=1)
        eqp = Factory.EqpFactory(emm=emm)
        dep_1 = Factory.DepFactory()
        dep_2 = Factory.DepFactory()

        eda = Factory.EdaFactory(eqp=eqp, dep=dep_1)

        self.assertEquals(1, dep_1.attachments.all().count())
        self.assertEquals(1, eqp.deployments.all().count())
        self.assertEquals(dep_1, eqp.deployments.all().last().dep)

        eda = Factory.EdaFactory(eqp=eqp, dep=dep_2)

        self.assertEquals(1, dep_2.attachments.all().count())
        self.assertEquals(2, eqp.deployments.all().count())
        self.assertEquals(dep_2, eqp.deployments.all().last().dep)
示例#8
0
    def setUp(self):
        super().setUp()

        self.data = Factory.EqpFactory.get_valid_data()

        emm = Factory.EmmFactory()
        obj = Factory.EqpFactory(emm=emm)

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

        # Since this is intended to be used as a pop-out form, use the no nav entry form
        self.test_expected_template = 'shared_models/shared_entry_form.html'

        self.expected_view = views.EqpUpdate

        self.expected_form = forms.EqpForm

        self.expected_success_url = reverse_lazy("whalesdb:list_eqp")
示例#9
0
    def setUp(self):
        super().setUp()
        eqt = models.EqtEquipmentTypeCode.objects.get(pk=4)
        emm = Factory.EmmFactory(eqt=eqt)
        eca_hydrophone = Factory.EqpFactory(emm=emm)

        self.eca = Factory.EcaFactory(eca_hydrophone=eca_hydrophone)

        self.data = Factory.EccFactory.get_valid_data()

        args = [self.eca.pk, 'pop']

        self.test_url = reverse_lazy('whalesdb:create_ecc', args=args)

        # Since this is intended to be used as a pop-out form, the html file should start with an underscore
        self.test_expected_template = 'shared_models/shared_entry_form.html'

        self.expected_success_url = reverse_lazy(
            'shared_models:close_me_no_refresh')

        self.expected_view = views.EcaCreate
        self.expected_form = forms.EcaForm
示例#10
0
    def setUp(self):
        super().setUp()

        self.data = Factory.EcaFactory.get_valid_data()

        eqt = models.EqtEquipmentTypeCode.objects.get(pk=4)
        emm = Factory.EmmFactory(eqt=eqt)
        eca_hydrophone = Factory.EqpFactory(emm=emm)

        obj = Factory.EcaFactory(eca_hydrophone=eca_hydrophone)

        self.test_url = reverse_lazy('whalesdb:update_eca', args=(obj.pk, ))

        # Since this is intended to be used as a pop-out form, the html file should start with an underscore
        self.test_expected_template = 'shared_models/shared_entry_form.html'

        self.expected_view = views.EmmUpdate

        self.expected_form = forms.EmmForm

        self.expected_success_url = reverse_lazy("whalesdb:details_eca",
                                                 args=(obj.pk, ))