def test_count(self): base = PostgreSQLBase(config=self.config) # A working count sql = 'SELECT count(*) FROM reports' count = base.count(sql) eq_(count, 2) # A working count with parameters sql = 'SELECT count(*) FROM reports WHERE url=%(url)s' params = {'url': 'http://mywebsite.com'} count = base.count(sql, params) eq_(count, 1) # A failing count sql = 'SELECT count(`invalid_field_name`) FROM reports' assert_raises(DatabaseError, base.count, sql)
def test_count(self): base = PostgreSQLBase(config=self.config) # A working count sql = "SELECT count(*) FROM reports" count = base.count(sql) self.assertEqual(count, 2) # A working count with parameters sql = "SELECT count(*) FROM reports WHERE url=%(url)s" params = {"url": "http://mywebsite.com"} count = base.count(sql, params) self.assertEqual(count, 1) # A failing count sql = "SELECT count(`invalid_field_name`) FROM reports" self.assertRaises(DatabaseError, base.count, sql)
def test_count(self): base = PostgreSQLBase(config=self.config) # A working count sql = 'SELECT count(*) FROM release_channels' count = base.count(sql) assert count == 5 # A working count with parameters sql = 'SELECT count(*) FROM release_channels WHERE release_channel=%(release_channel)s' params = {'release_channel': 'Nightly'} count = base.count(sql, params) assert count == 1 # A failing count sql = 'SELECT count(`invalid_field_name`) FROM release_channels' with pytest.raises(DatabaseError): base.count(sql)