def test_create_group(self): """Creates a group in Cassandra.""" expected = {'groupId': 'group-abc', 'tenantId': '101010', 'notification': 'notification-ghi', 'notificationPlan': 'notificationPlan-jkl'} def execute(query, data, consistency): if 'INSERT' in query: return defer.succeed(None) elif 'SELECT' in query: return defer.succeed([expected]) self.client.execute.side_effect = execute d = cass.create_group(self.client, expected['tenantId'], expected['groupId'], expected['notification'], expected['notificationPlan']) result = self.successResultOf(d) self.assertEqual(result, expected) self.assertEqual( self.client.execute.mock_calls, [mock.call( ' '.join([ 'INSERT INTO groups ("tenantId", "groupId", "notification", "notificationPlan")', 'VALUES (:tenantId, :groupId, :notification, :notificationPlan);']), {'notificationPlan': 'notificationPlan-jkl', 'notification': 'notification-ghi', 'groupId': 'group-abc', 'tenantId': '101010'}, 1), mock.call( 'SELECT * FROM groups WHERE "tenantId"=:tenantId AND "groupId"=:groupId;', {'tenantId': '101010', 'groupId': 'group-abc'}, 1)])
def test_create_group(self): """Creates a group in Cassandra.""" expected = { 'groupId': 'group-abc', 'tenantId': '101010', 'notification': 'notification-ghi', 'notificationPlan': 'notificationPlan-jkl' } def execute(query, data, consistency): if 'INSERT' in query: return defer.succeed(None) elif 'SELECT' in query: return defer.succeed([expected]) self.client.execute.side_effect = execute d = cass.create_group(self.client, expected['tenantId'], expected['groupId'], expected['notification'], expected['notificationPlan']) result = self.successResultOf(d) self.assertEqual(result, expected) self.assertEqual(self.client.execute.mock_calls, [ mock.call( ' '.join([ 'INSERT INTO groups ("tenantId", "groupId", "notification", "notificationPlan")', 'VALUES (:tenantId, :groupId, :notification, :notificationPlan);' ]), { 'notificationPlan': 'notificationPlan-jkl', 'notification': 'notification-ghi', 'groupId': 'group-abc', 'tenantId': '101010' }, 1), mock.call( 'SELECT * FROM groups WHERE "tenantId"=:tenantId AND "groupId"=:groupId;', { 'tenantId': '101010', 'groupId': 'group-abc' }, 1) ])
def create_group_in_db((notification, notification_plan)): return cass.create_group(self._db, tenant_id, group_id, notification, notification_plan)
def create_group_in_db((notification, notification_plan)): return cass.create_group( self._db, tenant_id, group_id, notification, notification_plan)