Beispiel #1
0
    def test_copy_dictionaries(self):
        """Testcase for LP: #497664"""
        dicts = [{
            "key1_1": "val1_1",
            "key1_2": "val1_2",
            "key1_3": "val1_3"
        }, {
            "key1_1": "val2_1",
            "key1_2": "val2_2",
            "key1_3": "val2_3"
        }]

        #build the CouchGrid
        grid1 = DictionaryGrid(dicts)
        # added two dicts, so length should be 2
        self.assertEqual(len(grid1.get_dictionaries_copy()), 2)

        #no dicts, so it should be 0
        grid2 = DictionaryGrid()
        self.assertEqual(len(grid2.get_dictionaries_copy()), 0)
Beispiel #2
0
    def test_mismatched_col_and_val_types(self):
        """Ensure robustness for strings passed in for non-str
        column types

        """

        keys = ["id", "price", "bool?"]
        dicts = [{"price": "100.00", "id": "50", "bool?": "Yes"}]
        grid = DictionaryGrid(dicts, keys)
        test_dict = grid.get_dictionaries_copy()[0]
        self.assertEqual(test_dict["id"], 50)
        self.assertEqual(test_dict["price"], 100.00)
        self.assertEqual(test_dict["bool?"], True)
Beispiel #3
0
 def test_infer_boolean_values(self):
     """Ensure that inferring boolean values from strings works"""
     keys = ["a?", "b?", "c?", "d?", "e?", "f?"]
     dicts = [{
         "a?": True,
         "b?": False,
         "c?": "Yes",
         "d?": "No",
         "e?": 1.5,
         "f?": 0
     }]
     grid = DictionaryGrid(dicts, keys)
     test_dict = grid.get_dictionaries_copy()[0]
     self.assertEqual(test_dict["a?"], True)
     self.assertEqual(test_dict["b?"], False)
     self.assertEqual(test_dict["c?"], True)
     self.assertEqual(test_dict["d?"], False)
     self.assertEqual(test_dict["e?"], True)
     self.assertEqual(test_dict["f?"], False)