import os
from unittest import TestCase

from KeynoteAPI import Keynote


def _get_fixture_path(name):
    return os.path.join(os.path.abspath(os.path.dirname(__file__)), name)


class TestPicture(TestCase):
    def setUp(self):
        self.keynote = Keynote(_get_fixture_path("test.key"))
        self.slide = self.keynote.slides[1]

    def test_picture_count(self):
        self.assertEquals = self.slide.pictures[0]


    def test_picture_properties(self):
        picture = self.slide.pictures[0]
        self.assertEquals(picture.relative_path, "IMG_2274-1.jpg")
        self.assertEquals(picture.natural_width, 1920)
        self.assertEquals(picture.natural_height, 2570)
        self.assertEquals(picture.display_width, 507.2684020996094)
        self.assertEquals(picture.display_height, 678.9998779296875)
        self.assertEquals(picture.display_x, 37.0)
        self.assertEquals(picture.display_y, -33.0)


class TestSlide(TestCase):
    def setUp(self):
        self.keynote = Keynote(_get_fixture_path("test.key"))

    def test_count(self):
        self.assertEquals(len(self.keynote.slides), 2)

    def test_id(self):
        self.assertEquals(self.keynote.slides[0].id, "BGSlide-0")


class TestKeynote(TestCase):
    def setUp(self):
        self.keynote = Keynote(_get_fixture_path("test.key"))

    def test_size(self):
        self.assertEquals(self.keynote.size, "1920x1080")


@@ -66,16 +66,44 @@
 eynote%0A%0A
+TEST_IMG = %22IMG_2274-1.jpg%22%0A
 %0Adef _ge
@@ -573,32 +573,24 @@
 e_path, 
-%22IMG_2274-1.jpg%22
+TEST_IMG
 )%0A      
@@ -882,16 +882,16 @@
 , 37.0)%0A
-
         
@@ -935,16 +935,139 @@
 -33.0)%0A%0A
+    def test_saveas(self):%0A        picture = self.slide.pictures%5B0%5D%0A        picture.save_as()%0A        os.remove(TEST_IMG)%0A%0A
 %0Aclass T

Add test for saving picture out