Repository: jbradberry/universe

Issue:
`name` should not be a mandatory attribute on Components
Currently a Component's name is used to determine which registry dicts an Entity gets registered into, but `name` is also a very likely name for a field.  We should do something else to set up the entity registries.

Also, change `SpeciesComponent.singular_name` to `SpeciesComponent.name`.

Discussion:

Patch:
diff --git a/universe/components.py b/universe/components.py
index 98d274a..7bba5cb 100644
--- a/universe/components.py
+++ b/universe/components.py
@@ -32,13 +32,13 @@ class Component(metaclass=MetaComponent):
 
 
 class MetadataComponent(Component):
-    name = 'metadata'
+    _name = 'metadata'
 
     type = fields.CharField(required=True)
 
 
 class PositionComponent(Component):
-    name = 'position'
+    _name = 'position'
 
     x = fields.IntField()
     y = fields.IntField()
@@ -48,7 +48,7 @@ class PositionComponent(Component):
 
 
 class QueueComponent(Component):
-    name = 'queue'
+    _name = 'queue'
 
     queue = fields.ListField()
 
@@ -57,20 +57,20 @@ class QueueComponent(Component):
 
 
 class SpeciesComponent(Component):
-    name = 'species'
+    _name = 'species'
 
-    singular_name = fields.CharField(required=True)
+    name = fields.CharField(required=True)
     plural_name = fields.CharField(required=True)
     growth_rate = fields.IntField(required=True)
 
 
 class OwnershipComponent(Component):
-    name = 'ownership'
+    _name = 'ownership'
 
     owner_id = fields.IntField(required=False)
 
 
 class PopulationComponent(Component):
-    name = 'population'
+    _name = 'population'
 
     population = fields.IntField(required=False)
diff --git a/universe/engine.py b/universe/engine.py
index 9e8d022..9158188 100644
--- a/universe/engine.py
+++ b/universe/engine.py
@@ -51,7 +51,7 @@ class Manager:
         if name in self._entity_registry:
             raise ValueError("{} is already a registered entity type.".format(name))
         _components.append(components.MetadataComponent())
-        self._entity_registry[name] = {component.name: component for component in _components}
+        self._entity_registry[name] = {component._name: component for component in _components}
 
     def get_updates(self, _id):
         return self._updates.get(_id, [])


Test patch:
diff --git a/tests/test_systems.py b/tests/test_systems.py
index 81cbaee..6711970 100644
--- a/tests/test_systems.py
+++ b/tests/test_systems.py
@@ -12,7 +12,7 @@ class PopulationTestCase(unittest.TestCase):
             'entities': {
                 0: {
                     'type': 'species',
-                    'singular_name': 'Human',
+                    'name': 'Human',
                     'plural_name': 'Humans',
                     'growth_rate': 15,
                 },
@@ -36,7 +36,7 @@ class PopulationTestCase(unittest.TestCase):
                           'entities': {
                               0: {
                                   'type': 'species',
-                                  'singular_name': 'Human',
+                                  'name': 'Human',
                                   'plural_name': 'Humans',
                                   'growth_rate': 15,
                                   },