Beispiel #1
0
 def test_load_obj(self):
     test_data = {
         'metadata': {
             'foo': 'bar'
         },
         'name': ['Johnny', 'B', 'Good'],
         'class': {
             'module': 'fractions',
             'name': 'Fraction'
         },
         'data': {}
     }
     after = BW2Package._load_obj(copy.deepcopy(test_data), False)
     for key in test_data:
         self.assertTrue(key in after)
     with self.assertRaises(InvalidPackage):
         BW2Package._load_obj({})
     self.assertEqual(after['class'], fractions.Fraction)
Beispiel #2
0
 def test_load_obj(self):
     test_data = {
         "metadata": {
             "foo": "bar"
         },
         "name": ["Johnny", "B", "Good"],
         "class": {
             "module": "fractions",
             "name": "Fraction"
         },
         "data": {},
     }
     after = BW2Package._load_obj(copy.deepcopy(test_data), False)
     for key in test_data:
         self.assertTrue(key in after)
     with self.assertRaises(InvalidPackage):
         BW2Package._load_obj({})
     self.assertEqual(after["class"], fractions.Fraction)
Beispiel #3
0
 def test_create_obj(self):
     mock_data = {
         'class': {
             'module': 'bw2io.tests',
             'name': 'MockDS'
         },
         'metadata': {
             'circle': 'square'
         },
         'data': [],
         'name': 'Wilhelm'
     }
     data = BW2Package._load_obj(mock_data)
     obj = BW2Package._create_obj(data)
     self.assertTrue(isinstance(obj, MockDS))
     self.assertTrue("Wilhelm" in mocks)
     self.assertEqual(mocks['Wilhelm'], {'circle': 'square'})
     mocks.__init__()
     self.assertEqual(mocks['Wilhelm'], {'circle': 'square'})
     self.assertEqual(MockDS("Wilhelm").load(), [])
Beispiel #4
0
 def test_create_obj(self):
     mock_data = {
         "class": {
             "module": "bw2io.tests",
             "name": "MockDS"
         },
         "metadata": {
             "circle": "square"
         },
         "data": [],
         "name": "Wilhelm",
     }
     data = BW2Package._load_obj(mock_data)
     obj = BW2Package._create_obj(data)
     self.assertTrue(isinstance(obj, MockDS))
     self.assertTrue("Wilhelm" in mocks)
     self.assertEqual(mocks["Wilhelm"], {"circle": "square"})
     mocks.__init__()
     self.assertEqual(mocks["Wilhelm"], {"circle": "square"})
     self.assertEqual(MockDS("Wilhelm").load(), [])