def add_content_id_json(self, id, json_content):
     if (os.path.isfile(self.gpg.get_file())):
         jm = JSONManager(json.loads(str(self.gpg.decrypt_content())))
     else:
         jm = JSONManager(json.loads('{}'))
     jkv = jm.add(id, json.loads(str(json_content)))
     jkv = json.dumps(jkv)
     self.gpg.encrypt_content(jkv)
Beispiel #2
0
def test_add_value():
    json = {
        "One": {
            "user": "******",
            "password": "******",
            "url": "url1",
            "other": "other1"
        },
        "Two": {
            "user": "******",
            "password": "******",
            "url": "url2",
            "other": "other2"
        }
    }
    jm = JSONManager(json)
    x = jm.add("Three", {
        "user": "******",
        "password": "******",
        "url": "url3",
        "other": "other3"
    })
    assert x == {
        "One": {
            "user": "******",
            "password": "******",
            "url": "url1",
            "other": "other1"
        },
        "Two": {
            "user": "******",
            "password": "******",
            "url": "url2",
            "other": "other2"
        },
        "Three": {
            "user": "******",
            "password": "******",
            "url": "url3",
            "other": "other3"
        }
    }
Beispiel #3
0
def test_add_value_exist():
    json = {
        "One": {
            "user": "******",
            "password": "******",
            "url": "url1",
            "other": "other1"
        },
        "Two": {
            "user": "******",
            "password": "******",
            "url": "url2",
            "other": "other2"
        }
    }
    jm = JSONManager(json)
    with pytest.raises(KeyError):
        x = jm.add(
            "Two", {
                "user": "******",
                "password": "******",
                "url": "url3",
                "other": "other3"
            })