SEBA-271 unit test for field numbers
Change-Id: Idbb6e522fddea16e8ccb265446488ba07b427198
diff --git a/VERSION b/VERSION
index 67da954..291d0de 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.1.15
+2.1.16
diff --git a/containers/chameleon/Dockerfile.chameleon b/containers/chameleon/Dockerfile.chameleon
index c37ef00..e10df7b 100644
--- a/containers/chameleon/Dockerfile.chameleon
+++ b/containers/chameleon/Dockerfile.chameleon
@@ -13,7 +13,7 @@
# limitations under the License.
# xosproject/chameleon
-FROM xosproject/xos-base:2.1.15
+FROM xosproject/xos-base:2.1.16
# xos-base already has protoc and dependencies installed
diff --git a/containers/xos/Dockerfile.client b/containers/xos/Dockerfile.client
index 363b5ae..4999830 100644
--- a/containers/xos/Dockerfile.client
+++ b/containers/xos/Dockerfile.client
@@ -13,7 +13,7 @@
# limitations under the License.
# xosproject/xos-client
-FROM xosproject/xos-libraries:2.1.15
+FROM xosproject/xos-libraries:2.1.16
# Install XOS client
COPY xos/xos_client /tmp/xos_client
diff --git a/containers/xos/Dockerfile.libraries b/containers/xos/Dockerfile.libraries
index 115fe03..2926dfa 100644
--- a/containers/xos/Dockerfile.libraries
+++ b/containers/xos/Dockerfile.libraries
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-FROM xosproject/xos-base:2.1.15
+FROM xosproject/xos-base:2.1.16
# Add libraries
COPY lib /opt/xos/lib
diff --git a/containers/xos/Dockerfile.synchronizer-base b/containers/xos/Dockerfile.synchronizer-base
index 9877367..2743e21 100644
--- a/containers/xos/Dockerfile.synchronizer-base
+++ b/containers/xos/Dockerfile.synchronizer-base
@@ -13,7 +13,7 @@
# limitations under the License.
# xosproject/xos-synchronizer-base
-FROM xosproject/xos-client:2.1.15
+FROM xosproject/xos-client:2.1.16
COPY xos/synchronizers/new_base /opt/xos/synchronizers/new_base
COPY xos/xos/logger.py /opt/xos/xos/logger.py
diff --git a/containers/xos/Dockerfile.xos-core b/containers/xos/Dockerfile.xos-core
index 653e7b9..23494e9 100644
--- a/containers/xos/Dockerfile.xos-core
+++ b/containers/xos/Dockerfile.xos-core
@@ -13,7 +13,7 @@
# limitations under the License.
# xosproject/xos-core
-FROM xosproject/xos-libraries:2.1.15
+FROM xosproject/xos-libraries:2.1.16
# Install XOS
ADD xos /opt/xos
diff --git a/lib/xos-genx/xos-genx-tests/test_generator.py b/lib/xos-genx/xos-genx-tests/test_generator.py
index 9b1a44a..1a81f8a 100644
--- a/lib/xos-genx/xos-genx-tests/test_generator.py
+++ b/lib/xos-genx/xos-genx-tests/test_generator.py
@@ -32,9 +32,11 @@
BASE_XPROTO = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/xproto/base.xproto")
TEST_XPROTO = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/xproto/test.xproto")
+FIELDTEST_XPROTO = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/xproto/fieldtest.xproto")
SKIP_DJANGO_XPROTO = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/xproto/skip_django.xproto")
VROUTER_XPROTO = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/xproto/vrouterport.xproto")
TEST_TARGET = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/xtarget/test.xtarget")
+FIELDTEST_TARGET = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/xtarget/fieldtest.xtarget")
SPLIT_TARGET = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/xtarget/split.xtarget")
TEST_ATTICS = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/attics/")
@@ -205,6 +207,28 @@
self.assertLess(base_line, xosmodel_line)
self.assertLess(xosmodel_line, vrouter_line)
+ def test_field_numbers(self):
+ args = FakeArgs()
+ args.files = [FIELDTEST_XPROTO]
+ args.target = FIELDTEST_TARGET
+ output = XOSProcessor.process(args)
+
+ def _assert_field(modelname, fieldname, id):
+ self.assertIn("%s,%s,%s" % (modelname, fieldname, id), output)
+
+ _assert_field("Site", "id", 1)
+ _assert_field("Site", "base_field", 2)
+ _assert_field("Site", "base_field2", 3)
+ _assert_field("Site", "otherstuff_field", 102)
+ _assert_field("Site", "slice_field", 201)
+ _assert_field("Site", "slices_ids", 1002)
+
+ _assert_field("Slice", "id", 1)
+ _assert_field("Slice", "base_field", 2)
+ _assert_field("Slice", "base_field2", 3)
+ _assert_field("Slice", "slice_field", 101)
+ _assert_field("Slice", "site", 102)
+
if __name__ == '__main__':
unittest.main()
diff --git a/lib/xos-genx/xos-genx-tests/xproto/fieldtest.xproto b/lib/xos-genx/xos-genx-tests/xproto/fieldtest.xproto
new file mode 100644
index 0000000..2d576e3
--- /dev/null
+++ b/lib/xos-genx/xos-genx-tests/xproto/fieldtest.xproto
@@ -0,0 +1,19 @@
+option app_label = "core";
+
+message XOSBase {
+ optional string base_field = 2 [default = "stuff", max_length = 1024];
+ optional string base_field2 = 3 [default = "stuff", max_length = 1024];
+}
+
+message Otherstuff {
+ optional string otherstuff_field = 2 [default = "stuff", max_length = 1024];
+}
+
+message Site (XOSBase, Otherstuff) {
+ optional string slice_field = 1 [default = "other stuff", max_length=1024];
+}
+
+message Slice (XOSBase) {
+ optional string slice_field = 1 [default = "other stuff", max_length=1024];
+ required manytoone site->Site:slices = 2:1002 [help_text = "The Site this Slice belongs to", null = False, db_index = True, blank = False];
+}
diff --git a/lib/xos-genx/xos-genx-tests/xtarget/fieldtest.xtarget b/lib/xos-genx/xos-genx-tests/xtarget/fieldtest.xtarget
new file mode 100644
index 0000000..89e8e9e
--- /dev/null
+++ b/lib/xos-genx/xos-genx-tests/xtarget/fieldtest.xtarget
@@ -0,0 +1,8 @@
+{% for object in proto.messages|sort(attribute='name') %}
+{%- for field in xproto_fields(object, proto.message_table) | sort(attribute='id') %}
+{{ object.name }},{{ field.name }},{{ field.id }}
+{%- endfor %}
+{%- for field in xproto_rlinks(object, proto.message_table) | sort(attribute='id') %}
+{{ object.name}},{{ field.src_port }}_ids,{{ field.id }}
+{%- endfor %}
+{%- endfor %}