示例#1
0
 def test_form_validation(self):
     drug = Mock(spec=Prescription)
     form = TxItemForm(data={
         'med': drug,
         'dose': '',
         'freq': '',
         'unit': ''
     })
     self.assertFalse(form.is_valid())
示例#2
0
    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)