This repository has been archived by the owner on Oct 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #110 from MITLibraries/109_test_coverage
109 test coverage
- Loading branch information
Showing
11 changed files
with
930 additions
and
14 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,7 @@ | ||
SCOAP3 TopicHub | ||
================================= | ||
|
||
This is a web application to allow users to discover, subscribe to, | ||
and obtain automatic delivery of, aggregations of article content from the SCOAP3 repository. | ||
|
||
[![Build Status](https://travis-ci.org/MITLibraries/scoap3hub.svg?branch=107_sub_status_in_search_results)](https://travis-ci.org/MITLibraries/scoap3hub) [![Coverage Status](https://coveralls.io/repos/MITLibraries/scoap3hub/badge.svg?branch=item_model_tests)](https://coveralls.io/r/MITLibraries/scoap3hub?branch=item_model_tests) |
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 |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import org.specs2.mutable._ | ||
|
||
import play.api.test._ | ||
import play.api.test.Helpers._ | ||
import models.Item | ||
import models.Collection | ||
import models.Publisher | ||
import models.User | ||
import models.ContentType | ||
import models.ResourceMap | ||
import models.Scheme | ||
import models.Topic | ||
import java.util.Date | ||
|
||
class CollectionSpec extends Specification { | ||
|
||
"Collection model" should { | ||
|
||
"#create" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
User.create("bob", "bob@example.com", "pass", "roley") | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ResourceMap.create("tag", "desc", Some("swordurl")) | ||
Publisher.create(1, "pubtag", "pubname", "pubdesc", "pubcat", "pubstatus", Some(""), Some("")) | ||
|
||
Collection.findAll must haveSize(0) | ||
Collection.create(1, 1, 1, "coll", "desc", "open") | ||
Collection.findAll must haveSize(1) | ||
} | ||
} | ||
|
||
"#make" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
User.create("bob", "bob@example.com", "pass", "roley") | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ResourceMap.create("tag", "desc", Some("swordurl")) | ||
Publisher.create(1, "pubtag", "pubname", "pubdesc", "pubcat", "pubstatus", Some(""), Some("")) | ||
|
||
Collection.findAll must haveSize(0) | ||
var c = Collection.make(1, 1, 1, "coll", "desc", "open") | ||
Collection.findAll must haveSize(1) | ||
c must equalTo(Collection.findById(1).get) | ||
} | ||
} | ||
|
||
"#findByPublisher" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
User.create("bob", "bob@example.com", "pass", "roley") | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ResourceMap.create("tag", "desc", Some("swordurl")) | ||
Publisher.create(1, "pubtag", "pubname", "pubdesc", "pubcat", "pubstatus", Some(""), Some("")) | ||
Publisher.create(1, "pubtag2", "pubname2", "pubdesc2", "pubcat2", "pubstatus2", Some(""), Some("")) | ||
|
||
var c1 = Collection.make(1, 1, 1, "coll1", "desc", "open") | ||
var c2 = Collection.make(1, 1, 1, "coll2", "desc", "open") | ||
var c3 = Collection.make(2, 1, 1, "coll3", "desc", "open") | ||
|
||
var cols = Collection.findByPublisher(1) | ||
cols.contains(c1) must equalTo(true) | ||
cols.contains(c2) must equalTo(true) | ||
cols.contains(c3) must equalTo(false) | ||
} | ||
} | ||
|
||
"#findByTag" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
User.create("bob", "bob@example.com", "pass", "roley") | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ResourceMap.create("tag", "desc", Some("swordurl")) | ||
Publisher.create(1, "pubtag", "pubname", "pubdesc", "pubcat", "pubstatus", Some(""), Some("")) | ||
Publisher.create(1, "pubtag2", "pubname2", "pubdesc2", "pubcat2", "pubstatus2", Some(""), Some("")) | ||
|
||
var c1 = Collection.make(1, 1, 1, "coll1", "desc", "open") | ||
var c2 = Collection.make(1, 1, 1, "coll2", "desc", "open") | ||
var c3 = Collection.make(2, 1, 1, "coll3", "desc", "open") | ||
|
||
var cols = Collection.findByTag("coll1") | ||
cols.contains(c1) must equalTo(true) | ||
cols.contains(c2) must equalTo(false) | ||
cols.contains(c3) must equalTo(false) | ||
} | ||
} | ||
|
||
"#findById" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
User.create("bob", "bob@example.com", "pass", "roley") | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ResourceMap.create("tag", "desc", Some("swordurl")) | ||
Publisher.create(1, "pubtag", "pubname", "pubdesc", "pubcat", "pubstatus", Some(""), Some("")) | ||
Publisher.create(1, "pubtag2", "pubname2", "pubdesc2", "pubcat2", "pubstatus2", Some(""), Some("")) | ||
|
||
var c1 = Collection.make(1, 1, 1, "coll1", "desc", "open") | ||
var c2 = Collection.make(1, 1, 1, "coll2", "desc", "open") | ||
var c3 = Collection.make(2, 1, 1, "coll3", "desc", "open") | ||
|
||
var cols = Collection.findById(1) | ||
cols.contains(c1) must equalTo(true) | ||
cols.contains(c2) must equalTo(false) | ||
cols.contains(c3) must equalTo(false) | ||
} | ||
} | ||
|
||
"#findAll" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
User.create("bob", "bob@example.com", "pass", "roley") | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ResourceMap.create("tag", "desc", Some("swordurl")) | ||
Publisher.create(1, "pubtag", "pubname", "pubdesc", "pubcat", "pubstatus", Some(""), Some("")) | ||
Publisher.create(1, "pubtag2", "pubname2", "pubdesc2", "pubcat2", "pubstatus2", Some(""), Some("")) | ||
|
||
var c1 = Collection.make(1, 1, 1, "coll1", "desc", "open") | ||
var c2 = Collection.make(1, 1, 1, "coll2", "desc", "open") | ||
var c3 = Collection.make(2, 1, 1, "coll3", "desc", "open") | ||
|
||
var cols = Collection.findAll | ||
cols must haveSize(3) | ||
cols.contains(c1) must equalTo(true) | ||
cols.contains(c2) must equalTo(true) | ||
cols.contains(c3) must equalTo(true) | ||
} | ||
} | ||
|
||
"#recordDeposit" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
User.create("bob", "bob@example.com", "pass", "roley") | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ResourceMap.create("tag", "desc", Some("swordurl")) | ||
Publisher.create(1, "pubtag", "pubname", "pubdesc", "pubcat", "pubstatus", Some(""), Some("")) | ||
Publisher.create(1, "pubtag2", "pubname2", "pubdesc2", "pubcat2", "pubstatus2", Some(""), Some("")) | ||
|
||
var c1 = Collection.make(1, 1, 1, "coll1", "desc", "open") | ||
|
||
c1.deposits must equalTo(0) | ||
c1.recordDeposit | ||
// necessary to reload to check updated value | ||
Collection.findById(c1.id).get.deposits must equalTo(1) | ||
} | ||
} | ||
|
||
} | ||
} |
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,64 @@ | ||
import org.specs2.mutable._ | ||
|
||
import play.api.test._ | ||
import play.api.test.Helpers._ | ||
import models.ContentFormat | ||
import java.util.Date | ||
|
||
class ContentFormatSpec extends Specification { | ||
|
||
"ContentFormat model" should { | ||
|
||
"#create" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
ContentFormat.all must haveSize(0) | ||
ContentFormat.create("tag", "label", "desc", "http://www.example.com", "mimetype", Some("logo")) | ||
ContentFormat.all must haveSize(1) | ||
} | ||
} | ||
|
||
"#all" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
ContentFormat.all must haveSize(0) | ||
ContentFormat.create("tag", "label", "desc", "http://www.example.com", "mimetype", Some("logo")) | ||
ContentFormat.create("tag2", "label", "desc", "http://www.example.com", "mimetype", Some("logo")) | ||
val cf = ContentFormat.all | ||
cf must haveSize(2) | ||
cf.contains(ContentFormat.findById(1).get) must equalTo(true) | ||
cf.contains(ContentFormat.findById(2).get) must equalTo(true) | ||
} | ||
} | ||
|
||
"#findById" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
ContentFormat.all must haveSize(0) | ||
ContentFormat.create("tag", "label", "desc", "http://www.example.com", "mimetype", Some("logo")) | ||
ContentFormat.create("tag2", "label", "desc", "http://www.example.com", "mimetype", Some("logo")) | ||
ContentFormat.all must haveSize(2) | ||
ContentFormat.findById(1).get.tag must equalTo("tag") | ||
} | ||
} | ||
|
||
"#findByTag" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
ContentFormat.all must haveSize(0) | ||
ContentFormat.create("tag", "label", "desc", "http://www.example.com", "mimetype", Some("logo")) | ||
ContentFormat.create("tag2", "label", "desc", "http://www.example.com", "mimetype", Some("logo")) | ||
ContentFormat.all must haveSize(2) | ||
ContentFormat.findByTag("tag").get.id must equalTo(1) | ||
} | ||
} | ||
|
||
"#mapView" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
ContentFormat.all must haveSize(0) | ||
ContentFormat.create("tag", "label", "desc", "http://www.example.com", "mimetype", Some("logo")) | ||
ContentFormat.create("tag2", "label", "desc", "http://www.example.com", "mimetype", Some("logo")) | ||
ContentFormat.all must haveSize(2) | ||
val map = ContentFormat.mapView | ||
map must havePair("1" -> "tag") | ||
map must havePair("2" -> "tag2") | ||
} | ||
} | ||
} | ||
} |
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,87 @@ | ||
import org.specs2.mutable._ | ||
import org.specs2.matcher._ | ||
import org.specs2.matcher.MatchResult | ||
|
||
import play.api.test._ | ||
import play.api.test.Helpers._ | ||
import models.ContentType | ||
import models.Scheme | ||
import java.util.Date | ||
|
||
class ContentTypeSpec extends Specification { | ||
|
||
"ContentType model" should { | ||
|
||
"#create" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
ContentType.all must haveSize(0) | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ContentType.all must haveSize(1) | ||
} | ||
} | ||
|
||
"#all" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ContentType.create("tag2", "label", "desc", Some("logo")) | ||
ContentType.create("tag3", "label", "desc", Some("logo")) | ||
val all = ContentType.all | ||
all must haveSize(3) | ||
all.contains(ContentType.findByTag("tag").get) must equalTo(true) | ||
all.contains(ContentType.findByTag("tag2").get) must equalTo(true) | ||
all.contains(ContentType.findByTag("tag3").get) must equalTo(true) | ||
} | ||
} | ||
|
||
"#findById" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ContentType.create("tag2", "label", "desc", Some("logo")) | ||
ContentType.create("tag3", "label", "desc", Some("logo")) | ||
ContentType.all must haveSize(3) | ||
|
||
ContentType.findById(1) must equalTo(ContentType.findByTag("tag")) | ||
ContentType.findById(1) must not equalTo(ContentType.findByTag("tag2")) | ||
} | ||
} | ||
|
||
"#findByTag" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ContentType.create("tag2", "label", "desc", Some("logo")) | ||
ContentType.create("tag3", "label", "desc", Some("logo")) | ||
ContentType.all must haveSize(3) | ||
|
||
ContentType.findByTag("tag") must equalTo(ContentType.findById(1)) | ||
ContentType.findByTag("tag") must not equalTo(ContentType.findById(2)) | ||
} | ||
} | ||
|
||
"#mapView" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
ContentType.create("tag2", "label", "desc", Some("logo")) | ||
ContentType.create("tag3", "label", "desc", Some("logo")) | ||
ContentType.all must haveSize(3) | ||
|
||
val map = ContentType.mapView | ||
map must havePair("1" -> "tag") | ||
map must havePair("2" -> "tag2") | ||
map must havePair("3" -> "tag3") | ||
} | ||
} | ||
|
||
"#schemes" in { | ||
running(FakeApplication(additionalConfiguration = inMemoryDatabase())) { | ||
Scheme.create("tag", "gentype", "cat", "desc", Some("link"), Some("logo")) | ||
ContentType.create("tag", "label", "desc", Some("logo")) | ||
val ct = ContentType.findById(1) | ||
ct.get.schemes("relation") must haveSize(0) | ||
ct.get.addScheme(Scheme.findById(1).get, "relation") | ||
ct.get.schemes("relation") must haveSize(1) | ||
ct.get.removeScheme(Scheme.findById(1).get, "relation") | ||
ct.get.schemes("relation") must haveSize(0) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.