Repository: incubator-slider
Updated Branches:
  refs/heads/feature/python_unittests 8bc4ea989 -> f6f639df5


Test Commit 6


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/f6f639df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/f6f639df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/f6f639df

Branch: refs/heads/feature/python_unittests
Commit: f6f639df59a3c51da8f04f6a9fbf8432e0a02762
Parents: 8bc4ea9
Author: Sumit Mohanty <[email protected]>
Authored: Sun Nov 9 08:46:19 2014 -0800
Committer: Sumit Mohanty <[email protected]>
Committed: Sun Nov 9 08:46:19 2014 -0800

----------------------------------------------------------------------
 .../test/python/agent/TestCustomServiceOrchestrator.py  | 12 ++++++++++--
 slider-agent/src/test/python/agent/TestGrep.py          |  3 +++
 .../python/resource_management/TestContentSources.py    | 10 ++++++++--
 .../python/resource_management/TestExecuteResource.py   |  6 +++++-
 4 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/f6f639df/slider-agent/src/test/python/agent/TestCustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git 
a/slider-agent/src/test/python/agent/TestCustomServiceOrchestrator.py 
b/slider-agent/src/test/python/agent/TestCustomServiceOrchestrator.py
index 4f81ea9..30c8d7a 100644
--- a/slider-agent/src/test/python/agent/TestCustomServiceOrchestrator.py
+++ b/slider-agent/src/test/python/agent/TestCustomServiceOrchestrator.py
@@ -36,6 +36,8 @@ import StringIO
 import sys
 from socket import socket
 from AgentToggleLogger import AgentToggleLogger
+import platform
+IS_WINDOWS = platform.system() == "Windows"
 
 class TestCustomServiceOrchestrator(TestCase):
 
@@ -86,7 +88,10 @@ class TestCustomServiceOrchestrator(TestCase):
     json_file = orchestrator.dump_command_to_json(command, {})
     self.assertTrue(os.path.exists(json_file))
     self.assertTrue(os.path.getsize(json_file) > 0)
-    self.assertEqual(oct(os.stat(json_file).st_mode & 0777), '0644')
+    if IS_WINDOWS:
+      self.assertEqual(oct(os.stat(json_file).st_mode & 0777), '0666')
+    else:
+      self.assertEqual(oct(os.stat(json_file).st_mode & 0777), '0644')
     self.assertTrue(json_file.endswith("command-3.json"))
     os.unlink(json_file)
 
@@ -100,7 +105,10 @@ class TestCustomServiceOrchestrator(TestCase):
     json_file = orchestrator.dump_command_to_json(command, {})
     self.assertTrue(os.path.exists(json_file))
     self.assertTrue(os.path.getsize(json_file) > 0)
-    self.assertEqual(oct(os.stat(json_file).st_mode & 0777), '0644')
+    if IS_WINDOWS:
+      self.assertEqual(oct(os.stat(json_file).st_mode & 0777), '0666')
+    else:
+      self.assertEqual(oct(os.stat(json_file).st_mode & 0777), '0644')
     self.assertTrue(json_file.endswith("status_command.json"))
     os.unlink(json_file)
     # Testing side effect of dump_command_to_json

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/f6f639df/slider-agent/src/test/python/agent/TestGrep.py
----------------------------------------------------------------------
diff --git a/slider-agent/src/test/python/agent/TestGrep.py 
b/slider-agent/src/test/python/agent/TestGrep.py
index 351befb..bd9e437 100644
--- a/slider-agent/src/test/python/agent/TestGrep.py
+++ b/slider-agent/src/test/python/agent/TestGrep.py
@@ -43,6 +43,7 @@ class TestGrep(TestCase):
 
 
   def test_grep_few_lines(self):
+    self.assertEqual.__self__.maxDiff = None
     fragment = self.grep.grep(self.string_bad, "Err", 3, 3)
     desired = """
 debug: /Schedule[never]: Skipping device resources because running on a host
@@ -77,6 +78,7 @@ debug: Finishing transaction 70171639726240
     self.assertEquals(fragment, desired, "Grep tail function should return all 
lines if there are less lines than n")
 
   def test_tail_few_lines(self):
+    self.assertEqual.__self__.maxDiff = None
     fragment = self.grep.tail(self.string_good, 3)
     desired = """
 debug: Finishing transaction 70060456663980
@@ -106,6 +108,7 @@ debug: Processing report from ambari-dmi with processor 
Puppet::Reports::Store
     pass
 
   def test_cleanByTemplate(self):
+    self.assertEqual.__self__.maxDiff = None
     fragment = self.grep.cleanByTemplate(self.string_bad, "debug")
     desired = """
 info: Applying configuration version '1352127563'

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/f6f639df/slider-agent/src/test/python/resource_management/TestContentSources.py
----------------------------------------------------------------------
diff --git 
a/slider-agent/src/test/python/resource_management/TestContentSources.py 
b/slider-agent/src/test/python/resource_management/TestContentSources.py
index 7015c47..841b72a 100644
--- a/slider-agent/src/test/python/resource_management/TestContentSources.py
+++ b/slider-agent/src/test/python/resource_management/TestContentSources.py
@@ -133,9 +133,15 @@ class TestContentSources(TestCase):
       template = Template("test.j2")
 
     self.assertEqual(open_mock.call_count, 1)
-    open_mock.assert_called_with('/base/templates/test.j2', 'rb')
+    if IS_WINDOWS:
+      open_mock.assert_called_with('/base/templates\\test.j2', 'rb')
+    else:
+      open_mock.assert_called_with('/base/templates/test.j2', 'rb')
     self.assertEqual(getmtime_mock.call_count, 1)
-    getmtime_mock.assert_called_with('/base/templates/test.j2')
+    if IS_WINDOWS:
+      getmtime_mock.assert_called_with('/base/templates\\test.j2')
+    else:
+      getmtime_mock.assert_called_with('/base/templates/test.j2')
 
   @patch.object(os.path, "exists")
   def test_template_loader_fail(self, exists_mock):

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/f6f639df/slider-agent/src/test/python/resource_management/TestExecuteResource.py
----------------------------------------------------------------------
diff --git 
a/slider-agent/src/test/python/resource_management/TestExecuteResource.py 
b/slider-agent/src/test/python/resource_management/TestExecuteResource.py
index b7af465..f7f6371 100644
--- a/slider-agent/src/test/python/resource_management/TestExecuteResource.py
+++ b/slider-agent/src/test/python/resource_management/TestExecuteResource.py
@@ -121,7 +121,11 @@ class TestExecuteResource(TestCase):
       execute_resource = Execute('echo "1"',
                                  path=["/test/one", "test/two"]
       )
-    self.assertEqual(execute_resource.environment["PATH"], 
'/test/one:test/two')
+
+    if IS_WINDOWS:
+      self.assertEqual(execute_resource.environment["PATH"], 
'/test/one;test/two')
+    else:
+      self.assertEqual(execute_resource.environment["PATH"], 
'/test/one:test/two')
 
   @patch('time.sleep')
   @patch.object(subprocess, "Popen")

Reply via email to