From c6ba45c0be82c0b229f19567bf285ac6f4e563a8 Mon Sep 17 00:00:00 2001 From: Hanna Turunen Date: Fri, 13 Dec 2024 12:43:57 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Lis=C3=A4=C3=A4=20testej=C3=A4=20generate?= =?UTF-8?q?=20cite=20key=20funktiolle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tests/generate_citekey_test.py | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/tests/generate_citekey_test.py b/src/tests/generate_citekey_test.py index 94fbab9..76a8a94 100644 --- a/src/tests/generate_citekey_test.py +++ b/src/tests/generate_citekey_test.py @@ -22,3 +22,53 @@ def unique(key): key = generate_cite_key(self.fields) expected = "JouTo20" self.assertEqual(expected, key) + + @patch("util.unique_key") + @patch("secrets.token_hex") + def test_generate_cite_key_with_few_fields(self, mock_token_hex, mock_unique_key): + def unique(key): + return key not in ["Jou10", "Jou88"] + + mock_unique_key.side_effect = unique + mock_token_hex.return_value = "abcd" + fields = {"author": "Jo", "year": "2020"} + cite_key = generate_cite_key(fields) + expected = "Jo20abcd" + self.assertEqual(expected, cite_key) + + @patch("util.unique_key") + @patch("secrets.token_hex") + def test_generate_cite_key_with_short_fields(self, mock_token_hex, mock_unique_key): + def unique(key): + return key not in ["Jou10", "Jou88"] + + mock_unique_key.side_effect = unique + mock_token_hex.return_value = "abcd" + fields = {"author": "J", "edition": "5"} + cite_key = generate_cite_key(fields) + self.assertEqual(cite_key, "J5abcd") + + @patch("util.unique_key") + @patch("secrets.token_hex") + def test_generate_cite_key_with_empty_fields(self, mock_token_hex, mock_unique_key): + def unique(key): + return key not in ["Jou10", "Jou88"] + + mock_unique_key.side_effect = unique + mock_token_hex.return_value = "abcd" + fields = {} + cite_key = generate_cite_key(fields) + self.assertEqual(cite_key, "abcd") + + @patch("util.unique_key") + @patch("secrets.token_hex") + def test_generate_cite_key_not_unique_after_generating( + self, mock_token_hex, mock_unique_key + ): + def unique(key): + return key not in ["JouTo20", "Jou88"] + + mock_unique_key.side_effect = unique + mock_token_hex.return_value = "abcd" + cite_key = generate_cite_key(self.fields) + self.assertEqual(cite_key, "JouTo20abcd") From 6b869c814791bff2f0bd8a20d2e2ac6670de78d0 Mon Sep 17 00:00:00 2001 From: Hanna Turunen Date: Fri, 13 Dec 2024 12:51:24 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Robottestin=20korjaus:=20lis=C3=A4tty=20sle?= =?UTF-8?q?ep=200.25,=20syy:=20elementti=20ei=20ollut=20viel=C3=A4=20auenn?= =?UTF-8?q?ut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/story_tests/create_bibtex.robot | 1 + 1 file changed, 1 insertion(+) diff --git a/src/story_tests/create_bibtex.robot b/src/story_tests/create_bibtex.robot index 43d42f5..3b17ca1 100644 --- a/src/story_tests/create_bibtex.robot +++ b/src/story_tests/create_bibtex.robot @@ -9,6 +9,7 @@ When Get BibTeX Is Clicked The Generated BibTeX Is Shown Create Test Citation Author1 Title1 2024 Journal1 Go To Home Page Click Get Bibtex + Sleep 0.25 Wait Until Element Is Visible copy_bibtex_button Page Should Contain author = \{Author1\},\n\ttitle = \{Title1\},\n\tyear = \{2024\},\n\tjournal = \{Journal1\} From 2118f0cfdfed0c8339041b91f2570f979f6bc8d3 Mon Sep 17 00:00:00 2001 From: Hanna Turunen Date: Fri, 13 Dec 2024 12:56:34 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Robottestin=20korjaus:=20lis=C3=A4tty=20sle?= =?UTF-8?q?ep=200.5,=20syy:=20elementti=20ei=20ollut=20n=C3=A4kyviss=C3=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/story_tests/edit_citation.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/story_tests/edit_citation.robot b/src/story_tests/edit_citation.robot index abe8837..3e913df 100644 --- a/src/story_tests/edit_citation.robot +++ b/src/story_tests/edit_citation.robot @@ -52,7 +52,7 @@ After removing an optional field and closing the edit without updating, the fiel Click Element //button[@name='exit-edit'] Reload Page Click Citation Row 1 - Sleep 0.25 + Sleep 0.5 Page Should Contain volume Page Should Contain 5050