def test_expand_set_str_representation(self): items = ['item', 'parent', 'parent.child'] expand = ' '.join(sorted(items)) sut = ExpandSet.load(expand) expand_repr = str(sut) self.assertEqual(expand_repr, expand)
def test_extract_expand_set(self): sut = ExpandSet.load( 'item parent parent.child parent.child.second parent.first.third.parent' ) parent_set = sut.extract(ExpandItem.load('parent')) parent_set_repr = str(parent_set) self.assertEqual(parent_set_repr, 'child child.second first.third.parent')
def _get_trainings_for_category(uid: str): expand = ExpandSet.load(request.args.get('expand')) models = self._service.get_trainings_for_category(uid, expand=expand) return self._return_many(models)
def _get_all(): expand = ExpandSet.load(request.args.get('expand')) return self._get_all(expand)
def _get_by_id(uid: str): expand = ExpandSet.load(request.args.get('expand')) return self._get_by_id(UUID(uid), expand)
def _get_categories_for_reflection(uid: str): expand = ExpandSet.load(request.args.get('expand')) models = self._service.get_categories_for_reflection(uid, expand=expand) return self._return_many(models)
def _get_reflection_by_languages(n_id: str, f_id: str): expand = ExpandSet.load(request.args.get('expand')) model = self._service.get_reflection_by_languages(n_id, f_id, expand=expand) return self._return_one(model)
def test_expand_set_created(self): sut = ExpandSet.load('item') self.assertTrue(sut.contains(ExpandItem.load('item')))
def test_parent_not_exists_on_only_child_specified(self): sut = ExpandSet.load('parent.first.second') self.assertFalse(sut.contains(ExpandItem.load('parent')))
def test_expand_set_with_parent(self): sut = ExpandSet.load('item parent parent.child') self.assertTrue(sut.contains(ExpandItem.load('item'))) self.assertTrue(sut.contains(ExpandItem.load('parent'))) self.assertTrue(sut.contains(ExpandItem.load('parent.child')))
def test_expand_set_append(self): sut = ExpandSet() sut.append(ExpandItem.load('item')) self.assertTrue(sut.contains(ExpandItem.load('item')))
def _return_many(self, models: Sequence[Model]) -> Response: return return_many(models, self._serializer, ExpandSet.load(request.args.get('expand')))
def _return_one(self, model: Model) -> Response: return return_one(model, self._serializer, ExpandSet.load(request.args.get('expand')))