forked from enviPath/enviPy
[Feature] Alias Support (#151)
Fixes #149 Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#151
This commit is contained in:
@ -112,3 +112,57 @@ class PathwayViewTest(TestCase):
|
||||
predicted_nodes.add(n.default_node_label.smiles)
|
||||
|
||||
self.assertEqual(first_level_nodes, predicted_nodes)
|
||||
|
||||
def test_set_aliases(self):
|
||||
alias_1 = "Alias 1"
|
||||
alias_2 = "Alias 2"
|
||||
|
||||
response = self.client.post(
|
||||
reverse("package pathway list", kwargs={"package_uuid": str(self.package.uuid)}),
|
||||
{
|
||||
"name": "Test Pathway",
|
||||
"description": "Just a Description",
|
||||
"predict": "predict",
|
||||
"smiles": "CCN(CC)C(=O)C1=CC(=CC=C1)CO",
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, 302)
|
||||
pathway_url = response.url
|
||||
pw = Pathway.objects.get(url=pathway_url)
|
||||
|
||||
response = self.client.post(
|
||||
reverse(
|
||||
"package pathway detail",
|
||||
kwargs={"package_uuid": str(pw.package.uuid), "pathway_uuid": str(pw.uuid)},
|
||||
),
|
||||
{"aliases": [alias_1, alias_2]},
|
||||
)
|
||||
|
||||
pw = Pathway.objects.get(url=pathway_url)
|
||||
self.assertEqual(len(pw.aliases), 2)
|
||||
|
||||
response = self.client.post(
|
||||
reverse(
|
||||
"package pathway detail",
|
||||
kwargs={"package_uuid": str(pw.package.uuid), "pathway_uuid": str(pw.uuid)},
|
||||
),
|
||||
{"aliases": [alias_1]},
|
||||
)
|
||||
|
||||
pw = Pathway.objects.get(url=pathway_url)
|
||||
self.assertEqual(len(pw.aliases), 1)
|
||||
|
||||
response = self.client.post(
|
||||
reverse(
|
||||
"package pathway detail",
|
||||
kwargs={"package_uuid": str(pw.package.uuid), "pathway_uuid": str(pw.uuid)},
|
||||
),
|
||||
{
|
||||
# We have to set an empty string to avoid that the parameter is removed
|
||||
"aliases": ""
|
||||
},
|
||||
)
|
||||
|
||||
pw = Pathway.objects.get(url=pathway_url)
|
||||
self.assertEqual(len(pw.aliases), 0)
|
||||
|
||||
Reference in New Issue
Block a user