def test_form_validation(self): drug = Mock(spec=Prescription) form = TxItemForm(data={ 'med': drug, 'dose': '', 'freq': '', 'unit': '' }) self.assertFalse(form.is_valid())
def test_form_save_item(self): sheet = Mock(spec=TxSheet) sheet._state = Mock() sheet._state.db = None sheet.id = 1 Prescription.objects.create(name='Drugahol') form = TxItemForm(data={ 'med': 1, 'dose': 5, 'freq': 'BID', 'unit': 'T' }) form.is_valid() sheet = form.save(sheet=sheet) self.assertIsInstance(sheet, TxItem)