def test_unwrap(self): cif_wrapper = CIFWrapper(self.raw_dictionary['TEST_BLOCK_2'], "NEW_ID") self.assertEquals(cif_wrapper.unwrap(), {'NEW_ID': {'_test_category_1': {'test_value_1': [1, 2, 3, 4]}}}, "CIFWrapper to dictionary conversion failed") cif_wrapper = CIFWrapper(self.raw_dictionary['TEST_BLOCK_2']) for unique_id, data in cif_wrapper.unwrap().items(): self.assertNotEquals(unique_id, '', "No unique datablock id was assigned") self.assertEquals(data, {'_test_category_1': {'test_value_1': [1, 2, 3, 4]}}, "CIFWrapper to dictionary conversion failed")
def test_wrapperTable_setattr_setitem(self): cif_wrapper = CIFWrapper(self.raw_dictionary['TEST_BLOCK_2'], "NEW_ID") # # dot notation access cif_wrapper._test_category_1['test_value_2'] = ['a', 'b', 'c', 'd'] self.assertEqual(cif_wrapper._test_category_1['test_value_2'], ['a', 'b', 'c', 'd'], "Conventional attribute setter failed or gave inconsistent results") cif_wrapper._test_category_1['test_value_2'] = "FOO" self.assertEqual(cif_wrapper._test_category_1['test_value_2'], ["FOO",], "Attribute setter failed to overwrite or gave inconsistent results") cif_wrapper._test_category_1.test_value_3 = "Bundy" self.assertEqual(cif_wrapper._test_category_1['test_value_3'], ["Bundy",], "Dot-notation attribute setting failed to overwrite or gave inconsistent results")
def test_listContents(self): cif_wrapper = CIFWrapper(self.raw_dictionary['TEST_BLOCK_1']) categories = cif_wrapper.contents() categories.sort() self.assertEqual(categories, ['_test_category_1', '_test_category_2'], "Item list for the category is incorrect")