def test_dispense(self): drug = factories.DrugFactory() num = drug.stock dispense = 5 remain = num - dispense drug.dispense(dispense) self.assertEqual(drug.stock, remain)
def setUp(self): self.user = build_user() log_in_user(self.client, self.user) self.unit = factories.MeasuringUnitFactory(name='different_unit') self.category = factories.DrugCategoryFactory(name='different_category') self.manufacturer = factories.ManufacturerFactory(name='different_manufacturer') self.diff_drug = { 'name': 'Differentdrug', 'unit': self.unit.pk, 'dose': 500.0, 'stock': 5, 'expiration_date': '2100-01-01', 'lot_number': 'HGFEDCBA', 'category': self.category.pk, 'manufacturer': self.manufacturer.pk } self.drug = factories.DrugFactory() self.pt = core_factories.PatientFactory() self.encounter = core_factories.EncounterFactory(patient=self.pt)
def test_duplicate_drug_form_valid(self): drug = factories.DrugFactory() data = { 'name': drug.name, 'lot_number': drug.lot_number, 'manufacturer': drug.manufacturer.pk } form = forms.DuplicateDrugForm(data=data) self.assertTrue(form.is_valid())
def test_drug_form_valid(self): drug = factories.DrugFactory() data = { 'name': drug.name, 'unit': drug.unit.pk, 'dose': drug.dose, 'stock': drug.stock, 'expiration_date': drug.expiration_date, 'lot_number': drug.lot_number, 'category': drug.category.pk, 'manufacturer': drug.manufacturer.pk } form = forms.DrugForm(data=data) self.assertTrue(form.is_valid())
def setUp(self): log_in_user(self.client, build_user()) self.drug = factories.DrugFactory() self.drug_field = { 'name': self.drug.name, 'unit': self.drug.unit.pk, 'dose': self.drug.dose, 'stock': self.drug.stock, 'expiration_date': self.drug.expiration_date, 'lot_number': self.drug.lot_number, 'category': self.drug.category.pk, 'manufacturer': self.drug.manufacturer.pk }
def test_cannot_dispense(self): drug = factories.DrugFactory() num = drug.stock + 1 self.assertEqual(drug.can_dispense(num), False)
def test_can_dispense(self): drug = factories.DrugFactory() num = drug.stock self.assertEqual(drug.can_dispense(num), True)
def test_drug_creation(self): assert Drug.objects.count() == 0 drug = factories.DrugFactory() assert isinstance(drug, Drug) assert Drug.objects.count() == 1