Пример #1
0
    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
Пример #2
0
    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
Пример #3
0
    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."
Пример #4
0
    def test_minimal_valid_form(self):
        form = forms.GeneratorForm(data=self.form_data, files=self.multipart)

        assert form.is_valid(), form.errors
Пример #5
0
    def test_form_is_a_model_form(self):
        form = forms.GeneratorForm()

        for field in self.form_data.keys():
            assert field in form.fields.keys()