Skip to content
Snippets Groups Projects
Commit 4db6e81c authored by William Walker's avatar William Walker
Browse files

check roster records where users only have "LTI1" or "SAML" tag

parent ebdb306e
No related tags found
No related merge requests found
package edu.ucsc.its.temerity.test
import io.kotest.core.spec.style.FunSpec
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.DataRow
import org.jetbrains.kotlinx.dataframe.api.drop
import org.jetbrains.kotlinx.dataframe.api.filter
import org.jetbrains.kotlinx.dataframe.api.rows
import org.jetbrains.kotlinx.dataframe.io.readCSV
import org.jetbrains.kotlinx.dataframe.io.writeCSV
class DeduplicateTest : FunSpec({
test("Parse CSV and return rows without LTI3 identifier") {
val df = DataFrame.readCSV("scraped_roster.csv")
df.filter { it[1] != "Test" && it[2] != "Student" }
df.writeCSV("intermediate_roster.csv")
val dispatcher = limitedDispatcher
coroutineScope {
for(thisRow in df.rows()){
launch {
withContext(dispatcher){
checkRow(df, thisRow)
}
}
}
}
df.writeCSV("deduplicated_roster.csv")
}
})
fun checkRow(df: DataFrame<*>, thisRow: DataRow<Any?>){
if(thisRow[6] == "LTI3"){
df.drop { it[0] == thisRow[0] }
df.drop(thisRow.index())
}
}
......@@ -22,6 +22,7 @@ import io.kotest.core.test.TestCase
import io.kotest.core.test.TestResult
import io.kotest.core.test.TestType
import io.kotest.core.test.isRootTest
import kotlinx.coroutines.Dispatchers
import org.koin.core.context.startKoin
import org.koin.core.context.stopKoin
import org.koin.core.module.Module
......@@ -71,3 +72,5 @@ enum class KoinLifecycleMode {
Root,
Test,
}
internal val limitedDispatcher = Dispatchers.IO.limitedParallelism(5)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment