def test_serialize_with_nested_modules(self): parent = ModuleFactory(slug='a-module', order=1) child = ModuleFactory(slug='b-module', order=2, parent=parent) ModuleFactory(slug='c-module', order=3, parent=child) other_child = ModuleFactory(slug='d-module', order=4, parent=parent) serialization = parent.serialize() assert_that( serialization, has_entry('modules', contains(child.serialize(), other_child.serialize()))) assert_that(serialization['modules'][0]['parent'], has_entry('id', str(parent.id)))
def test_serialize_with_nested_modules(self): parent = ModuleFactory(slug='a-module', order=1) child = ModuleFactory(slug='b-module', order=2, parent=parent) ModuleFactory( slug='c-module', order=3, parent=child) other_child = ModuleFactory(slug='d-module', order=4, parent=parent) serialization = parent.serialize() assert_that( serialization, has_entry('modules', contains(child.serialize(), other_child.serialize()))) assert_that( serialization['modules'][0]['parent'], has_entry('id', str(parent.id)))
def test_serialize_with_dataset_but_no_query_parameters(self): module = ModuleFactory( slug='a-module', type=self.module_type, data_set=self.data_set, order=1, dashboard=self.dashboard_a) serialization = module.serialize() assert_that(serialization['slug'], equal_to('a-module')) assert_that( serialization['type']['id'], equal_to(str(self.module_type.id))) assert_that( serialization['dashboard']['id'], equal_to(str(self.dashboard_a.id))) assert_that(serialization['query_parameters'], equal_to(None)) assert_that( serialization, has_entry( 'data_group', equal_to(self.data_set.data_group.name))) assert_that( serialization, has_entry( 'data_type', equal_to(self.data_set.data_type.name)))
def test_serialize_with_no_nested_modules(self): module = ModuleFactory(slug='a-module', type=self.module_type, options={}, query_parameters={}, order=1, dashboard=self.dashboard_a) serialization = module.serialize() assert_that(serialization['modules'], equal_to([])) assert_that(serialization['parent'], equal_to(None))
def test_serialize_with_no_nested_modules(self): module = ModuleFactory( slug='a-module', type=self.module_type, options={}, query_parameters={}, order=1, dashboard=self.dashboard_a) serialization = module.serialize() assert_that(serialization['modules'], equal_to([])) assert_that(serialization['parent'], equal_to(None))
def test_serialize_with_no_dataset(self): module = ModuleFactory(slug='a-module', type=self.module_type, order=1, dashboard=self.dashboard_a) serialization = module.serialize() assert_that(serialization['slug'], equal_to('a-module')) assert_that(serialization['type']['id'], equal_to(str(self.module_type.id))) assert_that(serialization['dashboard']['id'], equal_to(str(self.dashboard_a.id))) assert_that(serialization['query_parameters'], equal_to(None)) assert_that(serialization['data_set'], equal_to(None))
def test_serialize_with_no_dataset(self): module = ModuleFactory( slug='a-module', type=self.module_type, order=1, dashboard=self.dashboard_a) serialization = module.serialize() assert_that(serialization['slug'], equal_to('a-module')) assert_that( serialization['type']['id'], equal_to(str(self.module_type.id))) assert_that( serialization['dashboard']['id'], equal_to(str(self.dashboard_a.id))) assert_that(serialization['query_parameters'], equal_to(None)) assert_that(serialization['data_set'], equal_to(None))
def test_serialize_with_dataset_but_no_query_parameters(self): module = ModuleFactory(slug='a-module', type=self.module_type, data_set=self.data_set, order=1, dashboard=self.dashboard_a) serialization = module.serialize() assert_that(serialization['slug'], equal_to('a-module')) assert_that(serialization['type']['id'], equal_to(str(self.module_type.id))) assert_that(serialization['dashboard']['id'], equal_to(str(self.dashboard_a.id))) assert_that(serialization['query_parameters'], equal_to(None)) assert_that( serialization, has_entry('data_group', equal_to(self.data_set.data_group.name))) assert_that( serialization, has_entry('data_type', equal_to(self.data_set.data_type.name)))