示例#1
0
 def test_add_term(self) -> None:
     """Test QueryBase.add_term()"""
     query = census.QueryBase()
     query.add_term('field', 'value')
     term = query.data.terms[0]
     self.assertEqual(term.field, 'field')
     self.assertEqual(term.value, 'value')
     self.assertEqual(term.modifier, census.SearchModifier.EQUAL_TO)
示例#2
0
 def test_add_join(self) -> None:
     """Test QueryBase.add_join()"""
     query = census.QueryBase('collection')
     join = census.JoinedQuery('join')
     query.add_join(join)
     # The joins cannot be compared directly as the add_join method creates
     # a copy of the join.
     self.assertDictEqual(query.joins[0].__dict__, join.__dict__)
示例#3
0
 def test_show(self) -> None:
     """Test QueryBase.show()"""
     query = census.QueryBase('collection')
     self.assertListEqual(query.data.show, [])
     query.show('one', 'two')
     self.assertListEqual(query.data.show, ['one', 'two'])
示例#4
0
 def test_hide(self) -> None:
     """Test QueryBase.hide()"""
     query = census.QueryBase('collection')
     self.assertListEqual(query.data.hide, [])
     query.hide('one', 'two')
     self.assertListEqual(query.data.hide, ['one', 'two'])
示例#5
0
 def test_create_join(self) -> None:
     """Test QueryBase.create_join()"""
     query = census.QueryBase('collection')
     join = query.create_join('join')
     self.assertListEqual(query.joins, [join])