aboutsummaryrefslogtreecommitdiffstats
path: root/selftest
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-05-04 12:05:05 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2020-05-04 16:36:33 +0200
commitea8c3d4b1235ef703e54cd963bc96f6716168387 (patch)
tree965e842905c4f2dddd41421365d7f308a56b8800 /selftest
parent96b17df282234f02972c6e4dbd02134f89767400 (diff)
Generate schemas dynamically from pieces provided by each object class
This way we benefit from: * knowing which attributes are used/required by each object class and subclass * Having validation function definitions near the class going to use them Change-Id: I8fd6773c51d19405a585977af4ed72cad2b21db1
Diffstat (limited to 'selftest')
-rwxr-xr-xselftest/config_test.py28
-rwxr-xr-xselftest/resource_test.py4
-rwxr-xr-xselftest/suite_test.py4
3 files changed, 22 insertions, 14 deletions
diff --git a/selftest/config_test.py b/selftest/config_test.py
index 83a8d06..c26ebd1 100755
--- a/selftest/config_test.py
+++ b/selftest/config_test.py
@@ -116,35 +116,35 @@ print('- Combine dicts:')
a = {'times': '2'}
b = {'type': 'osmo-bts-trx'}
res = {'times': '2', 'type': 'osmo-bts-trx'}
-config.combine(a, b)
+schema.combine(a, b)
assert a == res
print('- Combine dicts 2:')
a = {'times': '1', 'label': 'foo', 'type': 'osmo-bts-trx'}
b = {'type': 'osmo-bts-trx'}
res = {'times': '1', 'label': 'foo', 'type': 'osmo-bts-trx'}
-config.combine(a, b)
+schema.combine(a, b)
assert a == res
print('- Combine lists:')
a = { 'a_list': ['x', 'y', 'z'] }
b = { 'a_list': ['y'] }
res = {'a_list': ['x', 'y', 'z']}
-config.combine(a, b)
+schema.combine(a, b)
assert a == res
print('- Combine lists 2:')
a = { 'a_list': ['x'] }
b = { 'a_list': ['w', 'u', 'x', 'y', 'z'] }
res = {'a_list': ['x', 'w', 'u', 'y', 'z']}
-config.combine(a, b)
+schema.combine(a, b)
assert a == res
print('- Combine lists 3:')
a = { 'a_list': ['x', 3] }
b = { 'a_list': ['y', 'z'] }
try:
- config.combine(a, b)
+ schema.combine(a, b)
except ValueError:
print("ValueError expected")
@@ -152,7 +152,7 @@ print('- Combine lists 4:')
a = { 'a_list': [2, 3] }
b = { 'a_list': ['y', 'z'] }
try:
- config.combine(a, b)
+ schema.combine(a, b)
except ValueError:
print("ValueError expected")
@@ -160,7 +160,7 @@ print('- Combine lists 5:')
a = { 'a_list': [{}, {}] }
b = { 'a_list': ['y', 'z'] }
try:
- config.combine(a, b)
+ schema.combine(a, b)
except ValueError:
print("ValueError expected")
@@ -168,49 +168,49 @@ print('- Combine lists 6:')
a = { 'a_list': [{}, {}] }
b = { 'a_list': [{}] }
res = {'a_list': [{}, {}]}
-config.combine(a, b)
+schema.combine(a, b)
assert a == res
print('- Combine lists 7:')
a = { 'times': '1', 'label': 'foo', 'trx': [{'nominal power': '10'}, {'nominal power': '12'}] }
b = { 'type': 'osmo-bts-trx', 'trx': [{'nominal power': '10'}, {'nominal power': '12'}] }
res = {'times': '1', 'label': 'foo', 'trx': [{'nominal power': '10'}, {'nominal power': '12'}], 'type': 'osmo-bts-trx'}
-config.combine(a, b)
+schema.combine(a, b)
assert a == res
print('- Combine lists 8:')
a = { 'times': '1', 'label': 'foo', 'trx': [{'nominal power': '10'}] }
b = { 'type': 'osmo-bts-trx', 'trx': [{'nominal power': '10'}, {'nominal power': '12'}] }
res = {'times': '1', 'label': 'foo', 'trx': [{'nominal power': '10'}, {'nominal power': '12'}], 'type': 'osmo-bts-trx'}
-config.combine(a, b)
+schema.combine(a, b)
assert a == res
print('- Combine lists 9:')
a = { 'times': '1', 'label': 'foo', 'trx': [{'nominal power': '10'}, {'nominal power': '12'}] }
b = { 'type': 'osmo-bts-trx', 'trx': [{'nominal power': '10'}] }
res = {'times': '1', 'label': 'foo', 'trx': [{'nominal power': '10'}, {'nominal power': '12'}], 'type': 'osmo-bts-trx'}
-config.combine(a, b)
+schema.combine(a, b)
assert a == res
print('- Combine lists 10:')
a = { 'times': '1', 'label': 'foo', 'trx': [{'nominal power': '10'}, {'nominal power': '12'}] }
b = { 'type': 'osmo-bts-trx', 'trx': [{}, {'nominal power': '12'}] }
res = {'times': '1', 'label': 'foo', 'trx': [{'nominal power': '10'}, {'nominal power': '12'}], 'type': 'osmo-bts-trx'}
-config.combine(a, b)
+schema.combine(a, b)
assert a == res
print('- Combine lists 13:')
a = { 'times': '1', 'label': 'foo', 'trx': [{}, {'nominal power': '12'}] }
b = { 'type': 'osmo-bts-trx', 'trx': [{'nominal power': '10'}, {'nominal power': '12'}] }
res = {'times': '1', 'label': 'foo', 'trx': [{'nominal power': '10'}, {'nominal power': '12'}], 'type': 'osmo-bts-trx'}
-config.combine(a, b)
+schema.combine(a, b)
assert a == res
print('- Combine lists 14:')
a = { 'times': '1', 'label': 'foo', 'trx': [] }
b = { 'type': 'osmo-bts-trx', 'trx': [] }
res = {'times': '1', 'label': 'foo', 'trx': [], 'type': 'osmo-bts-trx'}
-config.combine(a, b)
+schema.combine(a, b)
assert a == res
# vim: expandtab tabstop=4 shiftwidth=4
diff --git a/selftest/resource_test.py b/selftest/resource_test.py
index f399e20..ecbeb24 100755
--- a/selftest/resource_test.py
+++ b/selftest/resource_test.py
@@ -7,6 +7,7 @@ import shutil
import atexit
import _prep
from osmo_gsm_tester.core import config, log, util
+from osmo_gsm_tester.core.schema import generate_schemas
from osmo_gsm_tester import resource
workdir = util.get_tempdir()
@@ -16,6 +17,9 @@ config.ENV_CONF = './conf'
log.get_process_id = lambda: '123-1490837279'
+# Generate supported schemas dynamically from objects:
+generate_schemas()
+
print('- expect solutions:')
pprint.pprint(
resource.solve([ [0, 1, 2],
diff --git a/selftest/suite_test.py b/selftest/suite_test.py
index c4dd5bf..1fb95ec 100755
--- a/selftest/suite_test.py
+++ b/selftest/suite_test.py
@@ -3,6 +3,7 @@ import os
import _prep
import shutil
from osmo_gsm_tester.core import log, config, util
+from osmo_gsm_tester.core.schema import generate_schemas
from osmo_gsm_tester import suite, report
config.ENV_CONF = './suite_test'
@@ -24,6 +25,9 @@ class FakeTrial(log.Origin):
#log.style_change(trace=True)
+# Generate supported schemas dynamically from objects:
+generate_schemas()
+
print('- non-existing suite dir')
assert(log.run_logging_exceptions(suite.load, 'does_not_exist') == None)