Commit e31ae185 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[algorithms][tests] Add default integer type creation

This type is need to load the algorithm prototype.

This commit also cleans up the code.
parent 15abee4a
This diff is collapsed.
......@@ -28,7 +28,7 @@
from django.contrib.auth.models import User
from ...libraries.models import Library
from ...common.testutils import tearDownModule
from ...common.testutils import tearDownModule # noqa test runner will call it
from ..models import Algorithm
......@@ -38,18 +38,25 @@ from .core import AlgorithmsBaseTestCase
class DependencyTests(AlgorithmsBaseTestCase):
def setUp(self):
super(DependencyTests, self).setUp()
user = User.objects.create_user('johndoe', 'johndoe@test.org', '1234')
user = User.objects.get(username="johndoe")
algorithm_declaration = """{
"description": "some description",
"schema_version": 1,
"language": "python",
"splittable": false,
"groups": [
{
"name": "channel1",
"inputs": {
"in_data": {
"type": "johndoe/integer/1"
}
},
"outputs": {
"out_data": {
"type": "johndoe/integer/1"
}
}
}
],
......@@ -81,44 +88,42 @@ class DependencyTests(AlgorithmsBaseTestCase):
"""
(algorithm, errors) = Algorithm.objects.create_algorithm(
author=user,
name='algorithm1',
name="algorithm1",
declaration=algorithm_declaration,
code=algorithm_code,
)
assert algorithm, errors
self.assertIsNotNone(algorithm, errors)
(library, errors) = Library.objects.create_library(
author=user,
name='library1',
name="library1",
declaration=library_declaration,
code=library_code,
)
assert library, errors
self.assertIsNotNone(library, errors)
def test_add_dependency(self):
algorithm1 = Algorithm.objects.get(name="algorithm1")
library1 = Library.objects.get(name='library1')
library1 = Library.objects.get(name="library1")
decl = algorithm1.declaration
decl.setdefault('uses', {})
decl['uses']['dep1'] = library1.fullname()
decl.setdefault("uses", {})
decl["uses"]["dep1"] = library1.fullname()
algorithm1.declaration = decl
algorithm1.save()
self.assertEqual(algorithm1.referenced_libraries.count(), 1)
def test_update_dependency(self):
algorithm1 = Algorithm.objects.get(name="algorithm1")
library1 = Library.objects.get(name='library1')
library1 = Library.objects.get(name="library1")
decl = algorithm1.declaration
decl.setdefault('uses', {})
decl['uses']['dep1'] = library1.fullname()
decl['uses']['dep2'] = library1.fullname()
decl.setdefault("uses", {})
decl["uses"]["dep1"] = library1.fullname()
decl["uses"]["dep2"] = library1.fullname()
algorithm1.declaration = decl
algorithm1.save()
......@@ -130,7 +135,7 @@ class DependencyTests(AlgorithmsBaseTestCase):
self.assertEqual(algorithm1.referenced_libraries.count(), 1)
decl = algorithm1.declaration
decl['uses'] = {}
decl["uses"] = {}
algorithm1.declaration = decl
algorithm1.save()
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment