-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from xzebra/fix-practical
Fix practical
- Loading branch information
Showing
10 changed files
with
210 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package semester | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/xzebra/unizar-calendar/pkg/schedules" | ||
) | ||
|
||
func TestNewData(t *testing.T) { | ||
f, err := os.Open("./testdata/semester.json") | ||
assert.Nil(t, err) | ||
defer f.Close() | ||
|
||
semData, err := ioutil.ReadAll(f) | ||
assert.Nil(t, err) | ||
|
||
sem, err := NewSemesterFromData(semData) | ||
assert.Nil(t, err) | ||
|
||
parsed, err := schedules.ParseSemesterFiles(&schedules.SemesterFiles{ | ||
Subjects: "./testdata/asignaturas.csv", | ||
Schedule: "./testdata/mixed.csv", | ||
}) | ||
assert.Nil(t, err) | ||
|
||
data, err := NewData(sem, parsed, 1) | ||
assert.Nil(t, err) | ||
|
||
// Check: Merged map[string][]timeRange | ||
assert.Equal(t, | ||
map[string][]timeRange{ | ||
"ssdd": { | ||
{ // Lx | ||
Start: time.Date(2021, 1, 11, 17, 0, 0, 0, time.UTC), | ||
End: time.Date(2021, 1, 11, 17, 50, 0, 0, time.UTC), | ||
}, | ||
{ // Lb | ||
Start: time.Date(2020, 12, 21, 17, 0, 0, 0, time.UTC), | ||
End: time.Date(2020, 12, 21, 17, 50, 0, 0, time.UTC), | ||
}, | ||
}, | ||
"ing_soft": { | ||
{ // Lb | ||
Start: time.Date(2020, 12, 21, 18, 10, 0, 0, time.UTC), | ||
End: time.Date(2020, 12, 21, 19, 00, 0, 0, time.UTC), | ||
}, | ||
}, | ||
"ph": { | ||
{ // Lb | ||
Start: time.Date(2020, 12, 21, 10, 0, 0, 0, time.UTC), | ||
End: time.Date(2020, 12, 21, 14, 0, 0, 0, time.UTC), | ||
}, | ||
}, | ||
"ia": { | ||
{ // Mb | ||
Start: time.Date(2020, 12, 22, 17, 0, 0, 0, time.UTC), | ||
End: time.Date(2020, 12, 22, 20, 0, 0, 0, time.UTC), | ||
}, | ||
}, | ||
}, | ||
data.Merged, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package semester_test | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path" | ||
"runtime" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/xzebra/unizar-calendar/internal/semester" | ||
"github.com/xzebra/unizar-calendar/pkg/gcal" | ||
) | ||
|
||
// func NewSemesterFromData(data []byte) (semester *Semester, err error) | ||
func TestNewSemesterFromData(t *testing.T) { | ||
f, err := os.Open("./testdata/semester.json") | ||
assert.Nil(t, err) | ||
defer f.Close() | ||
|
||
data, err := ioutil.ReadAll(f) | ||
assert.Nil(t, err) | ||
|
||
sem, err := semester.NewSemesterFromData(data) | ||
assert.Nil(t, err) | ||
|
||
assert.Equal(t, time.Date(2020, 9, 14, 0, 0, 0, 0, time.UTC), sem.Begin) | ||
assert.Equal(t, time.Date(2021, 1, 13, 0, 0, 0, 0, time.UTC), sem.End) | ||
|
||
assert.Equal(t, gcal.EventDays{ | ||
time.Date(2021, 1, 11, 0, 0, 0, 0, time.UTC): "Lx", | ||
time.Date(2021, 1, 8, 0, 0, 0, 0, time.UTC): "Vx", | ||
time.Date(2020, 12, 22, 0, 0, 0, 0, time.UTC): "Mb", | ||
time.Date(2020, 12, 21, 0, 0, 0, 0, time.UTC): "Lb", | ||
}, sem.Days) | ||
} | ||
|
||
// ---------------------------------------------------------- | ||
// Test initialization | ||
// ---------------------------------------------------------- | ||
|
||
func TestMain(t *testing.M) { | ||
// Run everything from project root folder | ||
_, filename, _, _ := runtime.Caller(0) | ||
dir := path.Join(path.Dir(filename), "..", "..") | ||
err := os.Chdir(dir) | ||
if err != nil { | ||
fmt.Println("error returning to root folder: ", err) | ||
os.Exit(1) | ||
} | ||
|
||
os.Exit(t.Run()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,18 @@ | ||
weekday;class_id;start_hour;end_hour;desc | ||
weekday;class_id;start_hour;end_hour;desc;is_practical | ||
# IA | ||
Lx;ia;15:00;15:50;" | ||
https://meet.google.com/iig-sbwa-kdn?pli=1&authuser=1 | ||
https://meet.google.com/xzt-imof-jsw?pli=1&authuser=1" | ||
Lx;ia;16:00;16:50;" | ||
https://meet.google.com/iig-sbwa-kdn?pli=1&authuser=1 | ||
https://meet.google.com/xzt-imof-jsw?pli=1&authuser=1" | ||
Xx;ia;17:00;17:50;" | ||
https://meet.google.com/iig-sbwa-kdn?pli=1&authuser=1 | ||
https://meet.google.com/xzt-imof-jsw?pli=1&authuser=1" | ||
Lx;ia;15:00;15:50;false | ||
Lx;ia;16:00;16:50;false | ||
Xx;ia;17:00;17:50;false | ||
|
||
#Sist Inf | ||
Mx;sist_inf;15:00;15:50;" | ||
https://meet.google.com/tqk-zssa-pmp?pli=1&authuser=1" | ||
Mx;sist_inf;16:00;16:50;" | ||
https://meet.google.com/tqk-zssa-pmp?pli=1&authuser=1" | ||
Xx;sist_inf;18:00;18:50;" | ||
https://meet.google.com/tqk-zssa-pmp?pli=1&authuser=1" | ||
Mx;sist_inf;15:00;15:50;false | ||
Mx;sist_inf;16:00;16:50;false | ||
Xx;sist_inf;18:00;18:50;false | ||
|
||
#SSDD | ||
Jx;sist_inf;15:00;15:50;" | ||
- Google Meet (Rafa) https://meet.google.com/tqk-zssa-pmp?pli=1&authuser=1 | ||
- Microsoft Teams (Rafa): https://teams.microsoft.com/dl/launcher/launcher.html?url=%2F_%23%2Fl%2Fmeetup-join%2F19%3A3ec116dc5a8941eda39f8e8c4d831ae1%40thread.tacv2%2F1601481330986%3Fcontext%3D%257B%2522Tid%2522%253A%25223f227dba-f3f4-4544-b314-c6efd30e0d00%2522%252C%2522Oid%2522%253A%25226f6be409-9319-4b90-a817-7e05df5b1ce9%2522%257D%26anon%3Dtrue&type=meetup-join&deeplinkId=4803e452-eae3-424c-b262-40878a17fa57&directDl=true&msLaunch=true&enableMobilePage=true&suppressPrompt=true | ||
- Google Meet (Unai): https://meet.google.com/ijq-umtk-ewp?pli=1&authuser=1" | ||
Jx;sist_inf;16:00;16:50;" | ||
- Google Meet (Rafa) https://meet.google.com/tqk-zssa-pmp?pli=1&authuser=1 | ||
- Microsoft Teams (Rafa): https://teams.microsoft.com/dl/launcher/launcher.html?url=%2F_%23%2Fl%2Fmeetup-join%2F19%3A3ec116dc5a8941eda39f8e8c4d831ae1%40thread.tacv2%2F1601481330986%3Fcontext%3D%257B%2522Tid%2522%253A%25223f227dba-f3f4-4544-b314-c6efd30e0d00%2522%252C%2522Oid%2522%253A%25226f6be409-9319-4b90-a817-7e05df5b1ce9%2522%257D%26anon%3Dtrue&type=meetup-join&deeplinkId=4803e452-eae3-424c-b262-40878a17fa57&directDl=true&msLaunch=true&enableMobilePage=true&suppressPrompt=true | ||
- Google Meet (Unai): https://meet.google.com/ijq-umtk-ewp?pli=1&authuser=1" | ||
Jx;sist_inf;15:00;15:50;false | ||
Jx;sist_inf;16:00;16:50;false | ||
|
||
#Ing Soft | ||
Xx;ing_soft;15:00;15:50;" | ||
https://meet.google.com/hdj-whng-oqw?pli=1&authuser=1" | ||
Xx;ing_soft;16:00;16:50;" | ||
https://meet.google.com/hdj-whng-oqw?pli=1&authuser=1" | ||
Xx;ing_soft;15:00;15:50;false | ||
Xx;ing_soft;16:00;16:50;false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
weekday;class_id;start_hour;end_hour;is_practical | ||
#SSDD class | ||
Lx;ssdd;17:00;17:50;false | ||
#Ing Soft class | ||
Lb;ing_soft;18:10;19:00;false | ||
#PH practical class | ||
Lx;ph;10:00;14:00;true | ||
#IA practical class | ||
Mb;ia;17:00;20:00;true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,3 @@ | ||
weekday;class_id;start_hour;end_hour;desc | ||
Xx;ph;10:00;14:00;" | ||
- Compa�eros: Carlos | ||
- Google Meet: https://meet.google.com/iac-dfzy-kwb?pli=1&authuser=1 | ||
- Google Meet privado: https://meet.google.com/xfi-bemu-raa?pli=1&authuser=1" | ||
Ja;ia;17:00;20:00;" | ||
- Google Meet: https://meet.google.com/iig-sbwa-kdn?pli=1&authuser=1" | ||
Jb;ing_soft;17:00;19:00;" | ||
- Compa�eros: Carlos | ||
- Google Meet: https://meet.google.com/fsi-kspo-ifv?pli=1&authuser=1 | ||
- Google Meet privado: https://meet.google.com/rpi-fgre-wce?pli=1&authuser=1" | ||
Va;ssdd;10:00;12:00;" | ||
- Compa�eros: Mario | ||
- Google Meet: https://meet.google.com/ijq-umtk-ewp?pli=1&authuser=1" | ||
Vx;sist_info;12:00;14:00;" | ||
- Compa�eros: Carlos, Mario | ||
- Google Meet: https://meet.google.com/ooo-gnvy-zyw?pli=1&authuser=1 | ||
- Google Meet privado: https://meet.google.com/pxd-yhzu-zrk?pli=1&authuser=1" | ||
weekday;class_id;start_hour;end_hour;is_practical | ||
Xx;ph;10:00;14:00;true | ||
Ja;ia;17:00;20:00;true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
weekday;class_id;start_hour;end_hour | ||
weekday;class_id;start_hour;end_hour;is_practical | ||
#SSDD | ||
Lx;ssdd;17:00;17:50 | ||
Lx;ssdd;17:00;17:50;false | ||
|
||
#Ing Soft | ||
Lb;ing_soft;18:10;19:00 | ||
Lb;ing_soft;18:10;19:00;false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"Days": { | ||
"2021-01-11T00:00:00Z": "Lx", | ||
"2021-01-08T00:00:00Z": "Vx", | ||
"2020-12-22T00:00:00Z": "Mb", | ||
"2020-12-21T00:00:00Z": "Lb" | ||
}, | ||
"End": "2021-01-13T00:00:00Z", | ||
"Begin": "2020-09-14T00:00:00Z", | ||
"Number": 1 | ||
} |