# -*- coding: utf-8 -*-
import unittest
import datac

class Instantiation(unittest.TestCase):
    """
    Test instantiation works according to spec
    """
    def test_params_non_dict(self):
        """
        Datac instantiation should fail is params is not a dict
        """
        params = None
        abscissae = [1,2]
        abscissa_name = "abscissa"

        self.assertRaises(TypeError, datac.Datac, params, abscissae, abscissa_name)

    def test_abscissae_non_iterable(self):
        """
        Datac instantiation should fail if abscissae is not iterable
        """
        params = {"fake": 1.}
        abscissae = None
        abscissa_name = "abscissa"

        self.assertRaises(TypeError, datac.Datac, params, abscissae, abscissa_name)

    def test_abscissae_string(self):
        """
        Datac instantiation should fail if abscissae is a string
        """
        params = {"fake": 1.}
        abscissae = "a string!"
        abscissa_name = "abscissa"

        self.assertRaises(TypeError, datac.Datac, params, abscissae, abscissa_name)

    def test_abscissae_name_non_string(self):
        """
        Datac instantiation should fail if abscissae_name is not a string
        """
        params = {"fake": 1.}
        abscissae = [1, 2]
        abscissa_name = None

        self.assertRaises(TypeError, datac.Datac, params, abscissae, abscissa_name)

@@ -1359,28 +1359,1213 @@
 , abscissae, abscissa_name)%0A
+%0A%0Aclass API(unittest.TestCase):%0A    %22%22%22%0A    Test API behaves%0A    %22%22%22%0A    def setUp(self):%0A        %22%22%22%0A        Create a Datac object for testing%0A        %22%22%22%0A        params = %7B%22fake%22: 1.%7D%0A        abscissae = %5B1, 2%5D%0A        abscissa_name = %22abscissa%22%0A%0A        self.test_obj = datac.Datac(params, abscissae, abscissa_name)%0A%0A    def tearDown(self):%0A        %22%22%22%0A        Destroy the test Datac object%0A        %22%22%22%0A        del self.test_obj%0A%0A    def test_params_read_only(self):%0A        %22%22%22%0A        The params attribute should be read-only%0A        %22%22%22%0A        legit_params = %7B%22one%22: 1.%7D%0A%0A        self.assertRaises(AttributeError, setattr, self.test_obj, %22params%22, legit_params)%0A%0A    def test_abscissae_read_only(self):%0A        %22%22%22%0A        The abscissae attribute should be read-only%0A        %22%22%22%0A        legit_abscissae = %5B3, 4%5D%0A%0A        self.assertRaises(AttributeError, setattr, self.test_obj, %22abscissae%22, legit_abscissae)%0A%0A    def test_abscissa_name_read_only(self):%0A        %22%22%22%0A        The abscissa_name attribute should be read-only%0A        %22%22%22%0A        legit_abscissa_name = %22legit%22%0A%0A        self.assertRaises(AttributeError, setattr, self.test_obj, %22abscissa_name%22, legit_abscissa_name)%0A%0A

Add some API tests