Commits

Chris Mutel committed 9dd42cc

Add test for geomapping array

  • Participants
  • Parent commits 77f7b1a

Comments (0)

Files changed (2)

File bw2data/tests/database.py

         fieldnames = {'activity', 'geo', 'row', 'col'}
         self.assertFalse(fieldnames.difference(set(array.dtype.names)))
 
+    def test_geomapping_array_includes_only_processes(self):
+        database = Database("a database")
+        database.register()
+        database.write({
+            ("a database", "foo"): {
+                'exchanges': [],
+                'type': 'process',
+                'location': 'bar'
+            },
+            ("a database", "baz"): {
+                'exchanges': [],
+                'type': 'emission'
+            },
+        })
+        database.process()
+        fp = os.path.join(
+            config.dir,
+            u"processed",
+            database.name + u".geomapping.pickle"
+        )
+        array = pickle.load(open(fp, "rb"))
+        self.assertEqual(array.shape, (1,))
+        self.assertEqual(array[0]['geo'], geomapping['bar'])
+
     def test_processed_array(self):
         database = Database("a database")
         database.register()

File bw2data/tests/validation.py

         with self.assertRaises(Invalid):
             valid_tuple(["a", "b"])
         with self.assertRaises(Invalid):
-            valid_tuple([1, "b"])
+            valid_tuple((1, "b"))
         self.assertTrue(valid_tuple(("a", "b")))
         self.assertTrue(valid_tuple(("a", ())))
         self.assertTrue(valid_tuple(("a", [])))