<commit_before>package models

import (
	kodingmodels "koding/db/models"
	"koding/db/mongodb/modelhelper"
	"math/rand"
	"strconv"
	"time"

	. "github.com/smartystreets/goconvey/convey"
	"labix.org/v2/mgo/bson"
)

func CreateChannelWithParticipants() (*Channel, []*Account) {
	account1 := CreateAccountWithTest()
	account2 := CreateAccountWithTest()
	account3 := CreateAccountWithTest()
	accounts := []*Account{account1, account2, account3}

	channel := CreateChannelWithTest(account1.Id)
	AddParticipants(channel.Id, account1.Id, account2.Id, account3.Id)

	return channel, accounts
}

func CreateChannelWithTest(accountId int64) *Channel {
	// create and account instance
	channel := NewChannel()
	channel.CreatorId = accountId

	err := channel.Create()
	So(err, ShouldBeNil)

	return channel
}

// CreateTypedChannelWithTest creates a channel specific to a group with the
// given type constant
func CreateTypedChannelWithTest(accountId int64, typeConstant string) *Channel {
	// create and account instance
	channel := NewChannel()
	channel.Name = RandomName()
	// there is a check for group channels for unsuring that there will be only
	// one group channel at a time, override that
	channel.GroupName = RandomName()
	channel.TypeConstant = typeConstant
	channel.CreatorId = accountId

	err := channel.Create()
	So(err, ShouldBeNil)

	return channel
}

func CreateMessage(channelId, accountId int64, typeConstant string) *ChannelMessage {
	return CreateMessageWithBody(channelId, accountId, typeConstant, "testing message")
}

func CreateMessageWithBody(channelId, accountId int64, typeConstant, body string) *ChannelMessage {
	cm := NewChannelMessage()

	cm.AccountId = accountId
	// set channel id
	cm.InitialChannelId = channelId
	cm.TypeConstant = typeConstant
	// set body
	cm.Body = body

	err := cm.Create()<commit_msg>Socialapi: created a new function for generating test data<commit_after>package models

import (
	kodingmodels "koding/db/models"
	"koding/db/mongodb/modelhelper"
	"math/rand"
	"strconv"
	"time"

	. "github.com/smartystreets/goconvey/convey"
	"labix.org/v2/mgo/bson"
)

func CreateChannelWithParticipants() (*Channel, []*Account) {
	account1 := CreateAccountWithTest()
	account2 := CreateAccountWithTest()
	account3 := CreateAccountWithTest()
	accounts := []*Account{account1, account2, account3}

	channel := CreateChannelWithTest(account1.Id)
	AddParticipants(channel.Id, account1.Id, account2.Id, account3.Id)

	return channel, accounts
}

func CreateChannelWithTest(accountId int64) *Channel {
	// create and account instance
	channel := NewChannel()
	channel.CreatorId = accountId

	err := channel.Create()
	So(err, ShouldBeNil)

	return channel
}

// CreateTypedChannelWithTest creates a channel specific to a group with the
// given type constant
func CreateTypedChannelWithTest(accountId int64, typeConstant string) *Channel {
	// create and account instance
	channel := NewChannel()
	channel.Name = RandomName()
	// there is a check for group channels for unsuring that there will be only
	// one group channel at a time, override that
	channel.GroupName = RandomName()
	channel.TypeConstant = typeConstant
	channel.CreatorId = accountId

	err := channel.Create()
	So(err, ShouldBeNil)

	return channel
}

func CreateTypedPublicChannelWithTest(accountId int64, typeConstant string) *Channel {
	// create and account instance
	channel := NewChannel()
	channel.Name = RandomName()
	// there is a check for group channels for unsuring that there will be only
	// one group channel at a time, override that
	channel.GroupName = RandomName()
	channel.TypeConstant = typeConstant
	channel.CreatorId = accountId
	channel.PrivacyConstant = Channel_PRIVACY_PUBLIC

	err := channel.Create()
	So(err, ShouldBeNil)

	return channel
}

func CreateMessage(channelId, accountId int64, typeConstant string) *ChannelMessage {
	return CreateMessageWithBody(channelId, accountId, typeConstant, "testing message")
}

func CreateMessageWithBody(channelId, accountId int64, typeConstant, body string) *ChannelMessage {
	cm := NewChannelMessage()

	cm.AccountId = accountId
	// set channel id
	cm.InitialChannelId = channelId
	cm.TypeConstant = typeConstant
	// set body
	cm.Body = body

	err := cm.Create()
{'fraction_non_alphanumeric': 0.09706439393939394, 'fraction_numerical': 0.00946969696969697, 'mean_word_length': 5.176900584795321, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7376305', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1263, 'n_words': 359}