<commit_before>-- Testing that only one preferred language is provided for people/users
\unset ECHO
\i unit_launch.sql
SELECT plan(24);
--select count(*) from people_languages;
SELECT ok(fct_chk_one_pref_language(1,1, true), 'Table people_languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(1,1, false), 'Table people languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(1,1, true, 'users'), 'Table users_languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(1,1, false, 'users'), 'Table users_languages. No preferred language yet -> is ok');

SELECT lives_ok('INSERT INTO people_languages (id, people_ref) VALUES (10,1)', 'People: First data and not a preferred language -> should return ok');
SELECT lives_ok('INSERT INTO users_languages (id, users_ref) VALUES (11,1)', 'Users: First data and not a preferred language -> should return ok');

SELECT ok(fct_chk_one_pref_language(10,1, true), 'Table people_languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(10,1, false), 'Table people languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(11,1, true, 'users'), 'Table users_languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(11,1, false, 'users'), 'Table users_languages. No preferred language yet -> is ok');

SELECT lives_ok('INSERT INTO people_languages (id, people_ref, language_country, preferred_language) VALUES (13,1, ''fr_be'', true)', 'People: First preferred language inserted -> should be ok');
SELECT lives_ok('INSERT INTO users_languages (id, users_ref, language_country, preferred_language) VALUES (14,1, ''fr_be'', true)', 'Users: First preferred language inserted -> should be ok');

SELECT ok(not fct_chk_one_pref_language(1, 1, true), 'Table people_languages. One preferred language yet -> should not be ok');
SELECT ok(fct_chk_one_pref_language(13, 1, false), 'Table people languages. One preferred language yet -> should be ok');
SELECT ok(not fct_chk_one_pref_language(1, 1, true, 'users'), 'Table users_languages. One preferred language yet -> should not be ok');
SELECT ok(fct_chk_one_pref_language(14, 1, false, 'users'), 'Table users_languages. One preferred language yet -> should be ok');

SELECT throws_ok('INSERT INTO people_languages (people_ref, language_country, preferred_language) VALUES (1, ''nl_be'', true)', '23514');
SELECT throws_ok('INSERT INTO users_languages (users_ref, language_country, preferred_language) VALUES (1, ''fr_be'', true)', '23514');

-- SELECT throws_ok('UPDATE people_languages set preferred_language = true where language_country = ''en_gb'' ', '23514');
-- SELECT throws_ok('UPDATE users_languages set preferred_language = true where language_country = ''en_gb'' ', '23514');

SELECT lives_ok('UPDATE people_languages set preferred_language = false', 'People: Set all languages to false -> should be ok');
SELECT lives_ok('UPDATE users_languages set preferred_language = false', 'Users: Set all languages to false -> should be ok');
SELECT lives_ok('UPDATE people_languages set preferred_language = true where people_ref = 1 and language_country = ''en_gb'' ', 'People: Set english to true for user 1 -> should be ok');
SELECT lives_ok('UPDATE users_languages set preferred_language = false where users_ref = 1 and language_country = ''en_gb'' ', 'Users: Set english to true for user 1 -> should be ok');

SELECT lives_ok('INSERT INTO people_languages (people_ref, language_country, preferred_language) VALUES (2, ''fr_be'', true)', 'People: New person inserted with first preferred language inserted -> should be ok');
SELECT lives_ok('INSERT INTO users_languages (users_ref, language_country, preferred_language) VALUES (2, ''fr_be'', true)', 'Users: New user inserted with first preferred language inserted -> should be ok');

-- Finish the tests and clean up.
SELECT * FROM finish();
ROLLBACK;<commit_msg>Modified tests so they follow db structure for languages<commit_after>-- Testing that only one preferred language is provided for people/users
\unset ECHO
\i unit_launch.sql
SELECT plan(26);
--select count(*) from people_languages;
SELECT ok(fct_chk_one_pref_language(1,1, true), 'Table people_languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(1,1, false), 'Table people languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(1,1, true, 'users'), 'Table users_languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(1,1, false, 'users'), 'Table users_languages. No preferred language yet -> is ok');

SELECT lives_ok('INSERT INTO people_languages (id, people_ref) VALUES (10,1)', 'People: First data and not a preferred language -> should return ok');
SELECT lives_ok('INSERT INTO users_languages (id, users_ref) VALUES (11,1)', 'Users: First data and not a preferred language -> should return ok');

SELECT ok(fct_chk_one_pref_language(10,1, true), 'Table people_languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(10,1, false), 'Table people languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(11,1, true, 'users'), 'Table users_languages. No preferred language yet -> is ok');
SELECT ok(fct_chk_one_pref_language(11,1, false, 'users'), 'Table users_languages. No preferred language yet -> is ok');

SELECT lives_ok('INSERT INTO people_languages (id, people_ref, language_country, preferred_language) VALUES (13,1, ''fr'', true)', 'People: First preferred language inserted -> should be ok');
SELECT lives_ok('INSERT INTO users_languages (id, users_ref, language_country, preferred_language) VALUES (14,1, ''fr'', true)', 'Users: First preferred language inserted -> should be ok');

SELECT ok(not fct_chk_one_pref_language(1, 1, true), 'Table people_languages. One preferred language yet -> should not be ok');
SELECT ok(fct_chk_one_pref_language(13, 1, false), 'Table people languages. One preferred language yet -> should be ok');
SELECT ok(not fct_chk_one_pref_language(1, 1, true, 'users'), 'Table users_languages. One preferred language yet -> should not be ok');
SELECT ok(fct_chk_one_pref_language(14, 1, false, 'users'), 'Table users_languages. One preferred language yet -> should be ok');

SELECT throws_ok('INSERT INTO people_languages (people_ref, language_country, preferred_language) VALUES (1, ''nl_BE'', true)', '23514');
SELECT throws_ok('INSERT INTO users_languages (users_ref, language_country, preferred_language) VALUES (1, ''fr'', true)', '23514');

SELECT throws_ok('UPDATE people_languages set preferred_language = true where language_country = ''en'' ', '23514');
SELECT throws_ok('UPDATE users_languages set preferred_language = true where language_country = ''en'' ', '23514');

SELECT lives_ok('UPDATE people_languages set preferred_language = false', 'People: Set all languages to false -> should be ok');
SELECT lives_ok('UPDATE users_languages set preferred_language = false', 'Users: Set all languages to false -> should be ok');
SELECT lives_ok('UPDATE people_languages set preferred_language = true where people_ref = 1 and language_country = ''en'' ', 'People: Set english to true for user 1 -> should be ok');
SELECT lives_ok('UPDATE users_languages set preferred_language = false where users_ref = 1 and language_country = ''en'' ', 'Users: Set english to true for user 1 -> should be ok');

SELECT lives_ok('INSERT INTO people_languages (people_ref, language_country, preferred_language) VALUES (2, ''fr'', true)', 'People: New person inserted with first preferred language inserted -> should be ok');
SELECT lives_ok('INSERT INTO users_languages (users_ref, language_country, preferred_language) VALUES (2, ''fr'', true)', 'Users: New user inserted with first preferred language inserted -> should be ok');

-- Finish the tests and clean up.
SELECT * FROM finish();
ROLLBACK;
{'fraction_non_alphanumeric': 0.11581067472306143, 'fraction_numerical': 0.01812688821752266, 'mean_word_length': 6.516556291390729, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '517054', 'n_tokens_mistral': 2365, 'n_tokens_neox': 2281, 'n_words': 863}