Exemplo n.º 1
0
class MetaDataWriteXMLTest(unittest.TestCase):
    """
    Tests for XMLWriter.
    """
    WRITABLE_METADATA = MetaDataReadXMLTest.EXPECTED_DICTIONARY

    def setUp(self):
        """
        Sets up necessary files for the tests.
        """
        meta_data_entity = GenericMetaData(self.WRITABLE_METADATA)
        self.meta_writer = XMLWriter(meta_data_entity)
        self.result_path = os.path.join(os.path.dirname(__file__),
                                        "Operation.xml")

    def tearDown(self):
        """
        Remove created XML file.
        """
        unittest.TestCase.tearDown(self)
        os.remove(self.result_path)

    def test_write_metadata(self):
        """
        Test that an XML file is created and correct data is written in it.
        """
        self.assertFalse(os.path.exists(self.result_path))
        self.meta_writer.write(self.result_path)
        self.assertTrue(os.path.exists(self.result_path))
        reader = XMLReader(self.result_path)
        meta_data = reader.read_metadata()
        for key, value in MetaDataReadXMLTest.EXPECTED_DICTIONARY.iteritems():
            found_value = meta_data[key]
            self.assertEqual(value, found_value)
Exemplo n.º 2
0
class TestMetaDataWriteXML():
    """
    Tests for XMLWriter.
    """ 
    WRITABLE_METADATA = TestMetaDataReadXML.EXPECTED_DICTIONARY
    
    def setup_method(self):
        """
        Sets up necessary files for the tests.
        """
        meta_data_entity = GenericMetaData(self.WRITABLE_METADATA)
        self.meta_writer = XMLWriter(meta_data_entity)
        self.result_path = os.path.join(os.path.dirname(__file__), "Operation.xml")
      
    def teardown_method(self):
        """
        Remove created XML file.
        """
        os.remove(self.result_path)
        
    def test_write_metadata(self):
        """
        Test that an XML file is created and correct data is written in it.
        """
        assert not os.path.exists(self.result_path)
        self.meta_writer.write(self.result_path)
        assert os.path.exists(self.result_path)
        reader = XMLReader(self.result_path)
        meta_data = reader.read_metadata()
        for key, value in TestMetaDataReadXML.EXPECTED_DICTIONARY.items():
            found_value = meta_data[key]
            assert value == found_value
class MetaDataWriteXMLTest(unittest.TestCase):  
    """
    Tests for XMLWriter.
    """ 
    WRITABLE_METADATA = MetaDataReadXMLTest.EXPECTED_DICTIONARY
    
    def setUp(self):
        """
        Sets up necessary files for the tests.
        """
        meta_data_entity = GenericMetaData(self.WRITABLE_METADATA)
        self.meta_writer = XMLWriter(meta_data_entity)
        self.result_path = os.path.join(os.path.dirname(__file__), "Operation.xml")
      
    def tearDown(self):
        """
        Remove created XML file.
        """
        unittest.TestCase.tearDown(self)
        os.remove(self.result_path)
        
    def test_write_metadata(self):
        """
        Test that an XML file is created and correct data is written in it.
        """
        self.assertFalse(os.path.exists(self.result_path))
        self.meta_writer.write(self.result_path)
        self.assertTrue(os.path.exists(self.result_path))
        reader = XMLReader(self.result_path)
        meta_data = reader.read_metadata()
        for key, value in MetaDataReadXMLTest.EXPECTED_DICTIONARY.iteritems():
            found_value = meta_data[key]
            self.assertEqual(value, found_value)
class TestMetaDataWriteXML():
    """
    Tests for XMLWriter.
    """ 
    WRITABLE_METADATA = TestMetaDataReadXML.EXPECTED_DICTIONARY
    
    def setup_method(self):
        """
        Sets up necessary files for the tests.
        """
        meta_data_entity = GenericMetaData(self.WRITABLE_METADATA)
        self.meta_writer = XMLWriter(meta_data_entity)
        self.result_path = os.path.join(os.path.dirname(__file__), "Operation.xml")
      
    def teardown_method(self):
        """
        Remove created XML file.
        """
        os.remove(self.result_path)
        
    def test_write_metadata(self):
        """
        Test that an XML file is created and correct data is written in it.
        """
        assert not os.path.exists(self.result_path)
        self.meta_writer.write(self.result_path)
        assert os.path.exists(self.result_path)
        reader = XMLReader(self.result_path)
        meta_data = reader.read_metadata()
        for key, value in TestMetaDataReadXML.EXPECTED_DICTIONARY.iteritems():
            found_value = meta_data[key]
            assert value == found_value