Commits

Jean-Tiare Le Bigot committed 4eb5ffd

add regression tests for issus #9

Comments (0)

Files changed (2)

tests/functional/boto/test_query.py

 TABLE_RK_TYPE = u'S'
 
 HK_VALUE = u'123'
+HK_VALUE_404 = u'404'
 RK_VALUE1 = u'Waldo-1'
 RK_VALUE2 = u'Waldo-2'
 RK_VALUE3 = u'Waldo-3'
         ret = db.layer1.query(TABLE_NAME, {TABLE_HK_TYPE: HK_VALUE})
         self.assertEqual(expected, ret)
 
+    # Regression test for #9
+    def test_query_all_404(self):
+        from ddbmock import connect_boto_patch
+        from ddbmock.database.db import dynamodb
+
+        expected = {
+            u"Count": 0,
+            u'Items': [],
+            u"ConsumedCapacityUnits": 0.5,
+        }
+
+        db = connect_boto_patch()
+
+        ret = db.layer1.query(TABLE_NAME, {TABLE_HK_TYPE: HK_VALUE_404})
+        self.assertEqual(expected, ret)
+
     def test_query_2_first(self):
         from ddbmock import connect_boto_patch
         from ddbmock.database.db import dynamodb

tests/functional/pyramid/test_query.py

 TABLE_RK_TYPE = u'S'
 
 HK_VALUE = u'123'
+HK_VALUE_404 = u'404'
 RK_VALUE1 = u'Waldo-1'
 RK_VALUE2 = u'Waldo-2'
 RK_VALUE3 = u'Waldo-3'
         self.assertEqual(expected, json.loads(res.body))
         self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
 
+    # Regression test for #9
+    def test_query_all_404(self):
+        from ddbmock import connect_boto_patch
+        from ddbmock.database.db import dynamodb
+
+        request = {
+            "TableName": TABLE_NAME,
+            "HashKeyValue": {TABLE_HK_TYPE: HK_VALUE_404},
+        }
+
+        expected = {
+            u"Count": 0,
+            u'Items': [],
+            u"ConsumedCapacityUnits": 0.5,
+        }
+
+        # Protocol check
+        res = self.app.post_json('/', request, HEADERS, status=400)
+        self.assertEqual(expected, json.loads(res.body))
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+