From 02de3969059430fe4520957f318cb3bf72fc6666 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 19 Oct 2011 14:50:16 +0200 Subject: [PATCH 1/5] tests for Object state Signed-off-by: Steven Armstrong --- lib/cdist/test/object/__init__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/cdist/test/object/__init__.py b/lib/cdist/test/object/__init__.py index 84d2cf8f..7064b34d 100644 --- a/lib/cdist/test/object/__init__.py +++ b/lib/cdist/test/object/__init__.py @@ -79,6 +79,7 @@ class ObjectTestCase(unittest.TestCase): self.cdist_object.source = [] self.cdist_object.code_local = '' self.cdist_object.code_remote = '' + self.cdist_object.state = '' def test_name(self): self.assertEqual(self.cdist_object.name, '__third/moon') @@ -163,6 +164,21 @@ class ObjectTestCase(unittest.TestCase): self.cdist_object.ran = True self.assertTrue(self.cdist_object.ran) + def test_state(self): + self.assertEqual(self.cdist_object.state, '') + + def test_state_ran(self): + self.cdist_object.state = core.Object.STATE_RAN + self.assertEqual(self.cdist_object.state, core.Object.STATE_RAN) + + def test_state_running(self): + self.cdist_object.state = core.Object.STATE_RUNNING + self.assertEqual(self.cdist_object.state, core.Object.STATE_RUNNING) + + def test_state_prepared(self): + self.cdist_object.state = core.Object.STATE_PREPARED + self.assertEqual(self.cdist_object.state, core.Object.STATE_PREPARED) + def test_source(self): self.assertEqual(list(self.cdist_object.source), []) From 4f398a834fbd0095bad54bda0f14c43416951c52 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 19 Oct 2011 14:53:06 +0200 Subject: [PATCH 2/5] /ran/done/ Signed-off-by: Steven Armstrong --- lib/cdist/test/object/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/cdist/test/object/__init__.py b/lib/cdist/test/object/__init__.py index 7064b34d..c5e9e2dd 100644 --- a/lib/cdist/test/object/__init__.py +++ b/lib/cdist/test/object/__init__.py @@ -167,17 +167,17 @@ class ObjectTestCase(unittest.TestCase): def test_state(self): self.assertEqual(self.cdist_object.state, '') - def test_state_ran(self): - self.cdist_object.state = core.Object.STATE_RAN - self.assertEqual(self.cdist_object.state, core.Object.STATE_RAN) + def test_state_prepared(self): + self.cdist_object.state = core.Object.STATE_PREPARED + self.assertEqual(self.cdist_object.state, core.Object.STATE_PREPARED) def test_state_running(self): self.cdist_object.state = core.Object.STATE_RUNNING self.assertEqual(self.cdist_object.state, core.Object.STATE_RUNNING) - def test_state_prepared(self): - self.cdist_object.state = core.Object.STATE_PREPARED - self.assertEqual(self.cdist_object.state, core.Object.STATE_PREPARED) + def test_state_done(self): + self.cdist_object.state = core.Object.STATE_DONE + self.assertEqual(self.cdist_object.state, core.Object.STATE_DONE) def test_source(self): self.assertEqual(list(self.cdist_object.source), []) From 022b17d70067c933505925c3c5b5920ed664be6f Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 19 Oct 2011 14:53:31 +0200 Subject: [PATCH 3/5] implement Object state Signed-off-by: Steven Armstrong --- lib/cdist/core/object.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/cdist/core/object.py b/lib/cdist/core/object.py index 8cecfe6d..a35182d2 100644 --- a/lib/cdist/core/object.py +++ b/lib/cdist/core/object.py @@ -51,6 +51,11 @@ class Object(object): """ + # Constants for use with Object.state + STATE_PREPARED = "prepared" + STATE_RUNNING = "running" + STATE_DONE = "done" + @classmethod def list_objects(cls, object_base_path, type_base_path): """Return a list of object instances""" @@ -127,6 +132,7 @@ class Object(object): changed = fsproperty.FileBooleanProperty(lambda obj: os.path.join(obj.absolute_path, "changed")) prepared = fsproperty.FileBooleanProperty(lambda obj: os.path.join(obj.absolute_path, "prepared")) ran = fsproperty.FileBooleanProperty(lambda obj: os.path.join(obj.absolute_path, "ran")) + state = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.absolute_path, "state")) source = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, "source")) code_local = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.base_path, obj.code_local_path)) code_remote = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.base_path, obj.code_remote_path)) From ff2192f6dea1a6899fb662e8e355ae0b92bfc689 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 19 Oct 2011 14:54:15 +0200 Subject: [PATCH 4/5] remove legacy attributes: ran, prepared Signed-off-by: Steven Armstrong --- lib/cdist/core/object.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/cdist/core/object.py b/lib/cdist/core/object.py index a35182d2..5157d86a 100644 --- a/lib/cdist/core/object.py +++ b/lib/cdist/core/object.py @@ -130,8 +130,6 @@ class Object(object): parameters = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.parameter_path)) explorers = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.explorer_path)) changed = fsproperty.FileBooleanProperty(lambda obj: os.path.join(obj.absolute_path, "changed")) - prepared = fsproperty.FileBooleanProperty(lambda obj: os.path.join(obj.absolute_path, "prepared")) - ran = fsproperty.FileBooleanProperty(lambda obj: os.path.join(obj.absolute_path, "ran")) state = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.absolute_path, "state")) source = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, "source")) code_local = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.base_path, obj.code_local_path)) From f732220e7794cd4bbf568d58816c2aba940db7b7 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 19 Oct 2011 14:54:38 +0200 Subject: [PATCH 5/5] remove legacy tests Signed-off-by: Steven Armstrong --- lib/cdist/test/object/__init__.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lib/cdist/test/object/__init__.py b/lib/cdist/test/object/__init__.py index c5e9e2dd..ab05c7af 100644 --- a/lib/cdist/test/object/__init__.py +++ b/lib/cdist/test/object/__init__.py @@ -150,20 +150,6 @@ class ObjectTestCase(unittest.TestCase): self.cdist_object.changed = True self.assertTrue(self.cdist_object.changed) - def test_prepared(self): - self.assertFalse(self.cdist_object.prepared) - - def test_prepared_after_changing(self): - self.cdist_object.prepared = True - self.assertTrue(self.cdist_object.prepared) - - def test_ran(self): - self.assertFalse(self.cdist_object.ran) - - def test_ran_after_changing(self): - self.cdist_object.ran = True - self.assertTrue(self.cdist_object.ran) - def test_state(self): self.assertEqual(self.cdist_object.state, '')