def test_form_help_texts(self): form = forms.GeneratorForm() renderedForm = form.as_p() assert "Distance metric to compare chemical similarity between " +\ "ligand pairs." in renderedForm assert "Input .sdf file containing ligands." in renderedForm
def test_form_rendering(self): form = forms.GeneratorForm() renderedForm = form.as_p() assert '<label for="id_in_sdf">In sdf:</label>' in renderedForm assert '<input type="file" name="in_sdf" required id="id_in_sdf">' in \ renderedForm
def test_some_invalid_sdfs(self): in_sdf = Path(__file__).parent / "test_files" / "One_ligand.sdf" with open(in_sdf, "rb") as inFile: content = inFile.read() self.multipart = {"in_sdf": SimpleUploadedFile(in_sdf, content)} self.form_data = {"metric": g.SMILES} form = forms.GeneratorForm(data=self.form_data, files=self.multipart) assert not form.is_valid() assert form.errors.as_data()["in_sdf"][0].message == \ "SDF file contains a single ligand. Needs two at least."
def test_minimal_valid_form(self): form = forms.GeneratorForm(data=self.form_data, files=self.multipart) assert form.is_valid(), form.errors
def test_form_is_a_model_form(self): form = forms.GeneratorForm() for field in self.form_data.keys(): assert field in form.fields.keys()