class ConfigurationSpecRetrieverTestSuite(TestCase):

    def setUp(self):
        self.retriever = ConfigurationSpecRetriever()
        self.retriever.retrieve_area_codes = Mock(return_value=['3201'])
        self.retriever.retrieve_meta_info = Mock(
            return_value={'user': '******'})

    def test_a(self):
        """Test the construction of a single ConfigurationSpec."""
        dir_name = '/path/to/configuration/directory'
        config_type = 'waterbalans'
        config_specs = self.retriever.retrieve(dir_name, config_type)
        self.assertEqual(1, len(config_specs))
        self.assertEqual('3201', config_specs[0]['area_code'])

    def test_b(self):
        """Test retrieve_area_codes_from_dbf is called correctly."""
        dir_name = '/path/to/configuration/directory'
        config_type = 'waterbalans'
        self.retriever.retrieve(dir_name, config_type)
        args, kwargs = self.retriever.retrieve_area_codes.call_args
        self.assertEqual(
            '/path/to/configuration/directory/aanafvoer_waterbalans.dbf',
            args[0])

    def test_c(self):
        """Test retrieve_area_codes_from_dbf is called correctly."""
        dir_name = '/path/to/configuration/directory'
        config_type = 'esf1'
        self.retriever.retrieve(dir_name, config_type)
        args, kwargs = self.retriever.retrieve_area_codes.call_args
        self.assertEqual('/path/to/configuration/directory/aanafvoer_esf1.dbf',
                         args[0])

    def test_d(self):
        """Test the retrieval of the 'user' attribute."""
        dir_name = '/path/to/configuration/directory'
        config_type = 'waterbalans'
        config_specs = self.retriever.retrieve(dir_name, config_type)
        self.assertEqual(1, len(config_specs))
        self.assertEqual('Pieter Swinkels', config_specs[0]['user'])

    def test_e(self):
        """Test retrieva_meta_info receives the right parameters."""
        dir_name = '/path/to/configuration/directory'
        config_type = 'waterbalans'
        self.retriever.retrieve(dir_name, config_type)
        args, kwargs = self.retriever.retrieve_meta_info.call_args
        self.assertEqual('/path/to/configuration/directory/description.txt',
                         args[0])
 def setUp(self):
     self.retriever = ConfigurationSpecRetriever()
     self.retriever.retrieve_area_codes = Mock(return_value=['3201'])
     self.retriever.retrieve_meta_info = Mock(
         return_value={'user': '******'})