Skip to content

Commit

Permalink
[Model Change] Corpus can have the same name across users (but also f…
Browse files Browse the repository at this point in the history
…or one user)

Fixeds #190
---------

Co-authored-by: Thibault Clérice <[email protected]>
  • Loading branch information
Juliettejns and PonteIneptique authored Mar 15, 2024
1 parent 71ee6e6 commit b60dda1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Corpus(db.Model):
:type name: str
"""
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(256), unique=True)
name = db.Column(db.String(256))
context_left = db.Column(db.SmallInteger, default=3)
context_right = db.Column(db.SmallInteger, default=3)
control_lists_id = db.Column(db.Integer, db.ForeignKey('control_lists.id'), nullable=False)
Expand Down
26 changes: 23 additions & 3 deletions tests/test_selenium/test_corpus_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ def test_registration_with_false_control_list(self):
"It is impossible to validate form with a wrong id of control list"
)

def test_registration_with_an_existing_name(self):
""" [Corpus Creation] Check that a corpus using this name does not already exist"""
"""def test_registration_with_an_existing_name(self):
" [Corpus Creation] Check that a corpus using this name does not already exist"
self.add_control_lists()
self.addCorpus('wauchier', cl=False)
# Click register menu link
Expand All @@ -438,7 +438,7 @@ def test_registration_with_an_existing_name(self):
sorted(['The corpus cannot be registered. Check your data',
"You have already a corpus going by the name Wauchier"]),
"Creating a corpus when one already exists for the current user with the same name fails."
)
)"""

def test_registration_with_wrongly_formated_input(self):
""" [Corpus Creation] Check that TSV formatting does not break everything"""
Expand Down Expand Up @@ -602,3 +602,23 @@ def test_registration_without_field_length_violation(self):
self.driver_find_element_by_id("submit").click()
self.driver.implicitly_wait(15)
self.assertFalse(self.driver_find_elements_by_css_selector(".alert.alert-danger"))

def test_corpus_name_unique_user(self):
""" Test that a single user can have twice the same name (even if weird)"""
self.add_control_lists()
self.add_user("foo", "foo")
self.login("%s.%[email protected]" % ("foo", "foo"), self.app.config['ADMIN_PASSWORD'])
self.addCorpus("wauchier", cl=False)
self.add_user("bar", "bar")
self.login("%s.%[email protected]" % ("bar", "bar"), self.app.config['ADMIN_PASSWORD'])
self.driver_find_element_by_id("new_corpus_link").click()
self.driver_find_element_by_id("corpusName").send_keys("Wauchier")
self.driver_find_element_by_id("label_checkbox_reuse").click()
self.driver_find_element_by_id("control_list_select").click()
self.writeMultiline(
self.driver_find_element_by_id("tokens"),
f"form\tlemma\tPOS\tmorph\nSOIGNORS\tseignor\tNOMcom\tNOMB.=p|GENRE=m|CAS=n"
)
self.driver_find_element_by_id("submit").click()
self.driver.implicitly_wait(5)
self.assertFalse(self.driver_find_elements_by_css_selector(".alert.alert-danger"))

0 comments on commit b60dda1

Please sign in to comment.