summaryrefslogtreecommitdiff
path: root/tests/cyclic
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-16 17:29:59 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-08-16 22:38:42 +0200
commitc34d01278bd9cadff3f1ebea4579ef556cf75480 (patch)
tree730d40aed20ad27e665329cd34694a7cdc5861d2 /tests/cyclic
parentbab73174ff9c6c8ef4bfa24142d18f04411cb342 (diff)
downloadfactory-boy-c34d01278bd9cadff3f1ebea4579ef556cf75480.tar
factory-boy-c34d01278bd9cadff3f1ebea4579ef556cf75480.tar.gz
Add full tests for CircularSubFactory.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests/cyclic')
-rw-r--r--tests/cyclic/__init__.py0
-rw-r--r--tests/cyclic/bar.py37
-rw-r--r--tests/cyclic/foo.py38
3 files changed, 75 insertions, 0 deletions
diff --git a/tests/cyclic/__init__.py b/tests/cyclic/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/cyclic/__init__.py
diff --git a/tests/cyclic/bar.py b/tests/cyclic/bar.py
new file mode 100644
index 0000000..cc90930
--- /dev/null
+++ b/tests/cyclic/bar.py
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2011-2012 Raphaël Barrois
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+"""Helper to test circular factory dependencies."""
+
+import factory
+
+class Bar(object):
+ def __init__(self, foo, y):
+ self.foo = foo
+ self.y = y
+
+
+class BarFactory(factory.Factory):
+ FACTORY_FOR = Bar
+
+ y = 13
+ foo = factory.CircularSubFactory('cyclic.foo', 'FooFactory')
+
diff --git a/tests/cyclic/foo.py b/tests/cyclic/foo.py
new file mode 100644
index 0000000..e6f8896
--- /dev/null
+++ b/tests/cyclic/foo.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2011-2012 Raphaël Barrois
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+"""Helper to test circular factory dependencies."""
+
+import factory
+
+from cyclic import bar
+
+class Foo(object):
+ def __init__(self, bar, x):
+ self.bar = bar
+ self.x = x
+
+
+class FooFactory(factory.Factory):
+ FACTORY_FOR = Foo
+
+ x = 42
+ bar = factory.SubFactory(bar.BarFactory)