Exemple #1
0
    def __init__(self, app, data, storage, payload, instclass, selection, error):
        EditTUISpoke.__init__(self, app, data, storage, payload, instclass)
        SourceSwitchHandler.__init__(self)
        self.selection = selection
        self._error = error

        nfs = self.data.method
        self.args = DataHolder(server="", opts=nfs.opts or "")
        if nfs.method == "nfs" and nfs.server and nfs.dir:
            self.args.server = "%s:%s" % (nfs.server, nfs.dir)
    def dataholder_test(self):
        """Test the DataHolder class"""

        source = {"name": "Minion", "color": "Yellow", "size": 3}
        data = DataHolder(**source)

        # test that init keywords show up as attrs
        self.assertTrue(all([getattr(data, s) == source[s] for s in source]))

        # test that init keywords show as keys
        self.assertTrue(all([data[s] == source[s] for s in source]))

        # test that adding an attr shows as a key
        data.master = "Gru"
        self.assertEquals(data["master"], "Gru")

        # test that adding a key shows as an attr
        data["sibling"] = "More Minions"
        self.assertEquals(data.sibling, "More Minions")

        # test that a copy results in the same key/values
        data_copy = data.copy()
        self.assertEquals(data, data_copy)
Exemple #3
0
    def dataholder_test(self):
        """Test the DataHolder class"""

        source = {"name": "Minion", "color": "Yellow", "size": 3}
        data = DataHolder(**source)

        # test that init keywords show up as attrs
        self.assertTrue(all([getattr(data, s) == source[s] for s in source]))

        # test that init keywords show as keys
        self.assertTrue(all([data[s] == source[s] for s in source]))

        # test that adding an attr shows as a key
        data.master = "Gru"
        self.assertEqual(data["master"], "Gru")

        # test that adding a key shows as an attr
        data["sibling"] = "More Minions"
        self.assertEqual(data.sibling, "More Minions")

        # test that a copy results in the same key/values
        data_copy = data.copy()
        self.assertEqual(data, data_copy)