Beispiel #1
0
 def run(self, params={}):
     var_to_look_for = params.get(Input.VARIABLE_NAME)
     cache_help = CacheHelp()
     return {
         Output.VARIABLE_FOUND:
         cache_help.check_for_variable(var_to_look_for)
     }
    def run(self, params={}):
        variable_to_store = params.get(Input.VARIABLE_NAME)
        value_to_store = params.get(Input.VARIABLE_VALUE)

        cache_help = CacheHelp()
        cache_help.store_variable(variable_to_store, value_to_store)

        return {Output.SUCCESS: True}
    def test_store(self):
        store = Store()
        params = {"variable_name": "foobar", "variable_value": "barfoo"}
        store.run(params)
        cache_help = CacheHelp()

        # This is cheaty, but it's a test
        actual = cache_help._get_dict_from_store()
        expected = {'foobar': 'barfoo'}

        self.assertEqual(expected, actual)
        cache_help._delete_dict_file()
    def test_store(self):
        store = Store()
        retrieve = Retrieve()
        params = {"variable_name": "foobar", "variable_value": "barfoo"}
        store.run(params)
        actual = retrieve.run(params)

        expected = {'value': 'barfoo'}
        self.assertEqual(expected, actual)

        cache_help = CacheHelp()
        cache_help._delete_dict_file()
    def test_store(self):
        store = Store()
        delete_ = DeleteVariable()
        params = {"variable_name": "foobar", "variable_value": "barfoo"}
        store.run(params)
        actual = delete_.run(params)

        expected = {'success': True}
        self.assertEqual(expected, actual)

        cache_help = CacheHelp()
        actual_dict = cache_help._get_dict_from_store()
        self.assertEqual({}, actual_dict)

        cache_help._delete_dict_file()
    def test_store(self):
        store = Store()
        var_check = CheckForVariable()
        params = {"variable_name": "foobar", "variable_value": "barfoo"}
        store.run(params)
        actual = var_check.run(params)

        expected = {'variable_found': True}
        self.assertEqual(expected, actual)

        cache_help = CacheHelp()
        cache_help.delete_variable("foobar")

        expected = {'variable_found': False}
        actual = var_check.run(params)
        self.assertEqual(expected, actual)
 def run(self, params={}):
     var_to_delete = params.get(Input.VARIABLE_NAME)
     cache_helper = CacheHelp()
     cache_helper.delete_variable(var_to_delete)
     return {Output.SUCCESS: True}
Beispiel #8
0
 def setUp(self) -> None:
     self.cache_help = CacheHelp()
     self.cache_help._delete_dict_file()
Beispiel #9
0
class TestCacheHelp(TestCase):
    def setUp(self) -> None:
        self.cache_help = CacheHelp()
        self.cache_help._delete_dict_file()

    def tearDown(self) -> None:
        self.cache_help._delete_dict_file()

    def test_get_dict_from_store(self):
        actual = self.cache_help._get_dict_from_store()
        self.assertEqual(actual, {})

    def test_save_dict_to_store(self):
        test_dict = {"foo": "bar"}
        self.cache_help._save_dict_to_store(test_dict)
        acutal_dict = self.cache_help._get_dict_from_store()

        self.assertEqual(acutal_dict, test_dict)

    def test_store_variable(self):
        self.cache_help.store_variable("test_dict", {"foo": "bar"})
        actual = self.cache_help.retrieve_variable("test_dict")
        self.assertEqual(actual, {"foo": "bar"})

    def test_delete_variable(self):
        self.cache_help.store_variable("key1", "value1")
        self.cache_help.store_variable("key2", "value2")
        self.cache_help.store_variable("key3", "value3")

        self.cache_help.delete_variable("key2")

        actual = self.cache_help._get_dict_from_store()
        expected = {'key1': 'value1', 'key3': 'value3'}

        self.assertEqual(expected, actual)

    def test_check_for_variable(self):
        self.cache_help.store_variable("key1", "value1")
        self.cache_help.store_variable("key2", "value2")

        self.assertTrue(
            not self.cache_help.check_for_variable("don't find me"))
        self.assertTrue(self.cache_help.check_for_variable("key2"))
 def run(self, params={}):
     var_to_get = params.get(Input.VARIABLE_NAME)
     cache_help = CacheHelp()
     ret_val = cache_help.retrieve_variable(var_to_get)
     return {Output.VALUE: ret_val}