Ejemplo n.º 1
0
def main():
    path = "examples/apyr.jpg"
    path = os.path.abspath(path)
    s = Steganography(path)

    s.encode("Sample text")
    s.save("examples/apyr - encoded.jpg")

    print(s.decode("examples/apyr - encoded.png"))
Ejemplo n.º 2
0
def test_save_successful(test_image, tmp_folder):
    # ARRANGE
    s = Steganography(test_image)
    s.encode("doesnt matter")

    mock_png_path = os.path.join(tmp_folder, "save_sucess.png")
    s._path_as_png = MagicMock(return_value=mock_png_path)

    # ACT
    s.save(mock_png_path)

    # ASSERT
    assert os.path.exists(mock_png_path)
Ejemplo n.º 3
0
def test_save_not_successful(test_image, tmp_folder):
    # ARRANGE
    s = Steganography(test_image)

    mock_png_path = os.path.join(tmp_folder, "save_not_sucessful.png")
    s._path_as_png = MagicMock()

    # ACT
    s.save(mock_png_path)

    # ASSERT
    assert not os.path.exists(mock_png_path)
    s._path_as_png.assert_not_called()
Ejemplo n.º 4
0
def test_encode_and_decode_with_path_for_decoding(tmp_folder, test_image,
                                                  random_words):
    # ARRANGE
    for idx, word in enumerate(random_words):
        s = Steganography(test_image)

        # ACT
        s.encode(word)

        tmp_file = os.path.join(tmp_folder, f"image{idx}.jpg")
        s.save(tmp_file)

        result = s.decode(tmp_file.replace("jpg", "png"))

        # ASSERT
        assert result == word