Exemplo n.º 1
0
 def test_execute_value_subqueries_1(self):
     """Verify execute_value_subqueries() raises ValueError from bad column.
     """
     with self.assertRaises(ValueError):
         querying.execute_value_subqueries(self.mock_engine,
                                           self.mock_executable, None,
                                           self.values)
Exemplo n.º 2
0
    def test_execute_value_subqueries_4(self):
        """Verify that execute_value_subqueries() calls Column.in_().
        """
        querying.execute_value_subqueries(self.mock_engine,
                                          self.mock_executable,
                                          self.mock_in_column, self.values)

        self.mock_in_column.in_.assert_called_with(self.values)
Exemplo n.º 3
0
    def test_execute_value_subqueries_2(self):
        """Verify execute_value_subqueries() raises ValueError from bad column.
        """
        self.mock_executable.is_derived_from.return_value = False

        with self.assertRaises(ValueError):
            querying.execute_value_subqueries(self.mock_engine,
                                              self.mock_executable,
                                              self.mock_in_column, self.values)
Exemplo n.º 4
0
    def test_execute_value_subqueries_5(self):
        """Verify that execute_value_subqueries chunks values correctly.
        """
        querying.execute_value_subqueries(self.mock_engine,
                                          self.mock_executable,
                                          self.mock_in_column,
                                          self.values,
                                          return_dict=False,
                                          limit=2)

        self.mock_in_column.in_.assert_any_call(self.values[:2])
        self.mock_in_column.in_.assert_any_call([self.values[2]])
Exemplo n.º 5
0
    def test_execute_value_subqueries_3(self, convert_to_encoded_mock):
        """Verify execute_value_subqueries() calls convert_to_encoded().
        """
        type_mock = Mock()
        type(type_mock).python_type = PropertyMock(return_value=bytes)
        type(self.mock_in_column).type = type_mock

        convert_to_encoded_mock.return_value = self.values

        querying.execute_value_subqueries(self.mock_engine,
                                          self.mock_executable,
                                          self.mock_in_column, self.values)

        convert_to_encoded_mock.assert_called_with(self.values)
Exemplo n.º 6
0
    def test_execute_value_subqueries(self):
        """Verify execute_value_subqueries() retrieves expected data.
        """
        where_clause = querying.build_where_clause(self.graph,
                                                   "phage.Cluster=A")
        phage_table = querying.get_table(self.metadata, "phage")
        phageid = querying.get_column(self.metadata, "phage.PhageID")
        select = querying.build_select(self.graph,
                                       phage_table,
                                       where=where_clause)

        results = querying.execute_value_subqueries(
            self.engine,
            select,
            phageid, ["Trixie", "D29", "Alice", "Myrna"],
            limit=2)

        for result in results:
            self.assertEqual(result["Cluster"], "A")