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)
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())
def test_delete_eqh(self): emm = factory.EmmFactory(eqt=models.EqtEquipmentTypeCode.objects.get(pk=4)) eqh = factory.EqhFactory(emm=emm) test_url = reverse_lazy(self.signature, args=[eqh.emm.pk, ]) self.assert_success_url(test_url, user=self.user) # for delete views... self.assertEqual(models.EmmMakeModel.objects.filter(pk=eqh.emm.pk).count(), 0)
def test_emm_eqh_hydrophones(self): eqt = models.EqtEquipmentTypeCode.objects.get(pk=4) emm = Factory.EmmFactory(eqt=eqt) # create an Eqh object from the factory, in theory it should share the emm object # when emm.hydrophone is called there should be a single matching entry eqh = Factory.EqhFactory(emm=emm) hydrophone = emm.hydrophone self.assertEquals(eqh, hydrophone)
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 = []
def createDict(self): if self._details_dict: return self._details_dict self._details_dict = {} obj = Factory.EmmFactory() self._details_dict['emm_1'] = obj return self._details_dict
def test_eda_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.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)
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']
def setUp(self): super().setUp() self.data = Factory.EqhFactory.get_valid_data() emm = Factory.EmmFactory(pk=4) obj = Factory.EqhFactory(emm=emm) self.test_url = reverse_lazy('whalesdb:update_eqh', args=(obj.pk, 'pop',)) # 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.EqhUpdate self.expected_form = forms.EqhForm
def test_emm_ecp_channels(self): eqt = models.EqtEquipmentTypeCode.objects.get(pk=1) emm = Factory.EmmFactory(eqt=eqt) eqr = Factory.EqrFactory(emm=emm) ecp1 = Factory.EcpFactory(eqr=eqr, ecp_channel_no=1) ecp2 = Factory.EcpFactory(eqr=eqr, ecp_channel_no=2) recorder = emm.recorder self.assertEquals(eqr, recorder) channels = recorder.channels.all() self.assertEquals(2, channels.count()) self.assertIn(ecp1, channels) self.assertIn(ecp2, channels)
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)
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")
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
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, ))