Exemplo n.º 1
0
 def test_first_column_value_subqueries_1(self):
     """Verify that first_column_value_subqueries() raises ValueError.
     First_column_value_subqueries should raise when inputted column
     is not a Column object.
     """
     with self.assertRaises(ValueError):
         querying.first_column_value_subqueries(self.mock_engine,
                                                self.mock_executable, None,
                                                self.values)
Exemplo n.º 2
0
    def test_first_column_value_subqueries_4(self):
        """Verify first_column_value_subqueries() calls Column.in_().
        """
        querying.first_column_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_first_column_value_subqueries_2(self):
     """Verify that first_column_value_subqueries() raises ValueError.
     first_column_value_subqueries() should raise when column does not
     belong to any of the tables joined for the query.
     """
     self.mock_executable.is_derived_from.return_value = False
     with self.assertRaises(ValueError):
         querying.first_column_value_subqueries(self.mock_engine,
                                                self.mock_executable,
                                                self.mock_in_column,
                                                self.values)
Exemplo n.º 4
0
    def test_first_column_value_subqueries_5(self):
        """Verify that first_column_value_subqueries() chunks values correctly.
        """
        querying.first_column_value_subqueries(self.mock_engine,
                                               self.mock_executable,
                                               self.mock_in_column,
                                               self.values,
                                               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_first_column_value_subqueries_3(self, convert_to_encoded_mock):
        """Verify first_column_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.first_column_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_first_column_value_subqueries(self):
        """Verify first_column_value_subqueries() retrieves expected data.
        """
        where_clause = querying.build_where_clause(self.graph,
                                                   "phage.Cluster=A")
        phageid = querying.get_column(self.metadata, "phage.PhageID")
        select = querying.build_select(self.graph, phageid, where=where_clause)

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

        self.assertTrue("Trixie" in results)
        self.assertTrue("D29" in results)
        self.assertFalse("Alice" in results)
        self.assertFalse("Myrna" in results)