You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ro...@apache.org on 2016/07/22 00:44:39 UTC

[1/2] incubator-beam git commit: Closes #702

Repository: incubator-beam
Updated Branches:
  refs/heads/python-sdk e5006991d -> 09b4daf23


Closes #702


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

Branch: refs/heads/python-sdk
Commit: 09b4daf23fc80ad565dbdcd8704c1b4c01d879fc
Parents: e500699 441fad3
Author: Robert Bradshaw <ro...@google.com>
Authored: Thu Jul 21 17:44:02 2016 -0700
Committer: Robert Bradshaw <ro...@google.com>
Committed: Thu Jul 21 17:44:02 2016 -0700

----------------------------------------------------------------------
 .../apache_beam/utils/windowed_value_test.py    | 71 ++++++++++++++++++++
 1 file changed, 71 insertions(+)
----------------------------------------------------------------------



[2/2] incubator-beam git commit: Add tests for WindowedValue.

Posted by ro...@apache.org.
Add tests for WindowedValue.


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

Branch: refs/heads/python-sdk
Commit: 441fad31ba42e14cd305277060b7e26a97f68166
Parents: e500699
Author: Robert Bradshaw <ro...@google.com>
Authored: Wed Jul 20 14:10:11 2016 -0700
Committer: Robert Bradshaw <ro...@google.com>
Committed: Thu Jul 21 17:44:02 2016 -0700

----------------------------------------------------------------------
 .../apache_beam/utils/windowed_value_test.py    | 71 ++++++++++++++++++++
 1 file changed, 71 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-beam/blob/441fad31/sdks/python/apache_beam/utils/windowed_value_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/utils/windowed_value_test.py b/sdks/python/apache_beam/utils/windowed_value_test.py
new file mode 100644
index 0000000..f257410
--- /dev/null
+++ b/sdks/python/apache_beam/utils/windowed_value_test.py
@@ -0,0 +1,71 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""Unit tests for the windowed_value."""
+
+import copy
+import pickle
+import unittest
+
+from apache_beam.utils import windowed_value
+from apache_beam.transforms.timeutil import Timestamp
+
+
+class WindowedValueTest(unittest.TestCase):
+
+  def test_timestamps(self):
+    wv = windowed_value.WindowedValue(None, 3, ())
+    self.assertEqual(wv.timestamp, Timestamp.of(3))
+    self.assertTrue(wv.timestamp is wv.timestamp)
+    self.assertEqual(windowed_value.WindowedValue(None, -2.5, ()).timestamp,
+                     Timestamp.of(-2.5))
+
+  def test_with_value(self):
+    wv = windowed_value.WindowedValue(1, 3, ())
+    self.assertEqual(wv.with_value(10), windowed_value.WindowedValue(10, 3, ()))
+
+  def test_equality(self):
+    self.assertEqual(
+        windowed_value.WindowedValue(1, 3, ()),
+        windowed_value.WindowedValue(1, 3, ()))
+    self.assertNotEqual(
+        windowed_value.WindowedValue(1, 3, ()),
+        windowed_value.WindowedValue(100, 3, ()))
+    self.assertNotEqual(
+        windowed_value.WindowedValue(1, 3, ()),
+        windowed_value.WindowedValue(1, 300, ()))
+    self.assertNotEqual(
+        windowed_value.WindowedValue(1, 3, ()),
+        windowed_value.WindowedValue(1, 300, ((),)))
+
+    self.assertNotEqual(
+        windowed_value.WindowedValue(1, 3, ()),
+        object())
+
+  def test_hash(self):
+    wv = windowed_value.WindowedValue(1, 3, ())
+    wv_copy = copy.copy(wv)
+    self.assertFalse(wv is wv_copy)
+    self.assertEqual({wv: 100}.get(wv_copy), 100)
+
+  def test_pickle(self):
+    wv = windowed_value.WindowedValue(1, 3, ())
+    self.assertTrue(pickle.loads(pickle.dumps(wv)) == wv)
+
+
+if __name__ == '__main__':
+  unittest.main()